From 0af88abc907dacc1c57a4de969ee13383a151919 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Sat, 11 Sep 2021 16:13:05 +0200 Subject: [PATCH] Ensure module output directory is generated in configure stage - subprojects using the stdlib's build interface will resolve the module output directory before it is created and error without this fix --- src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b56d75b0e..8639308cc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,6 +66,12 @@ set(SRC add_library(${PROJECT_NAME} ${SRC}) set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/) +# We need the module directory before we finish the configure stage since the +# build interface might resolve before the module directory is generated by CMake +if(NOT EXISTS "${LIB_MOD_DIR}") + make_directory("${LIB_MOD_DIR}") +endif() + set_target_properties(${PROJECT_NAME} PROPERTIES Fortran_MODULE_DIRECTORY ${LIB_MOD_DIR}) target_include_directories(${PROJECT_NAME} PUBLIC