diff --git a/CMakeLists.txt b/CMakeLists.txt index 18107bcf44c..f229c8df619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,7 +326,12 @@ add_subdirectory(src/ConvertInputFormat) if(BUILD_FORTRAN) include(CMakeAddFortranSubdirectory) - include(cmake/Fortran.cmake) + if (UNIX) + # Define a top-level target `fortran_project_options` + # It seems that CMakeAddFortranSubdirectory] doesn't know about the target `fortran_project_option` on Windows only. + # On Unix it is seen and detected as multiple targets defined with the same name (CMP0002) + include(cmake/Fortran.cmake) + endif() cmake_add_fortran_subdirectory( src/ExpandObjects PROJECT ExpandObjects diff --git a/src/AppGPostProcess/CMakeLists.txt b/src/AppGPostProcess/CMakeLists.txt index f47b9310e99..b73311344ef 100644 --- a/src/AppGPostProcess/CMakeLists.txt +++ b/src/AppGPostProcess/CMakeLists.txt @@ -16,7 +16,11 @@ set(SKIP_BUILD_RPATH TRUE) add_executable(AppGPostProcess ${SRC}) set_target_properties(AppGPostProcess PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "AppGPostProcess: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(AppGPostProcess PRIVATE fortran_project_options) install(TARGETS AppGPostProcess DESTINATION PostProcess) diff --git a/src/Basement/CMakeLists.txt b/src/Basement/CMakeLists.txt index d0f65493574..ee37d3605e3 100644 --- a/src/Basement/CMakeLists.txt +++ b/src/Basement/CMakeLists.txt @@ -58,7 +58,11 @@ add_executable(Basement ${SRC}) target_compile_options(Basement PRIVATE -O1) set_target_properties(Basement PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "Basement: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(Basement PRIVATE BasementOptions fortran_project_options) install(TARGETS Basement DESTINATION PreProcess/GrndTempCalc) diff --git a/src/CalcSoilSurfTemp/CMakeLists.txt b/src/CalcSoilSurfTemp/CMakeLists.txt index 0dc919aafcf..89bc4f54c29 100644 --- a/src/CalcSoilSurfTemp/CMakeLists.txt +++ b/src/CalcSoilSurfTemp/CMakeLists.txt @@ -16,7 +16,11 @@ set(SKIP_BUILD_RPATH TRUE) add_executable(CalcSoilSurfTemp ${SRC}) set_target_properties(CalcSoilSurfTemp PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "CalcSoilSurfTemp: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(CalcSoilSurfTemp PRIVATE fortran_project_options) install(TARGETS CalcSoilSurfTemp DESTINATION PreProcess/CalcSoilSurfTemp) diff --git a/src/ConvertESOMTR/CMakeLists.txt b/src/ConvertESOMTR/CMakeLists.txt index 64e6355a295..49bb8cf2394 100644 --- a/src/ConvertESOMTR/CMakeLists.txt +++ b/src/ConvertESOMTR/CMakeLists.txt @@ -16,7 +16,11 @@ set(SKIP_BUILD_RPATH TRUE) add_executable(convertESOMTR ${SRC}) set_target_properties(convertESOMTR PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "ConvertESOMTR: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(convertESOMTR PRIVATE fortran_project_options) install(TARGETS convertESOMTR DESTINATION "PostProcess/convertESOMTRpgm/") diff --git a/src/ExpandObjects/CMakeLists.txt b/src/ExpandObjects/CMakeLists.txt index ff6e555e8cc..768c6805cbf 100644 --- a/src/ExpandObjects/CMakeLists.txt +++ b/src/ExpandObjects/CMakeLists.txt @@ -22,7 +22,11 @@ set(SKIP_BUILD_RPATH TRUE) add_executable(ExpandObjects ${SRC}) target_link_libraries(ExpandObjects PRIVATE fortran_project_options) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "ExpandObjects: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") set_target_properties(ExpandObjects PROPERTIES FOLDER Auxiliary) install(TARGETS ExpandObjects DESTINATION "./") diff --git a/src/HVAC-Diagram/CMakeLists.txt b/src/HVAC-Diagram/CMakeLists.txt index 53ec763feb0..369fe8658c4 100644 --- a/src/HVAC-Diagram/CMakeLists.txt +++ b/src/HVAC-Diagram/CMakeLists.txt @@ -16,7 +16,11 @@ set(SKIP_BUILD_RPATH true) add_executable(HVAC-Diagram ${SRC}) set_target_properties(HVAC-Diagram PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "HVAC-Diagram: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(HVAC-Diagram PRIVATE fortran_project_options) if(NOT CMAKE_Fortran_COMPILER MATCHES "ifort") diff --git a/src/ParametricPreprocessor/CMakeLists.txt b/src/ParametricPreprocessor/CMakeLists.txt index 3df9a308f4b..28369fa5157 100644 --- a/src/ParametricPreprocessor/CMakeLists.txt +++ b/src/ParametricPreprocessor/CMakeLists.txt @@ -16,7 +16,11 @@ set(SKIP_BUILD_RPATH true) add_executable(ParametricPreprocessor ${SRC}) set_target_properties(ParametricPreprocessor PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "ParametricPreprocessor: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(ParametricPreprocessor PRIVATE fortran_project_options) install(TARGETS ParametricPreprocessor DESTINATION PreProcess/ParametricPreprocessor) diff --git a/src/ReadVars/CMakeLists.txt b/src/ReadVars/CMakeLists.txt index 507b3285426..068a8b01573 100644 --- a/src/ReadVars/CMakeLists.txt +++ b/src/ReadVars/CMakeLists.txt @@ -16,7 +16,11 @@ set(SKIP_BUILD_RPATH true) add_executable(ReadVarsESO ${SRC}) set_target_properties(ReadVarsESO PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "ReadVars: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(ReadVarsESO PRIVATE fortran_project_options) install(TARGETS ReadVarsESO DESTINATION PostProcess) diff --git a/src/Slab/CMakeLists.txt b/src/Slab/CMakeLists.txt index c1e82c60eff..9fbc9fdd8b7 100644 --- a/src/Slab/CMakeLists.txt +++ b/src/Slab/CMakeLists.txt @@ -28,7 +28,11 @@ set(SKIP_BUILD_RPATH true) add_executable(Slab ${SRC}) set_target_properties(Slab PROPERTIES FOLDER Auxiliary) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "Slab: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(Slab PRIVATE fortran_project_options) install(TARGETS Slab DESTINATION PreProcess/GrndTempCalc) diff --git a/src/Transition/CMakeLists.txt b/src/Transition/CMakeLists.txt index f74075075e0..14d4a5e6553 100644 --- a/src/Transition/CMakeLists.txt +++ b/src/Transition/CMakeLists.txt @@ -29,7 +29,11 @@ add_library(TransitionLib STATIC ${LIB_SRC}) target_include_directories(TransitionLib PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_compile_options(TransitionLib PUBLIC -fbounds-check) -include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +if(NOT UNIX) # Defined as top-level target on Unix only + include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Fortran.cmake") +endif() +get_target_property(F_INTERFACE_COMPILE_FLAGS fortran_project_options INTERFACE_COMPILE_OPTIONS) +message(DEBUG "Transition: F_INTERFACE_COMPILE_FLAGS=${F_INTERFACE_COMPILE_FLAGS}") target_link_libraries(TransitionLib PUBLIC fortran_project_options) # ffree-line-length-none set(VERSIONS