Skip to content

Commit 5905dfb

Browse files
authored
Ensure module output directory is generated in configure stage (#521)
- subprojects using the stdlib's build interface will resolve the module output directory before it is created and error without this fix
1 parent 0bf8fd2 commit 5905dfb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ set(SRC
6666
add_library(${PROJECT_NAME} ${SRC})
6767

6868
set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/)
69+
# We need the module directory before we finish the configure stage since the
70+
# build interface might resolve before the module directory is generated by CMake
71+
if(NOT EXISTS "${LIB_MOD_DIR}")
72+
make_directory("${LIB_MOD_DIR}")
73+
endif()
74+
6975
set_target_properties(${PROJECT_NAME} PROPERTIES
7076
Fortran_MODULE_DIRECTORY ${LIB_MOD_DIR})
7177
target_include_directories(${PROJECT_NAME} PUBLIC

0 commit comments

Comments
 (0)