Skip to content

Commit 622ff41

Browse files
dougiesquireharshula
authored andcommitted
CMakeLists.txt: configure and install cmake config file
* GFDLGTracersConfig.cmake.in: use find_dependency instead of find_package See https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html
1 parent d3195f5 commit 622ff41

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ project(GFDLGTracers
1010
)
1111

1212
include(GNUInstallDirs)
13+
include(CMakePackageConfigHelpers)
1314

1415
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
1516
message(STATUS "Setting build type to 'Relwithdebinfo' as none was specified.")
@@ -115,6 +116,16 @@ install(EXPORT GFDLGTracersTargets
115116
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GFDLGTracers
116117
)
117118

119+
configure_package_config_file(
120+
cmake/GFDLGTracersConfig.cmake.in
121+
"${CMAKE_CURRENT_BINARY_DIR}/GFDLGTracersConfig.cmake"
122+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GFDLGTracers
123+
)
124+
125+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GFDLGTracersConfig.cmake
126+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/GFDLGTracers
127+
)
128+
118129
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/GFDLGTracers.pc.in
119130
${CMAKE_CURRENT_BINARY_DIR}/GFDLGTracers.pc @ONLY)
120131

cmake/GFDLGTracersConfig.cmake.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright ACCESS-NRI and contributors. See the top-level LICENSE file for details.
2+
3+
@PACKAGE_INIT@
4+
5+
if(NOT GFDLGTracers_FIND_QUIETLY)
6+
message(STATUS "Found GFDLGTracers: ${PACKAGE_PREFIX_DIR}")
7+
endif()
8+
9+
include(CMakeFindDependencyMacro)
10+
11+
# Request components
12+
set(_required_components ${GFDLGTracers_FIND_COMPONENTS})
13+
14+
find_dependency(MPI REQUIRED COMPONENTS Fortran)
15+
find_dependency(fms COMPONENTS R8 REQUIRED)
16+
find_dependency(PkgConfig REQUIRED)
17+
pkg_check_modules(MOCSY REQUIRED IMPORTED_TARGET "mocsy")
18+
19+
# Run the normal Targets.cmake
20+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
21+
include("${CMAKE_CURRENT_LIST_DIR}/GFDLGTracersTargets.cmake")
22+
list(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
23+
24+
# Check the requested components are valid
25+
check_required_components(_required_components)

0 commit comments

Comments
 (0)