diff --git a/CMakeLists.txt b/CMakeLists.txt index 91ee62d54..04056bd1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1198,23 +1198,44 @@ CONFIGURE_FILE( # Create CMake package configuration files. With these, other packages using # cmake should be able to find netcdf using find_package and find_library. -# This call is paired with one in liblib. -install(EXPORT netcdf-targets - DESTINATION share/cmake - COMPONENT documentation) +# The EXPORT call is paired with one in liblib. +set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF) +install(EXPORT netCDFTargets + DESTINATION ${ConfigPackageLocation} + COMPONENT Devel + ) -configure_file( - ${netCDF_SOURCE_DIR}/netcdf-config.cmake.in - ${netCDF_BINARY_DIR}/netcdf-config.cmake @ONLY) +include(CMakePackageConfigHelpers) +CONFIGURE_PACKAGE_CONFIG_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/netCDFConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/netCDFConfig.cmake" + INSTALL_DESTINATION "${ConfigPackageLocation}" + NO_CHECK_REQUIRED_COMPONENTS_MACRO + PATH_VARS + CMAKE_INSTALL_PREFIX + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR + ) -configure_file( - ${netCDF_SOURCE_DIR}/netcdf-config-version.cmake.in - ${netCDF_BINARY_DIR}/netcdf-config-version.cmake @ONLY) +INSTALL( + FILES "${CMAKE_CURRENT_BINARY_DIR}/netCDFConfig.cmake" + DESTINATION "${ConfigPackageLocation}" + COMPONENT Devel + ) -install(FILES ${netCDF_BINARY_DIR}/netcdf-config.cmake - ${netCDF_BINARY_DIR}/netcdf-config-version.cmake - DESTINATION share/cmake/netcdf) +# Create export configuration +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFConfigVersion.cmake" + VERSION ${netCDF_VERSION} + COMPATIBILITY SameMajorVersion + ) +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFConfigVersion.cmake" + DESTINATION ${ConfigPackageLocation} + COMPONENT Devel + ) ### # Create pkgconfig files. @@ -1392,19 +1413,6 @@ is_enabled(USE_MMAP HAS_MMAP) is_enabled(JNA HAS_JNA) # Generate file from template. -include(CMakePackageConfigHelpers) -set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF) -CONFIGURE_PACKAGE_CONFIG_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/netCDFConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/netCDFConfig.cmake" - INSTALL_DESTINATION "${ConfigPackageLocation}" - NO_CHECK_REQUIRED_COMPONENTS_MACRO - PATH_VARS - CMAKE_INSTALL_PREFIX - CMAKE_INSTALL_INCLUDEDIR - CMAKE_INSTALL_LIBDIR - ) - CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in" "${CMAKE_CURRENT_BINARY_DIR}/libnetcdf.settings" @ONLY) @@ -1422,26 +1430,6 @@ INSTALL(FILES "${netCDF_BINARY_DIR}/libnetcdf.settings" DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT libraries) -INSTALL( - FILES "${CMAKE_CURRENT_BINARY_DIR}/netCDFConfig.cmake" - DESTINATION "${ConfigPackageLocation}" - COMPONENT Devel - ) - -# Create export configuration -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFConfigVersion.cmake" - VERSION ${netCDF_VERSION} - COMPATIBILITY SameMajorVersion - ) - -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFConfigVersion.cmake" - DESTINATION ${ConfigPackageLocation} - COMPONENT Devel - ) - ##### # End libnetcdf.settings section. ##### diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt index 8b12cc52a..06e3fbbff 100644 --- a/liblib/CMakeLists.txt +++ b/liblib/CMakeLists.txt @@ -90,9 +90,14 @@ SET_TARGET_PROPERTIES(netcdf PROPERTIES ) INSTALL( - TARGETS netcdf EXPORT netcdf-targets RUNTIME DESTINATION bin COMPONENT libraries - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + TARGETS netcdf EXPORT netCDFTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT libraries + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT libraries + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) SET(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE) diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in index 3271c28dd..717213650 100644 --- a/netCDFConfig.cmake.in +++ b/netCDFConfig.cmake.in @@ -9,6 +9,8 @@ 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") + # Compiling Options # set(netCDF_C_COMPILER @CC_VERSION@) diff --git a/netcdf-config-version.cmake.in b/netcdf-config-version.cmake.in deleted file mode 100644 index d6aa98880..000000000 --- a/netcdf-config-version.cmake.in +++ /dev/null @@ -1,10 +0,0 @@ -# Cmake Package & Configuration file support. -# Based on code from 'Mastering Cmake' - -set (PACKAGE_VERSION "@VERSION@") -if (NOT "${PACKAGE_FIND_VERSION}" VERSION_GREATER "@VERSION@") - set (PACKAGE_VERSION_COMPATIBLE 1) # Compatible with older. - if ("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "@VERSION@") - set(PACKAGE_VERSION_EXACT 1) # exact match for this version. - endif() -endif() diff --git a/netcdf-config.cmake.in b/netcdf-config.cmake.in deleted file mode 100644 index 3903f82f1..000000000 --- a/netcdf-config.cmake.in +++ /dev/null @@ -1,15 +0,0 @@ -# Cmake Package & Configuration file support. -# Based on code from 'Mastering Cmake' - -# Compute installation prefix relative to this file. -get_filename_component (_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) -get_filename_component (_prefix "${_dir}/../.." ABSOLUTE) - -# Import the targets -include ("${_prefix}/share/cmake/netcdf-targets.cmake") - -# Report other information -set (netcdf_INCLUDE_DIRS "${_prefix}/include/") - -set (netcdf_LIBRARIES "netcdf") -