diff --git a/CMakeLists.txt b/CMakeLists.txt index da6c85ddd..7a04b0a44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,15 @@ + #Minimum required CMake Version cmake_minimum_required(VERSION 2.8.8) #Project Name project(NetCDF C) -SET(NetCDF_VERSION 4.2.1) +SET(NetCDF_VERSION_MAJOR 4) +SET(NetCDF_VERSION_MINOR 2) +SET(NetCDF_VERSION_PATCH 1) +SET(NetCDF_VERSION ${NetCDF_VERSION_MAJOR}.${NetCDF_VERSION_MINOR}.${NetCDF_VERSION_PATCH}) +SET(VERSION ${NetCDF_VERSION}) + ENABLE_TESTING() INCLUDE(CTest) @@ -12,8 +18,9 @@ IF(MSVC) ENDIF() # CTest configuration -SET (CTEST_MEMORYCHECK_COMMAND valgrind CACHE STRING "") - +IF(NOT MSVC) + SET (CTEST_MEMORYCHECK_COMMAND valgrind CACHE STRING "") +ENDIF() # Default to shared libs on OPTION(BUILD_SHARED_LIBS "Configure NetCDF as a shared library." ON) @@ -83,7 +90,7 @@ MACRO(add_bin_env_test prefix F) ENDIF() - ADD_TEST(${prefix}_${F} sh "-c" "export TOPSRCDIR=${CMAKE_SOURCE_DIR};" ${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F}) + ADD_TEST(${prefix}_${F} bash "-c" "export srcdir=/machine/wfisher/netcdf-cmake/ncgen;" "export TOPSRCDIR=/machine/wfisher/netcdf-cmake;" "/machine/wfisher/netcdf-cmake/build/ncgen/run_tests.sh" "-c" "export TOPSRCDIR=${CMAKE_SOURCE_DIR};" ${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F}) IF(MSVC) SET_PROPERTY(TARGET ${prefix}_${F} PROPERTY FOLDER "tests") ENDIF() @@ -122,7 +129,7 @@ ENDMACRO() # Shell script Macro MACRO(add_sh_test prefix F) IF(NOT MSVC) - ADD_TEST(${prefix}_${F} sh "-c" "export srcdir=${CMAKE_CURRENT_SOURCE_DIR};" "export TOPSRCDIR=${CMAKE_SOURCE_DIR};" "${CMAKE_CURRENT_BINARY_DIR}/${F}.sh") + ADD_TEST(${prefix}_${F} bash "-c" "export srcdir=${CMAKE_CURRENT_SOURCE_DIR};" "export TOPSRCDIR=${CMAKE_SOURCE_DIR};" "${CMAKE_CURRENT_BINARY_DIR}/${F}.sh") ENDIF() ENDMACRO() @@ -145,6 +152,10 @@ IF(NOT NETCDF_LIB_NAME STREQUAL "") SET(MOD_NETCDF_NAME ON) ENDIF() +# Option to use a local or remote CDash instance. +# instances Defined in CTestConfig.cmake +OPTION (USE_REMOTE_CDASH "Use CDash instance at CDash.org." OFF) + # Set the appropriate compiler/architecture for universal OSX binaries. IF(${CMAKE_SYSTEM_NAME} EQUAL "Darwin") SET(CMAKE_OSX_ARCHITECTURES i386;x86_64) @@ -206,7 +217,6 @@ SET (NCIO_MINBLOCKSIZE 256 CACHE STRING "Minimum I/O Blocksize for netCDF classi # Build NetCDF4 OPTION (ENABLE_NETCDF_4 "Enable NetCDF-4" ON) -SET(USE_NETCDF4 OFF CACHE BOOL "") IF(ENABLE_NETCDF_4) SET(USE_NETCDF4 ON CACHE BOOL "") SET(ENABLE_NETCDF_4 ON CACHE BOOL "") @@ -246,7 +256,7 @@ IF (USE_HDF5 OR ENABLE_NETCDF_4) #Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip. IF(USE_SZIP) #FIND_PACKAGE(SZIP) - FIND_LIBRARY(SZIP_LIBRARY NAMES szip sz) + FIND_LIBRARY(SZIP_LIBRARY NAMES szip sz libszip) IF(NOT SZIP_LIBRARY) MESSAGE(FATAL_ERROR "HDF5 compiled with szip, but cannot find local szip libraries.") ELSE() @@ -285,7 +295,7 @@ OPTION(ENABLE_DAP_LONG_TESTS "Enable DAP long tests." OFF) OPTION(ENABLE_DAP_REMOTE_TESTS "Enable DAP remote tests." ON) # If NetCDF4 and DAP, Option for DAP groups. -IF(ENABLE_NETCDF4 AND USE_DAP) +IF(ENABLE_NETCDF_4 AND USE_DAP) OPTION(ENABLE_DAP_GROUPS "Whether netcdf4 group names should be enabled." ON) ELSE() SET(ENABLE_DAP_GROUPS OFF CACHE BOOL "Whether netcdf4 group names should be enabled.") @@ -371,7 +381,7 @@ ENDIF() # Set some of the options as advanced. MARK_AS_ADVANCED(ENABLE_INTERNAL_DOCS VALGRIND_TESTS ENABLE_PNETCDF BUILD_CDMREMOTE ENABLE_COVERAGE_TESTS) -MARK_AS_ADVANCED(ENABLE_DAP_REMOTE_TESTS ENABLE_DAP_LONG_TESTS) +MARK_AS_ADVANCED(ENABLE_DAP_REMOTE_TESTS ENABLE_DAP_LONG_TESTS USE_REMOTE_CDASH) ##### # End option checks. ##### @@ -464,7 +474,7 @@ IF(NOT WIN32) ENDIF() ENDIF() - +MESSAGE(netcdf_libraries: ${netcdf_library}) # Create config.h file configure_file("${NetCDF_SOURCE_DIR}/cmake_config.h.in" "${NetCDF_BINARY_DIR}/config.h") @@ -475,7 +485,7 @@ FILE(COPY "${NetCDF_SOURCE_DIR}/nc-config" FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) EXECUTE_PROCESS(COMMAND "chmod 755 ${NetCDF_BINARY_DIR}/nc-config") -INSTALL(PROGRAMS ${NetCDF_BINARY_DIR}/nc-config DESTINATION bin) +INSTALL(PROGRAMS ${NetCDF_BINARY_DIR}/nc-config DESTINATION bin COMPONENT utilities) INCLUDE_DIRECTORIES(${NetCDF_BINARY_DIR}) # End autotools-style checs for config.h @@ -563,10 +573,17 @@ ENDIF() # Moving on to CPack, install packages. ##### INSTALL(FILES ${NetCDF_SOURCE_DIR}/include/netcdf.h - DESTINATION include) + DESTINATION include COMPONENT headers) + +# Install the dependencies. +IF(MSVC) + INSTALL(DIRECTORY ${CMAKE_PREFIX_PATH} DESTINATION "deps" COMPONENT dependencies) + +ENDIF() + IF(ENABLE_DOXYGEN) - INSTALL(DIRECTORY man4 DESTINATION ".") + INSTALL(DIRECTORY man4 DESTINATION "." COMPONENT documentation) ENDIF() # Subdirectory CMakeLists.txt files should specify their own @@ -580,6 +597,26 @@ CONFIGURE_FILE( ) #INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) +# Create CMake package configuration files. With these, other packages using +# cmake should be able to find netcdf using find_package and find_library. +# This call is paired with one in liblib. +install (EXPORT netcdf-targets + DESTINATION share/cmake + COMPONENT documentation) + +configure_file ( + ${NetCDF_SOURCE_DIR}/netcdf-config.cmake.in + ${NetCDF_BINARY_DIR}/netcdf-config.cmake @ONLY) + +configure_file ( + ${NetCDF_SOURCE_DIR}/netcdf-config-version.cmake.in + ${NetCDF_BINARY_DIR}/netcdf-config-version.cmake @ONLY) + +install (FILES ${NetCDF_BINARY_DIR}/netcdf-config.cmake + ${NetCDF_BINARY_DIR}/netcdf-config-version.cmake + DESTINATION share/cmake) + +# End CMake package configuration files. ##### # Various options for CPACK ##### @@ -620,8 +657,24 @@ ADD_CUSTOM_TARGET(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +## Customize some of the package component descriptions +set (CPACK_COMPONENT_UTILITIES_DISPLAY_NAME "netCDF Utilities") +set (CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "netCDF Libraries") +set (CPACK_COMPONENT_HEADERS_DISPLAY_NAME "netCDF Headers") +set (CPACK_COMPONENT_DEPENDENCIES_DISPLAY_NAME "netCDF Dependencies") +set (CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "netCDF Documentation") +set (CPACK_COMPONENT_UTILITIES_DESCRIPTION + "The netCDF Utilities") +set (CPACK_COMPONENT_LIBRARIES_DESCRIPTION + "The netCDF Libraries") +set (CPACK_COMPONENT_HEADERS_DESCRIPTION + "C header files for use with netCDF") +set (CPACK_COMPONENT_DEPENDENCIES_DESCRIPTION + "Dependencies for this build of netCDF") +set (CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION + "The netCDF user documentation.") print_conf_summary() #MESSAGE(STATUS "CPACK_SOURCE_IGNORE_FILES: ${CPACK_SOURCE_IGNORE_FILES}") # CPack inclusion must come last. diff --git a/libdap2/daputil.c b/libdap2/daputil.c index 5c685ca13..3a4f316e2 100644 --- a/libdap2/daputil.c +++ b/libdap2/daputil.c @@ -781,7 +781,7 @@ dap_repairname(char* name) newchar[0] = '%'; digit = (c & 0xf0) >> 4; newchar[1] = hexdigits[digit]; - digit = (c & 0x0f) + digit = (c & 0x0f); newchar[2] = hexdigits[digit]; newchar[3] = '\0'; strcat(newname,newchar); diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt index 3de7a1aea..0f5a170ae 100644 --- a/liblib/CMakeLists.txt +++ b/liblib/CMakeLists.txt @@ -62,7 +62,13 @@ IF(NOT MSVC) ENDIF() ENDIF() -INSTALL(TARGETS netcdf DESTINATION lib)# EXPORT netcdf-targets) -#INSTALL(EXPORT netcdf-targets DESTINATION ".") -#include(CPack) +SET_TARGET_PROPERTIES(netcdf PROPERTIES + VERSION ${NetCDF_VERSION} + SOVERSION ${NetCDF_VERSION_MAJOR}) + +INSTALL(TARGETS netcdf EXPORT netcdf-targets RUNTIME DESTINATION bin COMPONENT libraries + LIBRARY DESTINATION lib COMPONENT libraries + ARCHIVE DESTINATION lib COMPONENT libraries + ) + SET(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE) diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index bd2ebfe52..7ce2f24c1 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -33,8 +33,9 @@ add_library(netcdf3 OBJECT ${libsrc_SOURCES}) set(man_MANS netcdf.3) SET(MAN_FILES netcdf.3) -INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man3") - +IF(EXISTS ${MAN_FILES}) + INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man3" COMPONENT documentation) +ENDIF() set(ARGS_MANPAGE -DAPI=C) diff --git a/libsrc/nc3dispatch.c b/libsrc/nc3dispatch.c index 390826e2e..8b2f1b940 100644 --- a/libsrc/nc3dispatch.c +++ b/libsrc/nc3dispatch.c @@ -222,14 +222,14 @@ NC3_def_grp(int parent_ncid, const char *name, int *new_ncid) static int NC3_inq_ncid(int ncid, const char *name, int *grp_ncid) { - if(grp_ncid) *grp_ncid = ncid; + if(grp_ncid) *grp_ncid = ncid; return NC_NOERR; } static int NC3_inq_grps(int ncid, int *numgrps, int *ncids) { - if (numgrps) + if (numgrps) *numgrps = 0; return NC_NOERR; } diff --git a/libsrc4/nc4attr.c b/libsrc4/nc4attr.c index 54b433058..929b59cef 100644 --- a/libsrc4/nc4attr.c +++ b/libsrc4/nc4attr.c @@ -35,9 +35,10 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name, NC_HDF5_FILE_INFO_T *h5; NC_ATT_INFO_T *att; int my_attnum = -1; + int need_to_convert = 0; int range_error = NC_NOERR; - void *bufr = NULL; + void *bufr = NULL; size_t type_size; char norm_name[NC_MAX_NAME + 1]; int i; diff --git a/ncdump/CMakeLists.txt b/ncdump/CMakeLists.txt index ce1e7b100..a3c26c5dd 100644 --- a/ncdump/CMakeLists.txt +++ b/ncdump/CMakeLists.txt @@ -129,10 +129,10 @@ IF(MSVC) ENDIF() -INSTALL(TARGETS ncdump DESTINATION bin) -INSTALL(TARGETS nccopy DESTINATION bin) +INSTALL(TARGETS ncdump DESTINATION bin COMPONENT utilities) +INSTALL(TARGETS nccopy DESTINATION bin COMPONENT utilities) SET(MAN_FILES nccopy.1 ncdump.1) -INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1") +INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1" COMPONENT documentation) SET(CLEANFILES test0.nc test1.cdl test1.nc test2.cdl ctest1.cdl ctest.c ctest64.c ctest0.nc ctest0_64.nc c1.cdl ctest1_64.cdl c0.nc small.nc small2.nc c0tmp.nc c1.ncml utf8.cdl utf8_64.cdl utf8.nc utf8_64.nc tmp.cdl tst_vlen_data.nc tst_utf8.nc tst_special_atts.nc tst_unicode.nc tst_solar_2.nc tst_string_data.nc tst_calendars.nc tst_nans.nc tst_opaque_data.nc tst_solar_cmp.nc tst_enum_data.nc tst_solar_1.nc tst_mslp_64.nc tst_mslp.nc tst_comp2.nc tst_ncml.nc tst_fillbug.nc tst_group_data.nc tst_small.nc tst_comp.nc tst_unicode.cdl tst_group_data.cdl tst_compounds2.cdl tst_comp.cdl tst_enum_data.cdl tst_small.cdl tst_times.cdl tst_solar_2.cdl tst_string_data.cdl tst_fillbug.cdl tst_opaque_data.cdl tst_compounds4.cdl tst_utf8.cdl tst_compounds3.cdl tst_special_atts.cdl tst_nans.cdl tst_format_att_64.cdl tst_vlen_data.cdl tst_solar_1.cdl tst_format_att.cdl tst_inflated.nc tmp_subset.cdl tst_inflated4.nc tst_deflated.nc tst_chunking.nc tmp*.nc tst_charfill.nc tmp_tst_charfill.cdl iter.* tst_nc_test_netcdf4_4_0.cdl) diff --git a/ncgen/CMakeLists.txt b/ncgen/CMakeLists.txt index 99be51a35..540f0b22b 100644 --- a/ncgen/CMakeLists.txt +++ b/ncgen/CMakeLists.txt @@ -11,7 +11,7 @@ ENDIF() ADD_EXECUTABLE(ncgen ${ncgen_FILES}) TARGET_LINK_LIBRARIES(ncgen netcdf ${ALL_TLL_LIBS}) -INSTALL(TARGETS ncgen DESTINATION bin) +INSTALL(TARGETS ncgen DESTINATION bin COMPONENT utilities) # Stuff to build if tests are enabled. IF(ENABLE_TESTS) @@ -26,7 +26,8 @@ IF(ENABLE_TESTS) ENDIF() SET(MAN_FILES ncgen.1) -INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1") +INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1" + COMPONENT documentation) SET(CLEANFILES c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") diff --git a/ncgen/util.c b/ncgen/util.c index a1a708f83..3b2c66d2d 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -517,12 +517,14 @@ dlappend(Datalist* dl, Constant* constant) Constant builddatasublist(Datalist* dl) { + Constant d; d.nctype = NC_COMPOUND; d.lineno = (dl->length > 0?dl->data[0].lineno:0); d.value.compoundv = dl; d.filled = NULL; return d; + } static void diff --git a/ncgen3/CMakeLists.txt b/ncgen3/CMakeLists.txt index 790a6b3c8..ba8c8bf7e 100644 --- a/ncgen3/CMakeLists.txt +++ b/ncgen3/CMakeLists.txt @@ -36,10 +36,10 @@ IF(ENABLE_TESTS) #ADD_TEST(ncgen3_${F} sh ${CMAKE_CURRENT_BINARY_DIR}/${F}.sh) ENDFOREACH() ENDIF() -INSTALL(TARGETS ncgen3 DESTINATION bin) +INSTALL(TARGETS ncgen3 DESTINATION bin COMPONENT utilities) SET(MAN_FILES ncgen3.1) -INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1") +INSTALL(FILES ${MAN_FILES} DESTINATION "share/man/man1" COMPONENT documentation) SET(CLEANFILES c0.nc c0_64.nc c0_4.nc c0_4c.nc) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEANFILES}") diff --git a/netcdf-config-version.cmake.in b/netcdf-config-version.cmake.in new file mode 100644 index 000000000..7dcd6b8dc --- /dev/null +++ b/netcdf-config-version.cmake.in @@ -0,0 +1,10 @@ +# Cmake Package & Configuration file support. +# Based on code from 'Mastering Cmake' + +set (PACKAGE_VERSION "@version@") +if (NOT "${PACKAGE_FIND_VERSION}" VERSION_GREATER "@version@") + set (PACKAGE_VERSION_COMPATIBLE 1) # Compatible with older. + if ("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "@version@") + set(PACKAGE_VERSION_EXACT 1) # exact match for this version. + endif() +endif() diff --git a/netcdf-config.cmake.in b/netcdf-config.cmake.in new file mode 100644 index 000000000..a6097203f --- /dev/null +++ b/netcdf-config.cmake.in @@ -0,0 +1,15 @@ +# Cmake Package & Configuration file support. +# Based on code from 'Mastering Cmake' + +# Compute installation prefix relative to this file. +get_filename_component (_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component (_prefix "${_dir}/../.." ABSOLUTE) + +# Import the targets +include ("${_prefix}/share/cmake/netcdf-targets.cmake") + +# Report other information +set (netcdf_INCLUDE_DIRS "${_prefix}/include/") + + + diff --git a/oc2/ocuri.c b/oc2/ocuri.c index 9b0f39e53..efea9a069 100644 --- a/oc2/ocuri.c +++ b/oc2/ocuri.c @@ -348,6 +348,9 @@ ocuriparse(const char* uri0, OCURI** durip) } #endif if(durip != NULL) *durip = duri; + else { + free(duri); + } return 1; fail: