Skip to content

Commit b140da3

Browse files
committed
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
1 parent 4102bdb commit b140da3

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/CMakeLists.txt

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,7 @@ set(SOURCES_F90
44
ccpp_types.F90
55
)
66

7-
# Generate list of Fortran modules from defined sources
8-
foreach(source_f90 ${SOURCES_F90})
9-
string(REGEX REPLACE ".F90" ".mod" module_f90 ${source_f90})
10-
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90})
11-
endforeach()
12-
13-
#------------------------------------------------------------------------------
14-
# Add the toplevel source directory to our include directoies (for .h)
15-
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
16-
17-
# Add the toplevel binary directory to our include directoies (for .mod)
18-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
19-
20-
# Set a cached variable containing the includes, so schemes can use them
21-
set(${PACKAGE}_INCLUDE_DIRS
22-
"${CMAKE_CURRENT_SOURCE_DIR}$<SEMICOLON>${CMAKE_CURRENT_BINARY_DIR}"
23-
CACHE FILEPATH "${PACKAGE} include directories")
24-
set(${PACKAGE}_LIB_DIRS
25-
"${CMAKE_CURRENT_BINARY_DIR}"
26-
CACHE FILEPATH "${PACKAGE} library directories")
7+
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR})
278

289
#------------------------------------------------------------------------------
2910
# Define the executable and what to link
@@ -37,16 +18,17 @@ set_target_properties(ccpp_framework PROPERTIES VERSION ${PROJECT_VERSION}
3718
# Installation
3819
#
3920
target_include_directories(ccpp_framework PUBLIC
40-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
41-
$<INSTALL_INTERFACE:include>
21+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}>
22+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
4223
)
4324

25+
4426
# Define where to install the library
4527
install(TARGETS ccpp_framework
4628
EXPORT ccpp_framework-targets
4729
ARCHIVE DESTINATION lib
4830
LIBRARY DESTINATION lib
49-
RUNTIME DESTINATION lib
31+
RUNTIME DESTINATION bin
5032
)
5133

5234
# Export our configuration
@@ -55,5 +37,4 @@ install(EXPORT ccpp_framework-targets
5537
DESTINATION lib/cmake
5638
)
5739

58-
# Define where to install the Fortran modules
59-
install(FILES ${MODULES_F90} DESTINATION include)
40+
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

0 commit comments

Comments
 (0)