From b140da37be6c8f26f6300ee123906210cd39271d Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 12 Mar 2025 12:43:29 -0600 Subject: [PATCH 1/2] Update src/CMakeLists.txt: use modern cmake features to install Fortran modules in the correct place (#4) Update CMakeLists.txt to: - Bring in updates from NCAR ccpp-framework main as needed and update CMakeLists.txt to modern cmake version 3 - Support NEPTUNE cmake build while retaining compatibility with UFS/SCM --- src/CMakeLists.txt | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eaa78afe..3b787aec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,26 +4,7 @@ set(SOURCES_F90 ccpp_types.F90 ) -# Generate list of Fortran modules from defined sources -foreach(source_f90 ${SOURCES_F90}) - string(REGEX REPLACE ".F90" ".mod" module_f90 ${source_f90}) - list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90}) -endforeach() - -#------------------------------------------------------------------------------ -# Add the toplevel source directory to our include directoies (for .h) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -# Add the toplevel binary directory to our include directoies (for .mod) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Set a cached variable containing the includes, so schemes can use them -set(${PACKAGE}_INCLUDE_DIRS - "${CMAKE_CURRENT_SOURCE_DIR}$${CMAKE_CURRENT_BINARY_DIR}" - CACHE FILEPATH "${PACKAGE} include directories") -set(${PACKAGE}_LIB_DIRS - "${CMAKE_CURRENT_BINARY_DIR}" - CACHE FILEPATH "${PACKAGE} library directories") +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}) #------------------------------------------------------------------------------ # Define the executable and what to link @@ -37,16 +18,17 @@ set_target_properties(ccpp_framework PROPERTIES VERSION ${PROJECT_VERSION} # Installation # target_include_directories(ccpp_framework PUBLIC - $ - $ + INTERFACE $ + $ ) + # Define where to install the library install(TARGETS ccpp_framework EXPORT ccpp_framework-targets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib - RUNTIME DESTINATION lib + RUNTIME DESTINATION bin ) # Export our configuration @@ -55,5 +37,4 @@ install(EXPORT ccpp_framework-targets DESTINATION lib/cmake ) -# Define where to install the Fortran modules -install(FILES ${MODULES_F90} DESTINATION include) +install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) From 463d5ad7d8f52b786c74518751240548d8bbae10 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Tue, 18 Mar 2025 21:25:43 -0600 Subject: [PATCH 2/2] Add missing 'include(GNUInstallDirs)' in src/CMakeLists.txt --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b787aec..4ff78a81 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,5 @@ +include(GNUInstallDirs) + #------------------------------------------------------------------------------ # Set the sources set(SOURCES_F90