netcdf-c/liblib/CMakeLists.txt

221 lines
4.7 KiB
CMake
Raw Normal View History

# 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.
# See netcdf-c/COPYRIGHT file for more info.
2012-07-26 06:09:19 +08:00
#####
# Add target objects/modules based on options.
#####
target_sources(netcdf
2024-01-27 03:29:38 +08:00
PRIVATE
$<TARGET_OBJECTS:netcdf3>
$<TARGET_OBJECTS:dispatch>
2024-01-27 03:29:38 +08:00
)
2012-07-26 06:09:19 +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(FOUND_CURL)
target_link_libraries(netcdf PRIVATE CURL::libcurl)
endif()
if(NETCDF_ENABLE_DAP2)
target_sources(netcdf
PRIVATE
$<TARGET_OBJECTS:oc2>
$<TARGET_OBJECTS:dap2>
)
endif()
if(NETCDF_ENABLE_DAP4)
target_sources(netcdf
PRIVATE
$<TARGET_OBJECTS:dap4>
$<TARGET_OBJECTS:ncxml>
)
endif()
if(NETCDF_ENABLE_NCZARR)
target_sources(netcdf
PRIVATE
$<TARGET_OBJECTS:nczarr>
)
endif()
2024-03-19 05:27:23 +08:00
if(NETCDF_ENABLE_S3_INTERNAL)
target_sources(netcdf
PRIVATE
$<TARGET_OBJECTS:ncxml>
)
endif()
if(NETCDF_ENABLE_PLUGINS)
target_sources(netcdf
PRIVATE
$<TARGET_OBJECTS:ncpoco>
)
endif()
target_sources(netcdf
PRIVATE
2024-01-27 03:29:38 +08:00
${CMAKE_CURRENT_SOURCE_DIR}/nc_initialize.c
)
if(STATUS_PARALLEL)
target_link_libraries(netcdf PUBLIC MPI::MPI_C)
endif(STATUS_PARALLEL)
if(MOD_NETCDF_NAME)
set_target_properties(netcdf
PROPERTIES
OUTPUT_NAME ${NETCDF_LIB_NAME}
)
endif()
2012-07-21 05:16:27 +08:00
# 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()
2012-07-26 06:09:19 +08:00
#####
# Add dependencies required for linking.
#####
set(TLL_LIBS "")
set(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ${ZLIB_LIBRARY})
2014-09-30 02:04:35 +08:00
# Add extra dependencies specified via NC_EXTRA_DEPS
set(TLL_LIBS ${TLL_LIBS} ${EXTRA_DEPS})
if(NETCDF_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(NETCDF_ENABLE_NCZARR_ZIP)
set(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
endif()
if(USE_HDF5)
set(TLL_LIBS HDF5::HDF5 hdf5::hdf5_hl ${TLL_LIBS} ${Szip_LIBRARY})
endif()
if(FOUND_CURL)
set(TLL_LIBS ${TLL_LIBS} CURL::libcurl)
endif()
2012-07-21 05:16:27 +08:00
if(USE_HDF4)
set(TLL_LIBS ${HDF4_LIBRARIES} ${TLL_LIBS})
endif()
if(NETCDF_ENABLE_PNETCDF)
SET(TLL_LIBS ${TLL_LIBS} PNETCDF::PNETCDF)
endif()
2024-03-19 05:27:23 +08:00
if(NETCDF_ENABLE_S3)
if(NETCDF_ENABLE_S3_AWS)
2024-02-08 03:37:36 +08:00
target_link_directories(netcdf PUBLIC ${AWSSDK_LIB_DIR})
set(TLL_LIBS ${AWSSDK_LINK_LIBRARIES} ${TLL_LIBS})
2024-03-19 05:27:23 +08:00
elseif(NETCDF_ENABLE_S3_INTERNAL)
if(OPENSSL_FOUND)
set(TLL_LIBS ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} ${TLL_LIBS})
endif(OPENSSL_FOUND)
2024-03-19 05:27:23 +08:00
endif(NETCDF_ENABLE_S3_AWS)
endif(NETCDF_ENABLE_S3)
if(HAVE_LIBXML2)
set(TLL_LIBS ${TLL_LIBS} ${LIBXML2_LIBRARIES})
endif()
if(NOT WIN32)
if(NOT APPLE)
if(CMAKE_DL_LIBS)
2024-02-08 03:37:36 +08:00
target_link_libraries(netcdf PRIVATE ${CMAKE_DL_LIBS})
endif()
endif()
endif()
Add filter support to NCZarr Filter support has three goals: 1. Use the existing HDF5 filter implementations, 2. Allow filter metadata to be stored in the NumCodecs metadata format used by Zarr, 3. Allow filters to be used even when HDF5 is disabled Detailed usage directions are define in docs/filters.md. For now, the existing filter API is left in place. So filters are defined using ''nc_def_var_filter'' using the HDF5 style where the id and parameters are unsigned integers. This is a big change since filters affect many parts of the code. In the following, the terms "compressor" and "filter" and "codec" are generally used synonomously. ### Filter-Related Changes: * In order to support dynamic loading of shared filter libraries, a new library was added in the libncpoco directory; it helps to isolate dynamic loading across multiple platforms. * Provide a json parsing library for use by plugins; this is created by merging libdispatch/ncjson.c with include/ncjson.h. * Add a new _Codecs attribute to allow clients to see what codecs are being used; let ncdump -s print it out. * Provide special headers to help support compilation of HDF5 filters when HDF5 is not enabled: netcdf_filter_hdf5_build.h and netcdf_filter_build.h. * Add a number of new test to test the new nczarr filters. * Let ncgen parse _Codecs attribute, although it is ignored. ### Plugin directory changes: * Add support for the Blosc compressor; this is essential because it is the most common compressor used in Zarr datasets. This also necessitated adding a CMake FindBlosc.cmake file * Add NCZarr support for the big-four filters provided by HDF5: shuffle, fletcher32, deflate (zlib), and szip * Add a Codec defaulter (see docs/filters.md) for the big four filters. * Make plugins work with windows by properly adding __declspec declaration. ### Misc. Non-Filter Changes * Replace most uses of USE_NETCDF4 (deprecated) with USE_HDF5. * Improve support for caching * More fixes for path conversion code * Fix misc. memory leaks * Add new utility -- ncdump/ncpathcvt -- that does more or less the same thing as cygpath. * Add a number of new test to test the non-filter fixes. * Update the parsers * Convert most instances of '#ifdef _MSC_VER' to '#ifdef _WIN32'
2021-09-03 07:04:26 +08:00
if(TLL_LIBS)
list(REMOVE_DUPLICATES TLL_LIBS)
endif()
2024-02-08 03:37:36 +08:00
target_link_libraries(netcdf PRIVATE ${TLL_LIBS})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TLL_LIBS})
if(MSVC)
set_target_properties(netcdf PROPERTIES
2024-03-12 06:02:54 +08:00
LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
)
endif()
2012-09-14 02:27:23 +08:00
if(NETCDF_ENABLE_SHARED_LIBRARY_VERSION)
set_target_properties(netcdf PROPERTIES
VERSION ${netCDF_LIB_VERSION}
SOVERSION ${netCDF_SO_VERSION}
)
endif(NETCDF_ENABLE_SHARED_LIBRARY_VERSION)
2024-02-10 06:27:18 +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}
)
set(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)
set(NC_LIBS ${NC_LIBS} PARENT_SCOPE)
2024-01-27 03:29:38 +08:00
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)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")