[netcdf-cxx4] Export cmake targets (#14405)

* [netcdf-cxx4] Update to latest commit and also export targets file

* Revert the update to latest commit and make a patch to export cmake targets

* Revert the changes in fix-dependecy-hdf5.patch
This commit is contained in:
NancyLi1013 2020-11-11 01:37:13 +08:00 committed by GitHub
parent b24be705e9
commit 202ada4fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 3 deletions

View File

@ -1,6 +1,6 @@
Source: netcdf-cxx4
Version: 4.3.1
Port-Version: 1
Port-Version: 2
Build-Depends: hdf5, netcdf-c
Homepage: https://github.com/Unidata/netcdf-cxx4
Description: a set of machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.

View File

@ -0,0 +1,49 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f06fcc0..a19ab28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -622,9 +622,23 @@ write_basic_package_version_file(
VERSION ${NCXX_VERSION}
COMPATIBILITY SameMajorVersion
)
+
+install(
+ EXPORT netcdf-cxx4Targets
+ FILE netcdf-cxx4Targets.cmake
+ NAMESPACE netCDF::
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/netCDFCxx
+ )
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/netCDFCxxConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/netCDFCxxConfig.cmake"
+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/netCDFCxx"
+ )
+
install(
FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/netCDFCxxConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFCxxConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/netCDFCxx
COMPONENT headers
diff --git a/cxx4/CMakeLists.txt b/cxx4/CMakeLists.txt
index b433786..5ef4bed 100644
--- a/cxx4/CMakeLists.txt
+++ b/cxx4/CMakeLists.txt
@@ -32,7 +32,7 @@ SET(ALL_TLL_LIBS ${ALL_TLL_LIBS} ${HDF5_C_LIBRARY_hdf5})
SET(ALL_TLL_LIBS ${ALL_TLL_LIBS} ${EXTRA_DEPS} PARENT_SCOPE)
ADD_LIBRARY(netcdf-cxx4 ${CXX_SOURCES})
-TARGET_INCLUDE_DIRECTORIES(netcdf-cxx4 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
+TARGET_INCLUDE_DIRECTORIES(netcdf-cxx4 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
TARGET_LINK_LIBRARIES(netcdf-cxx4 ${ALL_TLL_LIBS})
SET_TARGET_PROPERTIES(netcdf-cxx4 PROPERTIES
VERSION ${NCXX_LIB_VERSION}
@@ -49,6 +49,7 @@ INSTALL(
)
INSTALL(
TARGETS netcdf-cxx4
+ EXPORT netcdf-cxx4Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

View File

@ -0,0 +1,29 @@
# NetCDF CXX Configuration Summary
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
if (@netCDF_FOUND@)
if(EXISTS "@netCDF_ROOT@")
set(netCDF_ROOT "@netCDF_ROOT@")
endif()
if(EXISTS "@netCDF_DIR@")
set(netCDF_DIR "@netCDF_DIR@")
endif()
find_dependency(netCDF)
set(NETCDF_C_LIBRARY ${netCDF_LIBRARIES})
set(NETCDF_C_INCLUDE_DIR ${netCDF_INCLUDE_DIR})
else()
set(NETCDF_C_LIBRARY "@NETCDF_C_LIBRARY@")
set(NETCDF_C_INCLUDE_DIR "@NETCDF_C_INCLUDE_DIR@")
endif()
if (NOT TARGET netCDF::netcdf)
add_library(netCDF::netcdf UNKNOWN IMPORTED)
set_target_properties(netCDF::netcdf PROPERTIES
IMPORTED_LOCATION "${NETCDF_C_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_C_INCLUDE_DIR}"
)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/netcdf-cxx4Targets.cmake")

View File

@ -8,12 +8,17 @@ vcpkg_from_github(
REF f8882188267488ef801691e69ad072e3eb217ad8 # v4.3.1
SHA512 9816acf221d196e21af19d4c3d85484934916e7c018e9b2c96aab9f5660b2f08c5db9cd8254ba3fa5f0aa5f5c5ad7bd3a3aaba559e5e640c5349d44e07a20ed3
HEAD_REF master
PATCHES fix-dependecy-hdf5.patch
PATCHES
fix-dependecy-hdf5.patch
export-cmake-targets.patch
)
#Provided by upstream https://github.com/Unidata/netcdf-cxx4/blob/master/netCDFCxxConfig.cmake.in
file(COPY ${CMAKE_CURRENT_LIST_DIR}/netCDFCxxConfig.cmake.in DESTINATION ${SOURCE_PATH})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
PREFER_NINJA
OPTIONS
-DNCXX_ENABLE_TESTS=OFF
-DCMAKE_INSTALL_CMAKECONFIGDIR=share/netCDFCxx