mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-24 16:04:40 +08:00
setting up packaging in its own directory, using netcdf as a target for compile options
This commit is contained in:
parent
05ce85be78
commit
887c479533
@ -33,6 +33,15 @@ if (NOT DEFINED NETCDF_IS_TOP_LEVEL)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
################################
|
||||
# The target
|
||||
################################
|
||||
|
||||
add_library(netcdf)
|
||||
add_library(netCDF::netcdf ALIAS netcdf)
|
||||
|
||||
|
||||
#####
|
||||
# Version Info:
|
||||
#
|
||||
@ -1402,11 +1411,6 @@ add_definitions(-DHAVE_CONFIG_H)
|
||||
include_directories(${netCDF_BINARY_DIR})
|
||||
# End autotools-style checks for config.h
|
||||
|
||||
#####
|
||||
# Set core names of the libraries.
|
||||
#####
|
||||
set(netCDF_LIB_CORENAME "netcdf")
|
||||
|
||||
#####
|
||||
# Set the true names of all the libraries, if customized by external project
|
||||
#####
|
||||
@ -1477,7 +1481,7 @@ endif()
|
||||
# For tests and utilities, we are no longer
|
||||
# exporting symbols but rather importing them.
|
||||
if(BUILD_DLL)
|
||||
REMOVE_DEFINITIONS(-DDLL_EXPORT)
|
||||
remove_definitions(-DDLL_EXPORT)
|
||||
endif()
|
||||
|
||||
# Enable Utilities.
|
||||
@ -1716,14 +1720,14 @@ else()
|
||||
endif()
|
||||
|
||||
if(WITH_S3_TESTING STREQUAL PUBLIC)
|
||||
set(ENABLE_S3_TESTING "public")
|
||||
set(ENABLE_S3_TESTING "public")
|
||||
elseif(WITH_S3_TESTING)
|
||||
set(ENABLE_S3_TESTING "yes")
|
||||
set(ENABLE_S3_TESTALL "yes")
|
||||
set(ENABLE_S3_TESTING "yes")
|
||||
set(ENABLE_S3_TESTALL "yes")
|
||||
elseif(NOT WITH_S3_TESTING)
|
||||
set(ENABLE_S3_TESTING "no")
|
||||
set(ENABLE_S3_TESTING "no")
|
||||
else()
|
||||
set(ENABLE_S3_TESTING "no")
|
||||
set(ENABLE_S3_TESTING "no")
|
||||
endif()
|
||||
|
||||
# The Unidata testing S3 bucket
|
||||
@ -1833,68 +1837,3 @@ endif()
|
||||
if(DEFINED ENV{LIB_FUZZING_ENGINE})
|
||||
add_subdirectory(fuzz)
|
||||
endif(DEFINED ENV{LIB_FUZZING_ENGINE})
|
||||
|
||||
####
|
||||
# Export files
|
||||
####
|
||||
|
||||
# Create CMake package configuration files. With these, other packages using
|
||||
# cmake should be able to find netcdf using find_package and find_library.
|
||||
# The EXPORT call is paired with one in liblib.
|
||||
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF)
|
||||
|
||||
install(EXPORT netCDFTargets
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
COMPONENT headers
|
||||
NAMESPACE netCDF::
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/netCDFConfig.cmake"
|
||||
DESTINATION "${ConfigPackageLocation}"
|
||||
COMPONENT headers
|
||||
)
|
||||
|
||||
add_library(netCDF::netcdf ALIAS netcdf)
|
||||
target_include_directories(netcdf
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
# 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 headers
|
||||
)
|
||||
|
||||
####
|
||||
# End export files
|
||||
####
|
||||
|
||||
# CPack inclusion must come last.
|
||||
option(NETCDF_PACKAGE "Create netCDF-C package " ${NETCDF_IS_TOP_LEVEL})
|
||||
|
||||
if (NETCDF_PACKAGE)
|
||||
include(CMakeInstallation.cmake)
|
||||
endif()
|
||||
|
@ -22,7 +22,11 @@ if(ENABLE_HDF4)
|
||||
if(NOT MFHDF_H_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "HDF4 Support specified, cannot find file mfhdf.h")
|
||||
else()
|
||||
include_directories(${MFHDF_H_INCLUDE_DIR})
|
||||
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${MFHDF_H_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(HDF4_DF_LIB NAMES df libdf hdf)
|
||||
@ -50,7 +54,11 @@ if(ENABLE_HDF4)
|
||||
else()
|
||||
set(HAVE_JPEGLIB_H ON CACHE BOOL "")
|
||||
set(HAVE_LIBJPEG TRUE )
|
||||
include_directories(${JPEGLIB_H_INCLUDE_DIR})
|
||||
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${JPEGLIB_H_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(JPEG_LIB NAMES jpeg libjpeg)
|
||||
@ -115,7 +123,10 @@ if(USE_HDF5)
|
||||
set(HDF5_C_LIBRARIES ${HDF5_C_LIBRARY} )
|
||||
set(HDF5_C_LIBRARY_hdf5 ${HDF5_C_LIBRARY} )
|
||||
set(HDF5_HL_LIBRARIES ${HDF5_HL_LIBRARY} )
|
||||
include_directories(${HDF5_INCLUDE_DIR})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HDF5_INCLUDE_DIR}
|
||||
)
|
||||
message(STATUS "Using HDF5 C Library: ${HDF5_C_LIBRARY}")
|
||||
message(STATUS "Using HDF5 HL LIbrary: ${HDF5_HL_LIBRARY}")
|
||||
if (EXISTS "${HDF5_INCLUDE_DIR}/H5pubconf.h")
|
||||
@ -231,7 +242,10 @@ if(USE_HDF5)
|
||||
set(HDF5_INCLUDE_DIR ${HDF5_INCLUDE_DIRS} )
|
||||
endif()
|
||||
message(STATUS "Using HDF5 include dir: ${HDF5_INCLUDE_DIR}")
|
||||
include_directories(${HDF5_INCLUDE_DIR})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HDF5_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
###
|
||||
# This is the block where we figure out what the appropriate
|
||||
@ -299,7 +313,10 @@ if(USE_HDF5)
|
||||
if(NOT HAVE_HDF5_H)
|
||||
message(FATAL_ERROR "Compiling a test with hdf5 failed. Either hdf5.h cannot be found, or the log messages should be checked for another reason.")
|
||||
else(NOT HAVE_HDF5_H)
|
||||
include_directories(${HAVE_HDF5_H})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HAVE_HDF5_H}
|
||||
)
|
||||
endif(NOT HAVE_HDF5_H)
|
||||
|
||||
set (CMAKE_REQUIRED_INCLUDES ${HDF5_INCLUDE_DIR})
|
||||
@ -407,11 +424,17 @@ if(USE_HDF5)
|
||||
if(NOT HAVE_HDF5_H)
|
||||
message(FATAL_ERROR "Compiling a test with hdf5 failed. Either hdf5.h cannot be found, or the log messages should be checked for another reason.")
|
||||
else(NOT HAVE_HDF5_H)
|
||||
include_directories(${HAVE_HDF5_H})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HAVE_HDF5_H}
|
||||
)
|
||||
endif(NOT HAVE_HDF5_H)
|
||||
|
||||
#option to include HDF5 High Level header file (hdf5_hl.h) in case we are not doing a make install
|
||||
include_directories(${HDF5_HL_INCLUDE_DIR})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${HDF5_HL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
endif(USE_HDF5)
|
||||
|
||||
@ -420,8 +443,14 @@ endif(USE_HDF5)
|
||||
################################
|
||||
# See if we have libcurl
|
||||
find_package(CURL)
|
||||
ADD_DEFINITIONS(-DCURL_STATICLIB=1)
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
target_compile_options(netcdf
|
||||
PRIVATE
|
||||
-DCURL_STATICLIB=1
|
||||
)
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${CURL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Define a test flag for have curl library
|
||||
if(CURL_LIBRARIES OR CURL_LIBRARY)
|
||||
@ -527,7 +556,10 @@ find_package(ZLIB)
|
||||
|
||||
# Define a test flag for have zlib library
|
||||
if(ZLIB_FOUND)
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
)
|
||||
set(ENABLE_ZLIB TRUE)
|
||||
else()
|
||||
set(ENABLE_ZLIB FALSE)
|
||||
@ -573,7 +605,10 @@ endif()
|
||||
|
||||
IF (ENABLE_NCZARR_ZIP)
|
||||
find_package(Zip REQUIRED)
|
||||
include_directories(${Zip_INCLUDE_DIRS})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${Zip_INCLUDE_DIRS}
|
||||
)
|
||||
endif ()
|
||||
|
||||
################################
|
||||
@ -588,7 +623,10 @@ if(ENABLE_S3)
|
||||
find_package(AWSSDK REQUIRED COMPONENTS s3;transfer)
|
||||
if(AWSSDK_FOUND)
|
||||
set(ENABLE_S3_AWS ON CACHE BOOL "S3 AWS" FORCE)
|
||||
include_directories(${AWSSDK_INCLUDE_DIR})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${AWSSDK_INCLUDE_DIR}
|
||||
)
|
||||
else(AWSSDK_FOUND)
|
||||
set(ENABLE_S3_AWS OFF CACHE BOOL "S3 AWS" FORCE)
|
||||
endif(AWSSDK_FOUND)
|
||||
@ -618,7 +656,10 @@ if(ENABLE_LIBXML2)
|
||||
find_package(LibXml2)
|
||||
if(LibXml2_FOUND)
|
||||
set(HAVE_LIBXML2 TRUE)
|
||||
include_directories(${LIBXML2_INCLUDE_DIRS})
|
||||
target_include_directories(netcdf
|
||||
PRIVATE
|
||||
${LIBXML2_INCLUDE_DIRS}
|
||||
)
|
||||
set(XMLPARSER "libxml2")
|
||||
else()
|
||||
set(HAVE_LIBXML2 FALSE)
|
||||
|
@ -4,194 +4,221 @@
|
||||
# University Corporation for Atmospheric Research/Unidata.
|
||||
|
||||
# See netcdf-c/COPYRIGHT file for more info.
|
||||
SET(liblib_LIBS dispatch netcdf3)
|
||||
|
||||
#####
|
||||
# Add target objects/modules based on options.
|
||||
#####
|
||||
|
||||
IF(USE_NETCDF4)
|
||||
SET(liblib_LIBS ${liblib_LIBS} netcdf4)
|
||||
ENDIF()
|
||||
IF(USE_HDF5)
|
||||
SET(liblib_LIBS ${liblib_LIBS} netcdfhdf5)
|
||||
ENDIF()
|
||||
if(USE_NETCDF4)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:netcdf4>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(USE_PNETCDF)
|
||||
SET(liblib_LIBS ${liblib_LIBS} netcdfp)
|
||||
ENDIF()
|
||||
if(USE_HDF5)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:netcdfhdf5>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(USE_HDF4)
|
||||
SET(liblib_LIBS ${liblib_LIBS} netcdfhdf4)
|
||||
ENDIF()
|
||||
if(USE_PNETCDF)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:netcdfp>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(ENABLE_DAP2)
|
||||
SET(liblib_LIBS ${liblib_LIBS} oc2 dap2)
|
||||
ENDIF()
|
||||
if(USE_HDF4)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:netcdfhdf4>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(ENABLE_DAP4)
|
||||
SET(liblib_LIBS ${liblib_LIBS} dap4)
|
||||
SET(liblib_LIBS ${liblib_LIBS} ncxml)
|
||||
ENDIF()
|
||||
if(ENABLE_DAP2)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:oc2>
|
||||
$<TARGET_OBJECTS:dap2>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(ENABLE_NCZARR)
|
||||
SET(liblib_LIBS ${liblib_LIBS} nczarr)
|
||||
ENDIF()
|
||||
if(ENABLE_DAP4)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:dap4>
|
||||
$<TARGET_OBJECTS:ncxml>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(ENABLE_S3_INTERNAL)
|
||||
SET(liblib_LIBS ${liblib_LIBS} ncxml)
|
||||
ENDIF()
|
||||
if(ENABLE_NCZARR)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:nczarr>
|
||||
)
|
||||
endif()
|
||||
|
||||
IF(ENABLE_PLUGINS)
|
||||
SET(liblib_LIBS ${liblib_LIBS} ncpoco)
|
||||
ENDIF()
|
||||
if(ENABLE_S3_INTERNAL)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:ncxml>
|
||||
)
|
||||
endif()
|
||||
|
||||
FOREACH(LIBS ${liblib_LIBS})
|
||||
SET(LARGS ${LARGS} $<TARGET_OBJECTS:${LIBS}>)
|
||||
ENDFOREACH()
|
||||
if(ENABLE_PLUGINS)
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:ncpoco>
|
||||
)
|
||||
endif()
|
||||
|
||||
ADD_LIBRARY(netcdf nc_initialize.c ${LARGS} )
|
||||
target_sources(netcdf
|
||||
PRIVATE
|
||||
nc_initialize.c
|
||||
)
|
||||
|
||||
IF(STATUS_PARALLEL)
|
||||
if(STATUS_PARALLEL)
|
||||
# TODO: Make PUBLIC when other dependencies have PUBLIC/PRIVATE specified
|
||||
target_link_libraries(netcdf MPI::MPI_C)
|
||||
ENDIF(STATUS_PARALLEL)
|
||||
endif(STATUS_PARALLEL)
|
||||
|
||||
IF(TARGET MPI::MPI_C)
|
||||
if(TARGET MPI::MPI_C)
|
||||
target_link_libraries(netcdf MPI::MPI_C)
|
||||
ENDIF(TARGET MPI::MPI_C)
|
||||
endif(TARGET MPI::MPI_C)
|
||||
|
||||
IF(MOD_NETCDF_NAME)
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES LIBRARY_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES ARCHIVE_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES RUNTIME_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
ENDIF()
|
||||
if(MOD_NETCDF_NAME)
|
||||
set_target_properties(netcdf PROPERTIES LIBRARY_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
set_target_properties(netcdf PROPERTIES ARCHIVE_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
set_target_properties(netcdf PROPERTIES RUNTIME_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
endif()
|
||||
|
||||
# Make sure that netcdf.dll path does not include the build configuration
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
ENDIF()
|
||||
if(MSVC)
|
||||
set_target_properties(netcdf PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
#####
|
||||
# Add dependencies required for linking.
|
||||
#####
|
||||
|
||||
SET(TLL_LIBS "")
|
||||
set(TLL_LIBS "")
|
||||
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ${ZLIB_LIBRARY})
|
||||
set(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ${ZLIB_LIBRARY})
|
||||
|
||||
# Add extra dependencies specified via NC_EXTRA_DEPS
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${EXTRA_DEPS})
|
||||
set(TLL_LIBS ${TLL_LIBS} ${EXTRA_DEPS})
|
||||
|
||||
IF(ENABLE_NCZARR_ZIP)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
|
||||
ENDIF()
|
||||
if(ENABLE_NCZARR_ZIP)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
|
||||
endif()
|
||||
|
||||
IF(Blosc_FOUND)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Blosc_LIBRARIES})
|
||||
ENDIF()
|
||||
IF(Zstd_FOUND)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Zstd_LIBRARIES})
|
||||
ENDIF()
|
||||
IF(Bz2_FOUND)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Bz2_LIBRARIES})
|
||||
ENDIF()
|
||||
IF(SZIP_FOUND)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
ENDIF()
|
||||
if(Blosc_FOUND)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${Blosc_LIBRARIES})
|
||||
endif()
|
||||
if(Zstd_FOUND)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${Zstd_LIBRARIES})
|
||||
endif()
|
||||
if(Bz2_FOUND)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${Bz2_LIBRARIES})
|
||||
endif()
|
||||
if(SZIP_FOUND)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
endif()
|
||||
|
||||
IF(HAVE_LIBDL)
|
||||
SET(TLL_LIBS ${LIBDL} ${TLL_LIBS})
|
||||
ENDIF()
|
||||
if(HAVE_LIBDL)
|
||||
set(TLL_LIBS ${LIBDL} ${TLL_LIBS})
|
||||
endif()
|
||||
|
||||
IF(ENABLE_NCZARR_ZIP)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
|
||||
ENDIF()
|
||||
if(ENABLE_NCZARR_ZIP)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
|
||||
endif()
|
||||
|
||||
IF(USE_HDF5)
|
||||
IF(NOT MSVC)
|
||||
if(USE_HDF5)
|
||||
if(NOT MSVC)
|
||||
# Some version of cmake define HDF5_hdf5_LIBRARY instead of
|
||||
# HDF5_LIBRARY. Same with HDF5_HL_LIBRARIES
|
||||
IF(HDF5_hdf5_LIBRARY AND NOT HDF5_C_LIBRARIES)
|
||||
SET(HDF5_C_LIBRARIES ${HDF5_hdf5_LIBRARY})
|
||||
ENDIF()
|
||||
IF(HDF5_hdf5_hl_LIBRARY AND NOT HDF5_HL_LIBRARIES)
|
||||
SET(HDF5_HL_LIBRARIES ${HDF5_hdf5_hl_LIBRARY})
|
||||
ENDIF()
|
||||
if(HDF5_hdf5_LIBRARY AND NOT HDF5_C_LIBRARIES)
|
||||
set(HDF5_C_LIBRARIES ${HDF5_hdf5_LIBRARY})
|
||||
endif()
|
||||
if(HDF5_hdf5_hl_LIBRARY AND NOT HDF5_HL_LIBRARIES)
|
||||
set(HDF5_HL_LIBRARIES ${HDF5_hdf5_hl_LIBRARY})
|
||||
endif()
|
||||
# The order of the libraries is important here for static
|
||||
# builds:
|
||||
# Make sure that HDF5_C_LIBRARY appears *after*
|
||||
# HDF5_HL_LIBRARY.
|
||||
SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
ELSE() # Windows CMake defines HDF5_LIBRARIES.
|
||||
SET(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
set(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
else() # Windows CMake defines HDF5_LIBRARIES.
|
||||
set(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(FOUND_CURL)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES})
|
||||
ENDIF()
|
||||
if(FOUND_CURL)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
IF(USE_HDF4)
|
||||
SET(TLL_LIBS ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB} ${TLL_LIBS})
|
||||
ENDIF()
|
||||
if(USE_HDF4)
|
||||
set(TLL_LIBS ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB} ${TLL_LIBS})
|
||||
endif()
|
||||
|
||||
IF(ENABLE_PNETCDF AND PNETCDF)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${PNETCDF})
|
||||
ENDIF()
|
||||
if(ENABLE_PNETCDF AND PNETCDF)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${PNETCDF})
|
||||
endif()
|
||||
|
||||
|
||||
IF(ENABLE_S3)
|
||||
IF(ENABLE_S3_AWS)
|
||||
if(ENABLE_S3)
|
||||
if(ENABLE_S3_AWS)
|
||||
TARGET_LINK_DIRECTORIES(netcdf PUBLIC ${AWSSDK_LIB_DIR})
|
||||
SET(TLL_LIBS ${AWSSDK_LINK_LIBRARIES} ${TLL_LIBS})
|
||||
ELSEIF(ENABLE_S3_INTERNAL)
|
||||
IF(OPENSSL_FOUND)
|
||||
SET(TLL_LIBS ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} ${TLL_LIBS})
|
||||
ENDIF(OPENSSL_FOUND)
|
||||
ENDIF(ENABLE_S3_AWS)
|
||||
ENDIF(ENABLE_S3)
|
||||
set(TLL_LIBS ${AWSSDK_LINK_LIBRARIES} ${TLL_LIBS})
|
||||
elseif(ENABLE_S3_INTERNAL)
|
||||
if(OPENSSL_FOUND)
|
||||
set(TLL_LIBS ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} ${TLL_LIBS})
|
||||
endif(OPENSSL_FOUND)
|
||||
endif(ENABLE_S3_AWS)
|
||||
endif(ENABLE_S3)
|
||||
|
||||
IF(HAVE_LIBXML2)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${LIBXML2_LIBRARIES})
|
||||
ENDIF()
|
||||
if(HAVE_LIBXML2)
|
||||
set(TLL_LIBS ${TLL_LIBS} ${LIBXML2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
IF(NOT WIN32)
|
||||
IF(NOT APPLE)
|
||||
IF(CMAKE_DL_LIBS)
|
||||
if(NOT WIN32)
|
||||
if(NOT APPLE)
|
||||
if(CMAKE_DL_LIBS)
|
||||
TARGET_LINK_LIBRARIES(netcdf ${CMAKE_DL_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(TLL_LIBS)
|
||||
LIST(REMOVE_DUPLICATES TLL_LIBS)
|
||||
ENDIF()
|
||||
if(TLL_LIBS)
|
||||
list(REMOVE_DUPLICATES TLL_LIBS)
|
||||
endif()
|
||||
|
||||
TARGET_LINK_LIBRARIES(netcdf ${TLL_LIBS})
|
||||
target_link_libraries(netcdf ${TLL_LIBS})
|
||||
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TLL_LIBS})
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TLL_LIBS})
|
||||
if(MSVC)
|
||||
set_target_properties(netcdf PROPERTIES
|
||||
LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
||||
)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
IF(NOT MSVC)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES LINK_FLAGS -shared)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
if(NOT MSVC)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(netcdf PROPERTIES LINK_FLAGS -shared)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(ENABLE_SHARED_LIBRARY_VERSION)
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES
|
||||
if(ENABLE_SHARED_LIBRARY_VERSION)
|
||||
set_target_properties(netcdf PROPERTIES
|
||||
VERSION ${netCDF_LIB_VERSION}
|
||||
SOVERSION ${netCDF_SO_VERSION}
|
||||
)
|
||||
ENDIF(ENABLE_SHARED_LIBRARY_VERSION)
|
||||
endif(ENABLE_SHARED_LIBRARY_VERSION)
|
||||
|
||||
###
|
||||
# The INCLUDES directive was introduced in 2.8.12.
|
||||
@ -200,7 +227,7 @@ ENDIF(ENABLE_SHARED_LIBRARY_VERSION)
|
||||
# https://github.com/Unidata/netcdf-c/issues/135
|
||||
# for more information.
|
||||
###
|
||||
IF(${CMAKE_VERSION} VERSION_LESS 2.8.12)
|
||||
if(${CMAKE_VERSION} VERSION_LESS 2.8.12)
|
||||
INSTALL(
|
||||
TARGETS netcdf EXPORT netCDFTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
|
||||
@ -208,7 +235,7 @@ IF(${CMAKE_VERSION} VERSION_LESS 2.8.12)
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
ELSE()
|
||||
else()
|
||||
INSTALL(
|
||||
TARGETS netcdf EXPORT netCDFTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
|
||||
@ -216,11 +243,11 @@ ELSE()
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
SET(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)
|
||||
SET(NC_LIBS ${NC_LIBS} PARENT_SCOPE)
|
||||
set(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)
|
||||
set(NC_LIBS ${NC_LIBS} PARENT_SCOPE)
|
||||
|
||||
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
||||
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
|
||||
set(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
|
||||
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
|
||||
|
@ -1,77 +1,76 @@
|
||||
## This is a CMake file, part of Unidata's netCDF package.
|
||||
# Copyright 2012-2018, see the COPYRIGHT file for more information.
|
||||
|
||||
SET(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c
|
||||
set(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c
|
||||
nc3internal.c var.c dim.c ncx.c lookup3.c ncio.c)
|
||||
|
||||
# Process these files with m4.
|
||||
SET(m4_SOURCES attr ncx putget)
|
||||
set(m4_SOURCES attr ncx putget)
|
||||
foreach (f ${m4_SOURCES})
|
||||
GEN_m4(${f} dest)
|
||||
LIST(APPEND libsrc_SOURCES ${dest})
|
||||
list(APPEND libsrc_SOURCES ${dest})
|
||||
endforeach(f)
|
||||
|
||||
LIST(APPEND libsrc_SOURCES pstdint.h ncio.h ncx.h)
|
||||
list(APPEND libsrc_SOURCES pstdint.h ncio.h ncx.h)
|
||||
|
||||
LIST(APPEND libsrc_SOURCES memio.c)
|
||||
list(APPEND libsrc_SOURCES memio.c)
|
||||
|
||||
IF (BUILD_MMAP)
|
||||
LIST(APPEND libsrc_SOURCES mmapio.c)
|
||||
ENDIF( BUILD_MMAP)
|
||||
if (BUILD_MMAP)
|
||||
list(APPEND libsrc_SOURCES mmapio.c)
|
||||
endif( BUILD_MMAP)
|
||||
|
||||
IF (USE_FFIO)
|
||||
LIST(APPEND libsrc_SOURCES ffio.c)
|
||||
ELSEIF (USE_STDIO)
|
||||
if (USE_FFIO)
|
||||
list(APPEND libsrc_SOURCES ffio.c)
|
||||
elseif (USE_STDIO)
|
||||
IST(APPEND libsrc_SOURCES ncstdio.c)
|
||||
ELSE (USE_FFIO)
|
||||
LIST(APPEND libsrc_SOURCES posixio.c)
|
||||
ENDIF (USE_FFIO)
|
||||
else (USE_FFIO)
|
||||
list(APPEND libsrc_SOURCES posixio.c)
|
||||
ENDif (USE_FFIO)
|
||||
|
||||
IF (ENABLE_BYTERANGE)
|
||||
LIST(APPEND libsrc_SOURCES httpio.c)
|
||||
IF (ENABLE_S3)
|
||||
LIST(APPEND libsrc_SOURCES s3io.c)
|
||||
ENDIF(ENABLE_S3)
|
||||
ENDIF(ENABLE_BYTERANGE)
|
||||
if (ENABLE_BYTERANGE)
|
||||
list(APPEND libsrc_SOURCES httpio.c)
|
||||
if (ENABLE_S3)
|
||||
list(APPEND libsrc_SOURCES s3io.c)
|
||||
endif(ENABLE_S3)
|
||||
endif(ENABLE_BYTERANGE)
|
||||
|
||||
add_library(netcdf3 OBJECT ${libsrc_SOURCES})
|
||||
|
||||
IF(STATUS_PARALLEL)
|
||||
if(STATUS_PARALLEL)
|
||||
target_link_libraries(netcdf3 PUBLIC MPI::MPI_C)
|
||||
ENDIF(STATUS_PARALLEL)
|
||||
endif(STATUS_PARALLEL)
|
||||
|
||||
# The C API man page.
|
||||
|
||||
SET(MAN_FILES netcdf.3)
|
||||
set(MAN_FILES netcdf.3)
|
||||
|
||||
set(ARGS_MANPAGE -DAPI=C)
|
||||
|
||||
IF (USE_HDF5)
|
||||
SET(ARGS_MANPAGE ${ARGS_MANPAGE} -DNETCDF4=TRUE)
|
||||
ENDIF(USE_HDF5)
|
||||
if (USE_HDF5)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DNETCDF4=TRUE)
|
||||
endif(USE_HDF5)
|
||||
|
||||
IF (BUILD_DAP)
|
||||
SET(ARGS_MANPAGE ${ARGS_MANPAGE} -DDAP=TRUE)
|
||||
ENDIF(BUILD_DAP)
|
||||
if (BUILD_DAP)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DDAP=TRUE)
|
||||
endif(BUILD_DAP)
|
||||
|
||||
IF (BUILD_PARALLEL)
|
||||
SET(ARGS_MANPAGE ${ARGS_MANPAGE} -DPARALLEL_IO=TRUE)
|
||||
ENDIF(BUILD_PARALLEL)
|
||||
if (BUILD_PARALLEL)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DPARALLEL_IO=TRUE)
|
||||
endif(BUILD_PARALLEL)
|
||||
|
||||
# Generate the man page.
|
||||
IF(HAVE_M4)
|
||||
if(HAVE_M4)
|
||||
|
||||
FILE(GLOB libsrc_MANPAGE ${CMAKE_CURRENT_SOURCE_DIR}/../docs/netcdf.m4)
|
||||
FILE(COPY ${libsrc_MANPAGE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
IF(NOT MSVC)
|
||||
ADD_CUSTOM_TARGET(manpage ALL
|
||||
|
||||
COMMAND ${NC_M4} ${ARGS_MANPAGE} "${CMAKE_CURRENT_BINARY_DIR}/netcdf.m4" > "${CMAKE_CURRENT_BINARY_DIR}/netcdf.3"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
if(NOT MSVC)
|
||||
add_custom_target(manpage ALL
|
||||
COMMAND ${NC_M4} ${ARGS_MANPAGE} "${CMAKE_CURRENT_BINARY_DIR}/netcdf.m4" > "${CMAKE_CURRENT_BINARY_DIR}/netcdf.3"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/netcdf.3" DESTINATION "share/man/man3" COMPONENT documentation)
|
||||
ENDIF(NOT MSVC)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/netcdf.3" DESTINATION "share/man/man3" COMPONENT documentation)
|
||||
endif(NOT MSVC)
|
||||
|
||||
ENDIF()
|
||||
endif()
|
@ -6,18 +6,18 @@
|
||||
# See netcdf-c/COPYRIGHT file for more info.
|
||||
# Process these files with m4.
|
||||
|
||||
SET(libsrc4_SOURCES nc4dispatch.c nc4attr.c nc4dim.c nc4grp.c
|
||||
set(libsrc4_SOURCES nc4dispatch.c nc4attr.c nc4dim.c nc4grp.c
|
||||
nc4internal.c nc4type.c nc4var.c ncfunc.c ncindex.c nc4cache.c)
|
||||
|
||||
add_library(netcdf4 OBJECT ${libsrc4_SOURCES})
|
||||
|
||||
IF(STATUS_PARALLEL)
|
||||
target_link_libraries(netcdf4 PUBLIC MPI::MPI_C)
|
||||
ENDIF(STATUS_PARALLEL)
|
||||
if(STATUS_PARALLEL)
|
||||
target_link_libraries(netcdf4 PUBLIC MPI::MPI_C)
|
||||
endif(STATUS_PARALLEL)
|
||||
|
||||
# Files for make dist
|
||||
FILE(GLOB libsrc4_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
|
||||
SET(CUR_EXTRA_DIST CMakeLists.txt Makefile.am)
|
||||
file(GLOB libsrc4_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
|
||||
set(CUR_EXTRA_DIST CMakeLists.txt Makefile.am)
|
||||
ADD_EXTRA_DIST("${libsrc4_SOURCES}")
|
||||
ADD_EXTRA_DIST("${libsrc4_HEADERS}")
|
||||
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
|
||||
@ -34,14 +34,14 @@ set(man_MANS netcdf.3)
|
||||
|
||||
set(ARGS_MANPAGE -DAPI=C)
|
||||
|
||||
IF (USE_HDF5)
|
||||
SET(ARGS_MANPAGE ${ARGS_MANPAGE} -DNETCDF4=TRUE)
|
||||
ENDIF(USE_HDF5)
|
||||
if (USE_HDF5)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DNETCDF4=TRUE)
|
||||
endif(USE_HDF5)
|
||||
|
||||
IF (BUILD_DAP)
|
||||
SET(ARGS_MANPAGE ${ARGS_MANPAGE} -DDAP=TRUE)
|
||||
ENDIF(BUILD_DAP)
|
||||
if (BUILD_DAP)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DDAP=TRUE)
|
||||
endif(BUILD_DAP)
|
||||
|
||||
IF (BUILD_PARALLEL)
|
||||
SET(ARGS_MANPAGE ${ARGS_MANPAGE} -DPARALLEL_IO=TRUE)
|
||||
ENDIF(BUILD_PARALLEL)
|
||||
if (BUILD_PARALLEL)
|
||||
set(ARGS_MANPAGE ${ARGS_MANPAGE} -DPARALLEL_IO=TRUE)
|
||||
endif(BUILD_PARALLEL)
|
||||
|
63
packaging/CMakeLists.txt
Normal file
63
packaging/CMakeLists.txt
Normal file
@ -0,0 +1,63 @@
|
||||
####
|
||||
# Export files
|
||||
####
|
||||
|
||||
# Create CMake package configuration files. With these, other packages using
|
||||
# cmake should be able to find netcdf using find_package and find_library.
|
||||
# The EXPORT call is paired with one in liblib.
|
||||
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF)
|
||||
|
||||
install(EXPORT netCDFTargets
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
COMPONENT headers
|
||||
NAMESPACE netCDF::
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/netCDFConfig.cmake"
|
||||
DESTINATION "${ConfigPackageLocation}"
|
||||
COMPONENT headers
|
||||
)
|
||||
|
||||
target_include_directories(netcdf
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
# 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 headers
|
||||
)
|
||||
|
||||
####
|
||||
# End export files
|
||||
####
|
||||
|
||||
# CPack inclusion must come last.
|
||||
option(NETCDF_PACKAGE "Create netCDF-C package " ${NETCDF_IS_TOP_LEVEL})
|
||||
|
||||
if (NETCDF_PACKAGE)
|
||||
include(CMakeInstallation.cmake)
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user