Skip to content

Commit dc7e49b

Browse files
authored
Merge pull request #109 from nncarlson/target-include
Update CMakeLists handling of .mod files
2 parents f300f4a + cb7cf71 commit dc7e49b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ cmake_minimum_required(VERSION 3.14.0)
22
project(stdlib Fortran)
33
enable_testing()
44

5-
# this avoids stdlib and projects using stdlib from having to introspect stdlib's directory structure
6-
# FIXME: this eventually needs to be handled more precisely, as this spills all .mod/.smod into one directory
7-
# and thereby can clash if module/submodule names are the same in different parts of library
8-
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR})
9-
105
# --- compiler options
116
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
127
add_compile_options(-fimplicit-none)

src/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ set(SRC
99

1010
add_library(fortran_stdlib ${SRC})
1111

12+
set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/)
13+
set_target_properties(fortran_stdlib PROPERTIES
14+
Fortran_MODULE_DIRECTORY ${LIB_MOD_DIR})
15+
target_include_directories(fortran_stdlib PUBLIC
16+
$<BUILD_INTERFACE:${LIB_MOD_DIR}>
17+
$<INSTALL_INTERFACE:include>
18+
)
19+
1220
if(f18errorstop)
1321
target_sources(fortran_stdlib PRIVATE f18estop.f90)
1422
else()
@@ -22,3 +30,4 @@ install(TARGETS fortran_stdlib
2230
ARCHIVE DESTINATION lib
2331
LIBRARY DESTINATION lib
2432
)
33+
install(DIRECTORY ${LIB_MOD_DIR} DESTINATION include)

0 commit comments

Comments
 (0)