mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-05 16:20:10 +08:00
Re: https://github.com/zarr-developers/zarr-python/pull/716 The Zarr version 2 spec has been extended to include the ability to choose the dimension separator in chunk name keys. The legal separators has been extended from {'.'} to {'.' '/'}. So now it is possible to use a key like "0/1/2/0" for chunk names. This PR implements this for NCZarr. The V2 spec now says that this separator can be set on a per-variable basis. For now, I have chosen to allow this be set only globally by adding a key named "ZARR.DIMENSION_SEPARATOR=<char>" in the .daprc/.dodsrc/ncrc file. Currently, the only legal separator characters are '.' (the default) and '/'. On writing, this key will only be written if its value is different than the default. This change caused problems because supporting a separator of '/' is difficult to parse when keys/paths use '/' as the path separator. A test case was added for this. Additionally, make nczarr be enabled default by default. This required some additional changes so that if zip and/or AWS S3 sdk are unavailable, then they are disabled for NCZarr. In addition the following unrelated changes were made. 1. Tested that pure-zarr mode could read an nczarr formatted store. 1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added. 1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl is not found then the other options that depend upon it properly are disabled. 1. I decided that xarray support should be enabled by default for pure zarr. In order to allow disabling, I added a new mode flag "noxarray". 1. Certain test in nczarr_test depend on use of .dodsrc. In order for these to work when testing in parallel, some inter-test dependencies needed to be added. 1. Improved authorization testing to use changes in thredds.ucar.edu
358 lines
12 KiB
CMake
358 lines
12 KiB
CMake
# 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.
|
|
#IF(BUILD_SHARED_LIBS AND WIN32)
|
|
# remove_definitions(-DDLL_EXPORT)
|
|
# remove_definitions(-DDLL_NETCDF)
|
|
#ENDIF()
|
|
|
|
SET(ncdump_FILES ncdump.c vardata.c dumplib.c indent.c nctime0.c utils.c nciter.c)
|
|
SET(nccopy_FILES nccopy.c nciter.c chunkspec.c utils.c dimmap.c list.c)
|
|
SET(ocprint_FILES ocprint.c)
|
|
SET(ncvalidator_FILES ncvalidator.c)
|
|
|
|
IF(USE_X_GETOPT)
|
|
SET(ncdump_FILES ${ncdump_FILES} XGetopt.c)
|
|
SET(nccopy_FILES ${nccopy_FILES} XGetopt.c)
|
|
SET(ocprint_FILES ${ocprint_FILES} XGetopt.c)
|
|
SET(ncvalidator_FILES ${ncvalidator_FILES} XGetopt.c)
|
|
ENDIF()
|
|
|
|
ADD_EXECUTABLE(ncdump ${ncdump_FILES})
|
|
ADD_EXECUTABLE(nccopy ${nccopy_FILES})
|
|
ADD_EXECUTABLE(ncvalidator ${ncvalidator_FILES})
|
|
|
|
IF(USE_HDF5)
|
|
ADD_EXECUTABLE(nc4print nc4print.c nc4printer.c)
|
|
ENDIF(USE_HDF5)
|
|
|
|
IF(ENABLE_DAP)
|
|
ADD_EXECUTABLE(ocprint ${ocprint_FILES})
|
|
ENDIF(ENABLE_DAP)
|
|
|
|
TARGET_LINK_LIBRARIES(ncdump netcdf ${ALL_TLL_LIBS})
|
|
TARGET_LINK_LIBRARIES(nccopy netcdf ${ALL_TLL_LIBS})
|
|
TARGET_LINK_LIBRARIES(ncvalidator netcdf ${ALL_TLL_LIBS})
|
|
|
|
IF(USE_HDF5)
|
|
TARGET_LINK_LIBRARIES(nc4print netcdf ${ALL_TLL_LIBS})
|
|
ENDIF(USE_HDF5)
|
|
|
|
IF(ENABLE_DAP)
|
|
TARGET_LINK_LIBRARIES(ocprint netcdf ${ALL_TLL_LIBS})
|
|
ENDIF(ENABLE_DAP)
|
|
|
|
####
|
|
# We have to do a little tweaking
|
|
# to remove the Release/ and Debug/ directories
|
|
# in MSVC builds. This is required to get
|
|
# test scripts to work.
|
|
####
|
|
IF(MSVC)
|
|
SET_TARGET_PROPERTIES(ncdump PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ncdump PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ncdump PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET_TARGET_PROPERTIES(nccopy PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(nccopy PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(nccopy PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET_TARGET_PROPERTIES(ncvalidator PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ncvalidator PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ncvalidator PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
IF(USE_HDF5)
|
|
|
|
SET_TARGET_PROPERTIES(ncvalidator PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ncvalidator PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ncvalidator PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
ENDIF(USE_HDF5)
|
|
|
|
IF(ENABLE_DAP)
|
|
SET_TARGET_PROPERTIES(ocprint PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ocprint PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(ocprint PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
ENDIF(ENABLE_DAP)
|
|
|
|
ENDIF()
|
|
|
|
IF(ENABLE_TESTS)
|
|
ADD_EXECUTABLE(rewrite-scalar rewrite-scalar.c)
|
|
ADD_EXECUTABLE(bom bom.c)
|
|
ADD_EXECUTABLE(tst_dimsizes tst_dimsizes.c)
|
|
ADD_EXECUTABLE(nctrunc nctrunc.c)
|
|
ADD_EXECUTABLE(tst_rcmerge tst_rcmerge.c)
|
|
TARGET_LINK_LIBRARIES(rewrite-scalar netcdf)
|
|
TARGET_LINK_LIBRARIES(bom netcdf)
|
|
TARGET_LINK_LIBRARIES(tst_dimsizes netcdf)
|
|
TARGET_LINK_LIBRARIES(nctrunc netcdf)
|
|
TARGET_LINK_LIBRARIES(tst_rcmerge netcdf)
|
|
|
|
IF(USE_HDF5)
|
|
ADD_EXECUTABLE(tst_fileinfo tst_fileinfo.c)
|
|
TARGET_LINK_LIBRARIES(tst_fileinfo netcdf)
|
|
ENDIF()
|
|
|
|
IF(MSVC)
|
|
SET_TARGET_PROPERTIES(rewrite-scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(rewrite-scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(rewrite-scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET_TARGET_PROPERTIES(bom PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(bom PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(bom PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET_TARGET_PROPERTIES(tst_dimsizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(tst_dimsizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(tst_dimsizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET_TARGET_PROPERTIES(nctrunc PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(nctrunc PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(nctrunc PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SET_TARGET_PROPERTIES(tst_rcmerge PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(tst_rcmerge PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(tst_rcmerge PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
IF(USE_HDF5)
|
|
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
SET_TARGET_PROPERTIES(tst_fileinfo PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
ENDIF(USE_HDF5)
|
|
ENDIF(MSVC)
|
|
|
|
# Base tests
|
|
# The tests are set up as a combination of shell scripts and executables that
|
|
# must be run in a particular order. It is painful but will use macros to help
|
|
# keep it from being too bad.
|
|
|
|
## Start adding tests in the appropriate order
|
|
add_sh_test(ncdump run_tests)
|
|
add_sh_test(ncdump tst_64bit)
|
|
add_bin_test_no_prefix(ref_ctest)
|
|
add_bin_test_no_prefix(ref_ctest64)
|
|
add_sh_test(ncdump tst_output)
|
|
add_sh_test(ncdump tst_lengths)
|
|
add_sh_test(ncdump tst_calendars)
|
|
build_bin_test_no_prefix(tst_utf8)
|
|
add_sh_test(ncdump run_utf8_tests)
|
|
IF(USE_HDF5)
|
|
add_sh_test(ncdump run_utf8_nc4_tests)
|
|
add_sh_test(ncdump tst_fileinfo)
|
|
add_sh_test(ncdump tst_hdf5_offset)
|
|
ENDIF(USE_HDF5)
|
|
|
|
add_sh_test(ncdump tst_null_byte_padding)
|
|
IF(USE_STRICT_NULL_BYTE_HEADER_PADDING)
|
|
SET_TESTS_PROPERTIES(ncdump_tst_null_byte_padding PROPERTIES WILL_FAIL TRUE)
|
|
ENDIF(USE_STRICT_NULL_BYTE_HEADER_PADDING)
|
|
|
|
add_sh_test(ncdump tst_nccopy3)
|
|
IF(HAVE_BASH)
|
|
SET_TESTS_PROPERTIES(ncdump_tst_nccopy3 PROPERTIES RUN_SERIAL TRUE)
|
|
ENDIF(HAVE_BASH)
|
|
|
|
add_sh_test(ncdump tst_nccopy3_subset)
|
|
add_sh_test(ncdump tst_charfill)
|
|
|
|
add_sh_test(ncdump tst_formatx3)
|
|
add_sh_test(ncdump tst_bom)
|
|
add_sh_test(ncdump tst_dimsizes)
|
|
|
|
# The following test script invokes
|
|
# gcc directly.
|
|
IF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
|
IF(ENABLE_LARGE_FILE_TESTS)
|
|
add_sh_test(ncdump tst_iter)
|
|
ENDIF(ENABLE_LARGE_FILE_TESTS)
|
|
ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
|
|
|
add_sh_test(ncdump tst_inmemory_nc3)
|
|
add_sh_test(ncdump tst_nccopy_w3)
|
|
IF(USE_HDF5)
|
|
add_sh_test(ncdump tst_inmemory_nc4)
|
|
add_sh_test(ncdump tst_nccopy_w4)
|
|
ENDIF(USE_HDF5)
|
|
|
|
IF(USE_HDF5)
|
|
build_bin_test_no_prefix(tst_create_files)
|
|
build_bin_test_no_prefix(tst_group_data)
|
|
build_bin_test_no_prefix(tst_enum_data)
|
|
build_bin_test_no_prefix(tst_opaque_data)
|
|
build_bin_test_no_prefix(tst_string_data)
|
|
build_bin_test_no_prefix(tst_vlen_data)
|
|
build_bin_test_no_prefix(tst_comp)
|
|
build_bin_test_no_prefix(tst_comp2)
|
|
build_bin_test_no_prefix(tst_nans)
|
|
build_bin_test_no_prefix(tst_h_scalar)
|
|
add_sh_test(ncdump tst_formatx4)
|
|
# Add this test by hand, as it is also called from a script.
|
|
# Editing the script would break autotools compatibility.
|
|
build_bin_test_no_prefix(tst_special_atts)
|
|
build_bin_test_no_prefix(tst_compress)
|
|
build_bin_test_no_prefix(tst_chunking)
|
|
|
|
###
|
|
# This test fails on Visual Studio builds with bash.
|
|
# It passes, but technically fails because the scientific
|
|
# formatting omits a 0.
|
|
###
|
|
IF(EXTRA_TESTS)
|
|
add_sh_test(ncdump run_back_comp_tests)
|
|
IF(MSVC)
|
|
SET_TESTS_PROPERTIES(ncdump_run_back_comp_tests PROPERTIES WILL_FAIL TRUE)
|
|
ENDIF(MSVC)
|
|
ENDIF(EXTRA_TESTS)
|
|
|
|
# Known failure on MSVC; the number of 0's padding
|
|
# is different, but the result is actually correct.
|
|
IF(HAVE_BASH)
|
|
add_sh_test(ncdump tst_netcdf4)
|
|
build_bin_test_no_prefix(tst_h_rdc0)
|
|
ENDIF()
|
|
|
|
build_bin_test_no_prefix(tst_fillbug)
|
|
add_sh_test(ncdump_sh tst_fillbug)
|
|
|
|
add_sh_test(ncdump tst_netcdf4_4)
|
|
IF(MSVC AND HAVE_BASH)
|
|
SET_TESTS_PROPERTIES(ncdump_tst_netcdf4_4 PROPERTIES WILL_FAIL TRUE)
|
|
ENDIF(MSVC AND HAVE_BASH)
|
|
|
|
###
|
|
# Some test reordering was required to ensure these tests
|
|
# only ran after ncdump was built.
|
|
###
|
|
add_sh_test(ncdump run_ncgen_tests)
|
|
IF(USE_HDF5)
|
|
add_sh_test(ncdump run_ncgen_nc4_tests)
|
|
ENDIF(USE_HDF5)
|
|
|
|
add_sh_test(ncdump tst_grp_spec)
|
|
add_sh_test(ncdump tst_mud)
|
|
add_sh_test(ncdump_shell tst_h_scalar)
|
|
|
|
add_sh_test(ncdump tst_nccopy4)
|
|
IF(HAVE_BASH)
|
|
SET_TESTS_PROPERTIES(ncdump_tst_nccopy4 PROPERTIES RUN_SERIAL TRUE)
|
|
ENDIF(HAVE_BASH)
|
|
|
|
add_sh_test(ncdump tst_nccopy5)
|
|
IF(HAVE_BASH)
|
|
SET_TESTS_PROPERTIES(ncdump_tst_nccopy5 PROPERTIES RUN_SERIAL TRUE)
|
|
ENDIF(HAVE_BASH)
|
|
|
|
IF(USE_HDF5)
|
|
add_sh_test(ncdump tst_ncgen4)
|
|
ENDIF(USE_HDF5)
|
|
|
|
ENDIF(USE_HDF5)
|
|
|
|
add_sh_test(ncdump tst_inttags)
|
|
IF(USE_HDF5)
|
|
add_sh_test(ncdump tst_inttags4)
|
|
ENDIF(USE_HDF5)
|
|
|
|
add_sh_test(ncdump test_radix)
|
|
|
|
add_sh_test(ncdump tst_ctests)
|
|
|
|
IF(ENABLE_UNFIXED_MEMORY_LEAKS)
|
|
SET_TESTS_PROPERTIES(ncdump_run_ncgen_nc4_tests.sh ncdump_tst_nccopy4.sh ncdump_tst_ncgen_shared.sh ncdump_tst_netcdf4.sh
|
|
PROPERTIES ENVIRONMENT NC_VLEN_NOTEST=1)
|
|
ENDIF()
|
|
|
|
# The unicode tests are complicated
|
|
IF(USE_HDF5)
|
|
IF(HAVE_BASH)
|
|
build_bin_test_no_prefix(tst_unicode)
|
|
IF(NOT MSVC)
|
|
# These tests do not work under windows
|
|
add_sh_test(ncdump test_unicode_directory)
|
|
add_sh_test(ncdump test_unicode_path)
|
|
ENDIF(NOT MSVC)
|
|
ENDIF(HAVE_BASH)
|
|
ENDIF(USE_HDF5)
|
|
|
|
IF(USE_CDF5)
|
|
add_sh_test(ncdump test_keywords)
|
|
ENDIF()
|
|
|
|
add_sh_test(ncdump test_rcmerge)
|
|
|
|
ENDIF(ENABLE_TESTS)
|
|
|
|
#IF(MSVC)
|
|
# SET_TARGET_PROPERTIES(ncdump
|
|
# PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
# )
|
|
# SET_TARGET_PROPERTIES(nccopy
|
|
# PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
# )
|
|
# SET_TARGET_PROPERTIES(ncvalidator
|
|
# PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
# )
|
|
# IF(ENABLE_DAP)
|
|
# SET_TARGET_PROPERTIES(ocprint
|
|
# PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
# )
|
|
# ENDIF(ENABLE_DAP)
|
|
#ENDIF()
|
|
|
|
INSTALL(TARGETS ncdump RUNTIME DESTINATION bin COMPONENT utilities)
|
|
INSTALL(TARGETS nccopy RUNTIME DESTINATION bin COMPONENT utilities)
|
|
|
|
SET(MAN_FILES nccopy.1 ncdump.1)
|
|
|
|
# Note, the L512.bin file is file containing exactly 512 bytes each of value 0.
|
|
# It is used for creating hdf5 files with varying offsets for testing.
|
|
|
|
FILE(GLOB COPY_FILES ${CMAKE_BINARY_DIR}/ncgen/*.nc ${CMAKE_BINARY_DIR}/nc_test4/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.ncml ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.1 ${CMAKE_CURRENT_SOURCE_DIR}/L512.bin ${CMAKE_CURRENT_SOURCE_DIR}/ref_ctest*.c)
|
|
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE)
|
|
|
|
ADD_SUBDIRECTORY(cdl)
|
|
ADD_SUBDIRECTORY(expected)
|
|
|
|
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}")
|
|
|
|
IF(NOT MSVC)
|
|
INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1" COMPONENT documentation)
|
|
ENDIF()
|