CMake: Export targets so the build directory can be used directly

This commit is contained in:
Peter Hill 2023-10-20 17:47:18 +01:00
parent cb61d34185
commit 5ee66e87ac
No known key found for this signature in database
GPG Key ID: 0C6B9742E72848EE
2 changed files with 7 additions and 5 deletions

View File

@ -2745,6 +2745,11 @@ install(EXPORT netCDFTargets
NAMESPACE netCDF::
)
export(EXPORT netCDFTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/netCDFTargets.cmake"
NAMESPACE netCDF::
)
include(CMakePackageConfigHelpers)
CONFIGURE_PACKAGE_CONFIG_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/netCDFConfig.cmake.in"
@ -2772,14 +2777,14 @@ target_include_directories(netcdf
# Create export configuration
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFConfigVersion.cmake"
netCDFConfigVersion.cmake
VERSION ${netCDF_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/netCDFConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
COMPONENT headers
)

View File

@ -5,9 +5,6 @@
@PACKAGE_INIT@
set(NetCDFVersion "@PACKAGE_VERSION@")
set_and_check(netCDF_INSTALL_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@")
set_and_check(netCDF_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set_and_check(netCDF_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
set(netCDF_LIBRARIES netCDF::netcdf)