Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2745,6 +2745,11 @@ install(EXPORT netCDFTargets
NAMESPACE netCDF::
)

export(EXPORT netCDFTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/netCDFTargets.cmake"
ZedThree marked this conversation as resolved.
Show resolved Hide resolved
NAMESPACE netCDF::
)

include(CMakePackageConfigHelpers)
CONFIGURE_PACKAGE_CONFIG_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/netCDFConfig.cmake.in"
Expand Down Expand Up @@ -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"
ZedThree marked this conversation as resolved.
Show resolved Hide resolved
DESTINATION ${ConfigPackageLocation}
COMPONENT headers
)
Expand Down
3 changes: 0 additions & 3 deletions netCDFConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading