2018-12-07 05:34:40 +08:00
|
|
|
# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
|
|
|
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
|
|
|
|
# 2015, 2016, 2017, 2018
|
|
|
|
# University Corporation for Atmospheric Research/Unidata.
|
2014-12-06 02:19:02 +08:00
|
|
|
|
2018-12-07 05:34:40 +08:00
|
|
|
# See netcdf-c/COPYRIGHT file for more info.
|
2012-07-18 05:44:41 +08:00
|
|
|
|
2012-07-26 06:09:19 +08:00
|
|
|
#####
|
|
|
|
# Add target objects/modules based on options.
|
|
|
|
#####
|
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(USE_NETCDF4)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:netcdf4>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_HDF5)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:netcdfhdf5>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_PNETCDF)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:netcdfp>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_HDF4)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:netcdfhdf4>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_DAP2)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:oc2>
|
|
|
|
$<TARGET_OBJECTS:dap2>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_DAP4)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:dap4>
|
|
|
|
$<TARGET_OBJECTS:ncxml>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_NCZARR)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:nczarr>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_S3_INTERNAL)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:ncxml>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_PLUGINS)
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
$<TARGET_OBJECTS:ncpoco>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_sources(netcdf
|
|
|
|
PRIVATE
|
|
|
|
nc_initialize.c
|
|
|
|
)
|
|
|
|
|
|
|
|
if(STATUS_PARALLEL)
|
2023-09-29 22:42:19 +08:00
|
|
|
# TODO: Make PUBLIC when other dependencies have PUBLIC/PRIVATE specified
|
|
|
|
target_link_libraries(netcdf MPI::MPI_C)
|
2024-01-19 23:25:24 +08:00
|
|
|
endif(STATUS_PARALLEL)
|
2021-01-20 01:33:08 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(TARGET MPI::MPI_C)
|
2023-01-26 05:41:27 +08:00
|
|
|
target_link_libraries(netcdf MPI::MPI_C)
|
2024-01-19 23:25:24 +08:00
|
|
|
endif(TARGET MPI::MPI_C)
|
2023-01-25 04:16:55 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
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()
|
2012-07-21 05:16:27 +08:00
|
|
|
|
2018-01-18 04:24:14 +08:00
|
|
|
# Make sure that netcdf.dll path does not include the build configuration
|
2024-01-19 23:25:24 +08:00
|
|
|
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()
|
2018-01-17 04:28:30 +08:00
|
|
|
|
2012-07-26 06:09:19 +08:00
|
|
|
#####
|
|
|
|
# Add dependencies required for linking.
|
|
|
|
#####
|
2013-02-13 06:22:54 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
set(TLL_LIBS "")
|
2013-02-13 06:22:54 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
set(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ${ZLIB_LIBRARY})
|
2013-02-13 06:22:54 +08:00
|
|
|
|
2014-09-30 02:04:35 +08:00
|
|
|
# Add extra dependencies specified via NC_EXTRA_DEPS
|
2024-01-19 23:25:24 +08:00
|
|
|
set(TLL_LIBS ${TLL_LIBS} ${EXTRA_DEPS})
|
|
|
|
|
|
|
|
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(HAVE_LIBDL)
|
|
|
|
set(TLL_LIBS ${LIBDL} ${TLL_LIBS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_NCZARR_ZIP)
|
|
|
|
set(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_HDF5)
|
|
|
|
if(NOT MSVC)
|
2013-10-08 02:39:54 +08:00
|
|
|
# Some version of cmake define HDF5_hdf5_LIBRARY instead of
|
2014-08-23 23:12:55 +08:00
|
|
|
# HDF5_LIBRARY. Same with HDF5_HL_LIBRARIES
|
2024-01-19 23:25:24 +08:00
|
|
|
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()
|
2014-08-21 18:03:41 +08:00
|
|
|
# The order of the libraries is important here for static
|
|
|
|
# builds:
|
|
|
|
# Make sure that HDF5_C_LIBRARY appears *after*
|
|
|
|
# HDF5_HL_LIBRARY.
|
2024-01-19 23:25:24 +08:00
|
|
|
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()
|
2012-08-07 01:27:08 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(FOUND_CURL)
|
|
|
|
set(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES})
|
|
|
|
endif()
|
2012-07-21 05:16:27 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(USE_HDF4)
|
|
|
|
set(TLL_LIBS ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB} ${TLL_LIBS})
|
|
|
|
endif()
|
2013-01-16 06:43:09 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(ENABLE_PNETCDF AND PNETCDF)
|
|
|
|
set(TLL_LIBS ${TLL_LIBS} ${PNETCDF})
|
|
|
|
endif()
|
2014-11-04 01:43:43 +08:00
|
|
|
|
2023-08-30 01:15:15 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(ENABLE_S3)
|
|
|
|
if(ENABLE_S3_AWS)
|
2023-08-30 01:15:15 +08:00
|
|
|
TARGET_LINK_DIRECTORIES(netcdf PUBLIC ${AWSSDK_LIB_DIR})
|
2024-01-19 23:25:24 +08:00
|
|
|
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(NOT WIN32)
|
|
|
|
if(NOT APPLE)
|
|
|
|
if(CMAKE_DL_LIBS)
|
2021-09-03 07:04:26 +08:00
|
|
|
TARGET_LINK_LIBRARIES(netcdf ${CMAKE_DL_LIBS})
|
2024-01-19 23:25:24 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-09-03 07:04:26 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(TLL_LIBS)
|
|
|
|
list(REMOVE_DUPLICATES TLL_LIBS)
|
|
|
|
endif()
|
2014-11-04 01:43:43 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
target_link_libraries(netcdf ${TLL_LIBS})
|
2020-08-18 09:15:47 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TLL_LIBS})
|
|
|
|
if(MSVC)
|
|
|
|
set_target_properties(netcdf PROPERTIES
|
2014-04-03 04:26:42 +08:00
|
|
|
LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
|
|
)
|
2024-01-19 23:25:24 +08:00
|
|
|
endif()
|
2012-09-14 02:27:23 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(NOT MSVC)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(netcdf PROPERTIES LINK_FLAGS -shared)
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-10-03 06:56:12 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
if(ENABLE_SHARED_LIBRARY_VERSION)
|
|
|
|
set_target_properties(netcdf PROPERTIES
|
2016-03-08 05:04:52 +08:00
|
|
|
VERSION ${netCDF_LIB_VERSION}
|
|
|
|
SOVERSION ${netCDF_SO_VERSION}
|
|
|
|
)
|
2024-01-19 23:25:24 +08:00
|
|
|
endif(ENABLE_SHARED_LIBRARY_VERSION)
|
2012-11-20 05:43:12 +08:00
|
|
|
|
2015-10-21 00:10:55 +08:00
|
|
|
###
|
|
|
|
# The INCLUDES directive was introduced in 2.8.12.
|
|
|
|
# However, 2.8.11 is still the default on some
|
|
|
|
# popular linux distributions. See
|
|
|
|
# https://github.com/Unidata/netcdf-c/issues/135
|
|
|
|
# for more information.
|
|
|
|
###
|
2024-01-19 23:25:24 +08:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 2.8.12)
|
2015-10-21 00:10:55 +08:00
|
|
|
INSTALL(
|
|
|
|
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
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
)
|
2024-01-19 23:25:24 +08:00
|
|
|
else()
|
2015-10-21 00:10:55 +08:00
|
|
|
INSTALL(
|
|
|
|
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}
|
|
|
|
)
|
2024-01-19 23:25:24 +08:00
|
|
|
endif()
|
2012-11-20 05:43:12 +08:00
|
|
|
|
2024-01-19 23:25:24 +08:00
|
|
|
set(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)
|
|
|
|
set(NC_LIBS ${NC_LIBS} PARENT_SCOPE)
|
2013-06-04 00:42:04 +08:00
|
|
|
|
|
|
|
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
2024-01-19 23:25:24 +08:00
|
|
|
set(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
|
2013-08-14 00:00:22 +08:00
|
|
|
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
|