2013-02-27 01:54:41 +08:00
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
#Minimum required CMake Version
|
|
|
|
cmake_minimum_required(VERSION 2.8.8)
|
2012-12-21 05:50:45 +08:00
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
#Project Name
|
2013-02-20 07:29:41 +08:00
|
|
|
project(netCDF C)
|
|
|
|
SET(netCDF_VERSION_MAJOR 4)
|
|
|
|
SET(netCDF_VERSION_MINOR 3)
|
|
|
|
SET(netCDF_VERSION_PATCH 0)
|
2013-02-23 05:03:02 +08:00
|
|
|
SET(netCDF_VERSION_NOTE "-rc2")
|
2013-02-20 07:29:41 +08:00
|
|
|
SET(netCDF_VERSION ${netCDF_VERSION_MAJOR}.${netCDF_VERSION_MINOR}.${netCDF_VERSION_PATCH}${netCDF_VERSION_NOTE})
|
|
|
|
SET(VERSION ${netCDF_VERSION})
|
2012-11-20 05:43:12 +08:00
|
|
|
|
2013-02-20 01:13:24 +08:00
|
|
|
# Set some default C Flags if we are using GCC
|
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
SET(CMAKE_C_FLAGS "-g -O2")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
ENABLE_TESTING()
|
|
|
|
INCLUDE(CTest)
|
|
|
|
|
|
|
|
IF(MSVC)
|
2012-11-06 06:52:14 +08:00
|
|
|
SET(GLOBAL PROPERTY USE_FOLDERS ON)
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDIF()
|
|
|
|
|
2012-10-12 06:42:53 +08:00
|
|
|
# CTest configuration
|
2012-11-20 05:43:12 +08:00
|
|
|
IF(NOT MSVC)
|
|
|
|
SET (CTEST_MEMORYCHECK_COMMAND valgrind CACHE STRING "")
|
|
|
|
ENDIF()
|
2012-10-04 00:39:27 +08:00
|
|
|
|
|
|
|
# Default to shared libs on
|
2013-02-20 07:29:41 +08:00
|
|
|
OPTION(BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON)
|
2012-10-03 04:56:46 +08:00
|
|
|
# Set variable to define the build type.
|
|
|
|
INCLUDE(GenerateExportHeader)
|
|
|
|
SET (LIB_TYPE STATIC)
|
|
|
|
IF (BUILD_SHARED_LIBS)
|
|
|
|
SET(LIB_TYPE SHARED)
|
2012-10-10 00:42:09 +08:00
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
2012-10-27 05:41:07 +08:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
2012-10-10 00:42:09 +08:00
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDIF()
|
|
|
|
ADD_DEFINITIONS()
|
|
|
|
|
|
|
|
### Verbose make, for debugging.
|
|
|
|
#SET(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
#Add custom CMake Module
|
|
|
|
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/"
|
|
|
|
CACHE INTERNAL "Location of our custom CMake modules.")
|
|
|
|
|
|
|
|
# Configure-type checks
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/FindPkgConfig.cmake)
|
|
|
|
INCLUDE (${CMAKE_ROOT}/Modules/GetPrerequisites.cmake)
|
2012-11-08 01:34:05 +08:00
|
|
|
# Only necessary for Windows
|
|
|
|
IF(MSVC)
|
2012-11-08 01:35:35 +08:00
|
|
|
INCLUDE (${CMAKE_SOURCE_DIR}/cmake/modules/windows/FindHDF5.cmake)
|
2012-12-14 06:09:41 +08:00
|
|
|
# Supress some warnings on Windows
|
2012-10-03 04:56:46 +08:00
|
|
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
2012-12-14 06:09:41 +08:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF (NOT CMAKE_BUILD_TYPE)
|
|
|
|
SET (CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None, Debug, Release."
|
|
|
|
FORCE)
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
#####
|
|
|
|
# Some utility macros/scripts.
|
|
|
|
#####
|
|
|
|
|
|
|
|
# A basic script used to convert m4 files
|
|
|
|
MACRO(GEN_m4 filename)
|
|
|
|
IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c)
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
|
|
|
|
COMMAND m4
|
|
|
|
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO(GEN_m4)
|
|
|
|
|
2013-02-13 06:22:54 +08:00
|
|
|
# Binary tests, but ones which depend on value of 'TEMP_LARGE' being defined.
|
|
|
|
MACRO(add_bin_env_temp_large_test prefix F)
|
|
|
|
ADD_EXECUTABLE(${prefix}_${F} ${F}.c)
|
|
|
|
TARGET_LINK_LIBRARIES(${prefix}_${F} netcdf)
|
|
|
|
IF(MSVC)
|
|
|
|
SET_TARGET_PROPERTIES(${prefix}_${F}
|
|
|
|
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
|
|
)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
ADD_TEST(${prefix}_${F} bash "-c" "TEMP_LARGE=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${prefix}_${F}")
|
|
|
|
IF(MSVC)
|
|
|
|
SET_PROPERTY(TARGET ${prefix}_${F} PROPERTY FOLDER "tests")
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
# Tests which are binary, but depend on a particular environmental variable.
|
|
|
|
MACRO(add_bin_env_test prefix F)
|
|
|
|
ADD_EXECUTABLE(${prefix}_${F} ${F}.c)
|
|
|
|
TARGET_LINK_LIBRARIES(${prefix}_${F} netcdf)
|
2012-10-25 03:49:31 +08:00
|
|
|
IF(MSVC)
|
2012-11-06 06:44:01 +08:00
|
|
|
SET_TARGET_PROPERTIES(${prefix}_${F}
|
2012-10-25 03:49:31 +08:00
|
|
|
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
|
|
)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2012-12-06 02:35:42 +08:00
|
|
|
ADD_TEST(${prefix}_${F} bash "-c" "TOPSRCDIR=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${prefix}_${F}")
|
2012-11-06 06:44:01 +08:00
|
|
|
IF(MSVC)
|
|
|
|
SET_PROPERTY(TARGET ${prefix}_${F} PROPERTY FOLDER "tests")
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDMACRO()
|
|
|
|
|
2013-02-15 04:24:02 +08:00
|
|
|
# Build a binary used by a script, but don't make a test out of it.
|
|
|
|
MACRO(build_bin_test F)
|
2013-02-13 06:22:54 +08:00
|
|
|
ADD_EXECUTABLE(${F} ${F}.c)
|
|
|
|
TARGET_LINK_LIBRARIES(${F} netcdf)
|
|
|
|
IF(MSVC)
|
|
|
|
SET_TARGET_PROPERTIES(${F}
|
|
|
|
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
2013-02-15 04:24:02 +08:00
|
|
|
)
|
2013-02-13 06:22:54 +08:00
|
|
|
ENDIF()
|
2013-02-15 04:24:02 +08:00
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
# Binary tests which are used by a script looking for a specific name.
|
|
|
|
MACRO(add_bin_test_no_prefix F)
|
|
|
|
build_bin_test(${F})
|
2013-02-13 06:22:54 +08:00
|
|
|
ADD_TEST(${F} ${EXECUTABLE_OUTPUT_PATH}/${F})
|
|
|
|
IF(MSVC)
|
|
|
|
SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/")
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
MACRO(add_bin_test prefix F)
|
|
|
|
ADD_EXECUTABLE(${prefix}_${F} ${F}.c)
|
|
|
|
TARGET_LINK_LIBRARIES(${prefix}_${F} netcdf)
|
2012-10-25 03:49:31 +08:00
|
|
|
IF(MSVC)
|
|
|
|
SET_TARGET_PROPERTIES(${prefix}_${F}
|
|
|
|
PROPERTIES LINK_FLAGS_DEBUG " /NODEFAULTLIB:MSVCRT"
|
|
|
|
)
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
ADD_TEST(${prefix}_${F} ${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F})
|
2012-11-06 06:44:01 +08:00
|
|
|
IF(MSVC)
|
2012-11-06 06:52:14 +08:00
|
|
|
SET_PROPERTY(TEST ${prefix}_${F} PROPERTY FOLDER "tests/")
|
2012-11-06 06:44:01 +08:00
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
# A script to print out information at the end of the configuration step.
|
|
|
|
MACRO(print_conf_summary)
|
|
|
|
MESSAGE("")
|
|
|
|
MESSAGE("")
|
|
|
|
MESSAGE(STATUS "CMake Summary:")
|
|
|
|
MESSAGE("")
|
2012-12-14 06:09:41 +08:00
|
|
|
MESSAGE(STATUS "\tBuild Type:\t\t\t" ${CMAKE_BUILD_TYPE})
|
2012-10-03 04:56:46 +08:00
|
|
|
MESSAGE(STATUS "\tBuilding Shared Libraries:\t" ${BUILD_SHARED_LIBS})
|
2013-02-20 07:29:41 +08:00
|
|
|
MESSAGE(STATUS "\tBuilding netCDF-4:\t\t" ${ENABLE_NETCDF_4})
|
2012-10-03 04:56:46 +08:00
|
|
|
MESSAGE(STATUS "\tBuilding DAP Support:\t\t" ${ENABLE_DAP})
|
|
|
|
MESSAGE(STATUS "\tBuilding Utilities:\t\t" ${BUILD_UTILITIES})
|
2013-02-13 06:22:54 +08:00
|
|
|
IF(CMAKE_PREFIX_PATH)
|
|
|
|
MESSAGE(STATUS "\tCMake Prefix Path:\t\t" "${CMAKE_PREFIX_PATH}")
|
|
|
|
ENDIF()
|
|
|
|
MESSAGE(STATUS "\tUsing pnetcdf:\t\t\t" ${STATUS_PNETCDF}, "\t" ${PNETCDF_INCLUDE_DIR})
|
|
|
|
MESSAGE(STATUS "\tUsing Parallel IO:\t\t" ${STATUS_PARALLEL})
|
|
|
|
MESSAGE(STATUS "\tLinking against:\t\t" "${ALL_TLL_LIBS}")
|
2012-10-03 04:56:46 +08:00
|
|
|
MESSAGE("")
|
|
|
|
|
|
|
|
ENDMACRO()
|
|
|
|
# Shell script Macro
|
|
|
|
MACRO(add_sh_test prefix F)
|
|
|
|
IF(NOT MSVC)
|
2012-12-06 02:35:42 +08:00
|
|
|
ADD_TEST(${prefix}_${F} bash "-c" "export srcdir=${CMAKE_CURRENT_SOURCE_DIR};export TOPSRCDIR=${CMAKE_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}/${F}.sh")
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDIF()
|
2012-11-06 06:44:01 +08:00
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
# Option checks
|
|
|
|
#####
|
|
|
|
|
|
|
|
# HDF5 cache variables.
|
|
|
|
SET (DEFAULT_CHUNK_SIZE 4194304 CACHE STRING "Default Chunk Cache Size.")
|
|
|
|
SET (DEFAULT_CHUNKS_IN_CACHE 10 CACHE STRING "Default number of chunks in cache.")
|
|
|
|
SET (CHUNK_CACHE_SIZE 4194304 CACHE STRING "Default Chunk Cache Size.")
|
|
|
|
SET (CHUNK_CACHE_NELEMS 1009 CACHE STRING "Default maximum number of elements in cache.")
|
|
|
|
SET (CHUNK_CACHE_PREEMPTION 0.75 CACHE STRING "Default file chunk cache preemption policy for HDf5 files (a number between 0 and 1, inclusive.")
|
|
|
|
SET (MAX_DEFAULT_CACHE_SIZE 67108864 CACHE STRING "Default maximum cache size.")
|
2012-11-01 06:17:33 +08:00
|
|
|
SET (NETCDF_LIB_NAME "" CACHE STRING "Default name of the netcdf library.")
|
2013-02-13 06:22:54 +08:00
|
|
|
SET (TEMP_LARGE "." CACHE STRING "Where to put large temp files if large file tests are run.")
|
2012-11-01 06:17:33 +08:00
|
|
|
|
|
|
|
IF(NOT NETCDF_LIB_NAME STREQUAL "")
|
|
|
|
SET(MOD_NETCDF_NAME ON)
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
|
2012-11-20 05:43:12 +08:00
|
|
|
# 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)
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
# Set the appropriate compiler/architecture for universal OSX binaries.
|
|
|
|
IF(${CMAKE_SYSTEM_NAME} EQUAL "Darwin")
|
|
|
|
SET(CMAKE_OSX_ARCHITECTURES i386;x86_64)
|
|
|
|
ENDIF(${CMAKE_SYSTEM_NAME} EQUAL "Darwin")
|
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
# Option to build netCDF Version 2
|
|
|
|
OPTION (BUILD_V2 "Build netCDF Version 2." ON)
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
# Option to build utilities
|
|
|
|
OPTION (BUILD_UTILITIES "Build ncgen, ncgen3, ncdump." ON)
|
|
|
|
|
|
|
|
# Option to use MMAP
|
2013-02-15 04:24:02 +08:00
|
|
|
OPTION (ENABLE_MMAP "Use MMAP." OFF)
|
|
|
|
IF(ENABLE_MMAP)
|
|
|
|
IF(NOT HAVE_MREMAP)
|
|
|
|
MESSAGE(STATUS "mremap not found: disabling MMAP support.")
|
|
|
|
SET(ENABLE_MMAP OFF)
|
|
|
|
ELSE()
|
|
|
|
SET(HAVE_MMAP ON)
|
|
|
|
SET(BUILD_MMAP ON)
|
|
|
|
SET(USE_MMAP ON)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
# Option to use examples.
|
|
|
|
OPTION (ENABLE_EXAMPLES "Build Examples" ON)
|
|
|
|
|
|
|
|
|
|
|
|
# Option to use Diskless
|
2013-02-13 06:22:54 +08:00
|
|
|
OPTION (ENABLE_DISKLESS "Build Diskless." ON)
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(ENABLE_DISKLESS)
|
|
|
|
SET(BUILD_DISKLESS ON)
|
|
|
|
SET(USE_DISKLESS ON)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(ENABLE_COVERAGE_TESTS)
|
2012-10-04 04:47:34 +08:00
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
|
|
|
|
SET(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Option Logging, only valid for netcdf4.
|
|
|
|
OPTION (ENABLE_LOGGING "Enable Logging." OFF)
|
2012-12-06 02:35:42 +08:00
|
|
|
IF(ENABLE_LOGGING)
|
|
|
|
SET(LOGGING ON)
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
# Option to use HDF4
|
2013-02-20 07:29:41 +08:00
|
|
|
OPTION (ENABLE_HDF4 "Build netCDF-4 with HDF5 read capability (HDF4, HDF5 and Zlib required)." OFF)
|
2013-01-16 06:43:09 +08:00
|
|
|
IF (ENABLE_HDF4)
|
|
|
|
SET(USE_HDF4 ON)
|
|
|
|
# Check for include files, libraries.
|
2012-10-03 04:56:46 +08:00
|
|
|
CHECK_INCLUDE_FILE("mfhdf.h" HAVE_MFHDF_H)
|
|
|
|
IF(NOT HAVE_MFHDF_H)
|
|
|
|
MESSAGE(FATAL_ERROR "HDF4 Support specified, cannot find file mfhdf.h")
|
|
|
|
ENDIF(NOT HAVE_MFHDF_H)
|
2013-01-16 06:43:09 +08:00
|
|
|
|
|
|
|
FIND_LIBRARY(HDF4_DF_LIB NAMES df libdf)
|
|
|
|
IF(NOT HDF4_DF_LIB)
|
|
|
|
MESSAGE(FATAL_ERROR "HDF4 Support enabled, but cannot find df lib.")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
FIND_LIBRARY(HDF4_MFHDF_LIB NAMES mfhdf libmfhdf)
|
|
|
|
IF(NOT HDF4_MFHDF_LIB)
|
|
|
|
MESSAGE(FATAL_ERROR "HDF4 Support enabled, but cannot find mfhdf lib.")
|
|
|
|
ENDIF()
|
|
|
|
|
2013-01-23 04:37:23 +08:00
|
|
|
SET(HDF4_LIBRARIES ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB})
|
2013-01-16 06:43:09 +08:00
|
|
|
# End include files, libraries.
|
|
|
|
MESSAGE(STATUS "HDF4 Libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}")
|
|
|
|
OPTION(ENABLE_HDF4_FILE_TESTS "Run HDF4 File Tests.",OFF)
|
|
|
|
IF(ENABLE_HDF4_FILE_TESTS)
|
|
|
|
SET(USE_HDF4_FILE_TESTS ON)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF ()
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
# Option to Build DLL
|
|
|
|
IF(WIN32)
|
|
|
|
OPTION (ENABLE_DLL "Build a Windows DLL." ${BUILD_SHARED_LIBS})
|
|
|
|
IF (ENABLE_DLL)
|
|
|
|
SET(BUILD_DLL ON CACHE BOOL "")
|
|
|
|
ADD_DEFINITIONS(-DDLL_NETCDF)
|
|
|
|
ADD_DEFINITIONS(-DDLL_EXPORT)
|
|
|
|
ENDIF ()
|
|
|
|
ENDIF()
|
|
|
|
# Did the user specify a default minimum blocksize for posixio?
|
|
|
|
SET (NCIO_MINBLOCKSIZE 256 CACHE STRING "Minimum I/O Blocksize for netCDF classic and 64-bit offset format files.")
|
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
# Build netCDF4
|
|
|
|
OPTION (ENABLE_NETCDF_4 "Enable netCDF-4" ON)
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(ENABLE_NETCDF_4)
|
|
|
|
SET(USE_NETCDF4 ON CACHE BOOL "")
|
|
|
|
SET(ENABLE_NETCDF_4 ON CACHE BOOL "")
|
|
|
|
SET(ENABLE_NETCDF4 ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Option for cdmremote support.
|
|
|
|
OPTION (ENABLE_CDMREMOTE OFF "Build with cdmremote client support.")
|
2012-10-27 05:41:07 +08:00
|
|
|
IF(ENABLE_CDMREMOTE)
|
|
|
|
SET(BUILD_CDMREMOTE ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
# Option for building RPC
|
2012-11-10 05:19:17 +08:00
|
|
|
OPTION (ENABLE_RPC OFF "Enable RPC Client and Server.")
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(ENABLE_RPC)
|
|
|
|
SET(BUILD_RPC ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Option to Enable HDF5
|
2012-10-16 05:58:13 +08:00
|
|
|
OPTION (USE_SZIP "Use SZip" OFF)
|
2012-10-03 04:56:46 +08:00
|
|
|
OPTION (USE_HDF5 "Use HDF5." ${ENABLE_NETCDF_4})
|
|
|
|
IF (USE_HDF5 OR ENABLE_NETCDF_4)
|
|
|
|
SET(USE_HDF5 ON)
|
|
|
|
SET(USE_NETCDF4 ON)
|
|
|
|
|
2012-11-10 06:45:33 +08:00
|
|
|
#FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
|
|
|
|
FIND_LIBRARY(HDF5_LIB NAMES hdf5 libhdf5 hdf5dll)
|
|
|
|
FIND_LIBRARY(HDF5_HL_LIB NAMES hdf5_hl libhdf5_hl hdf5_hldll)
|
|
|
|
|
|
|
|
SET(HDF5_LIBRARIES ${HDF5_LIB} ${HDF5_HL_LIB})
|
|
|
|
FIND_PATH(HDF5_INCLUDE_DIR H5public.h)
|
|
|
|
|
|
|
|
MESSAGE(STATUS "${HDF5_LIB}, ${HDF5_HL_LIB}, ${HDF5_INCLUDE_DIR}")
|
2012-10-03 04:56:46 +08:00
|
|
|
|
2012-11-08 01:30:12 +08:00
|
|
|
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
|
2012-11-10 05:19:17 +08:00
|
|
|
|
|
|
|
#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(USE_SZIP)
|
2012-11-10 05:19:17 +08:00
|
|
|
#FIND_PACKAGE(SZIP)
|
2012-11-20 05:43:12 +08:00
|
|
|
FIND_LIBRARY(SZIP_LIBRARY NAMES szip sz libszip)
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(NOT SZIP_LIBRARY)
|
|
|
|
MESSAGE(FATAL_ERROR "HDF5 compiled with szip, but cannot find local szip libraries.")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "Found SZip: ${SZIP_LIBRARY}")
|
|
|
|
ENDIF()
|
|
|
|
INCLUDE_DIRECTORIES(${SZIP_INCLUDE_DIRS})
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
SET(H5_USE_16_API 1)
|
|
|
|
|
|
|
|
# Check for ZLib, but only if using HDF5.
|
|
|
|
FIND_PACKAGE(ZLIB)
|
|
|
|
IF(NOT ZLIB_LIBRARY)
|
|
|
|
MESSAGE(FATAL_ERROR "HDF5 Support specified, cannot find ZLib.")
|
|
|
|
ENDIF()
|
|
|
|
SET(USE_ZLIB ON)
|
|
|
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
|
|
|
|
ENDIF ()
|
|
|
|
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
|
|
|
|
# Option to Build DAP Client
|
|
|
|
OPTION (ENABLE_DAP "Enable DAP Client." ON)
|
|
|
|
IF (ENABLE_DAP)
|
|
|
|
SET(USE_DAP ON)
|
|
|
|
FIND_PACKAGE(CURL)
|
|
|
|
IF(NOT CURL_LIBRARY)
|
|
|
|
MESSAGE(FATAL_ERROR "DAP Support specified, CURL libraries are not found.")
|
|
|
|
ENDIF()
|
|
|
|
ADD_DEFINITIONS(-DCURL_STATICLIB=1)
|
|
|
|
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Option to Enable DAP long tests, remote tests.
|
|
|
|
OPTION(ENABLE_DAP_LONG_TESTS "Enable DAP long tests." OFF)
|
|
|
|
OPTION(ENABLE_DAP_REMOTE_TESTS "Enable DAP remote tests." ON)
|
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
# If netCDF4 and DAP, Option for DAP groups.
|
2012-11-20 05:43:12 +08:00
|
|
|
IF(ENABLE_NETCDF_4 AND USE_DAP)
|
2012-10-03 04:56:46 +08:00
|
|
|
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.")
|
|
|
|
ENDIF()
|
|
|
|
|
2013-01-16 06:43:09 +08:00
|
|
|
|
|
|
|
# Enable some developer-only tests
|
|
|
|
OPTION(ENABLE_EXTRA_TESTS "Enable Extra tests. Some may not work because of known issues. Developers only." OFF)
|
|
|
|
IF(ENABLE_EXTRA_TESTS)
|
|
|
|
SET(EXTRA_TESTS ON)
|
|
|
|
ENDIF()
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
# Option to use bundled XGetopt in place of getopt(). This is mostly useful
|
|
|
|
# for MSVC builds. If not building utilities, getopt() isn't required at all.
|
|
|
|
IF(MSVC)
|
|
|
|
OPTION(ENABLE_XGETOPT "Enable bundled XGetOpt instead of external getopt()." ON)
|
|
|
|
IF(ENABLE_XGETOPT)
|
|
|
|
SET(USE_X_GETOPT ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
SET(MATH "")
|
|
|
|
IF(NOT WIN32)
|
|
|
|
# FFIO insteaad of PosixIO
|
|
|
|
OPTION(ENABLE_FFIO "If true, use ffio instead of posixio" OFF)
|
|
|
|
IF(ENABLE_FFIO)
|
|
|
|
SET(USE_FFIO ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Enable Tests
|
|
|
|
#IF(NOT MSVC)
|
2012-12-21 05:50:45 +08:00
|
|
|
OPTION (ENABLE_TESTS "Enable basic tests, run with 'make test'." ON)
|
|
|
|
IF(ENABLE_TESTS)
|
|
|
|
SET(BUILD_TESTSETS ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
# Enable Large file tests
|
|
|
|
OPTION (ENABLE_LARGE_FILE_TESTS "Enable large file tests." OFF)
|
|
|
|
IF(ENABLE_LARGE_FILE_TESTS)
|
2012-12-21 05:50:45 +08:00
|
|
|
SET(LARGE_FILE_TESTS ON)
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDIF()
|
|
|
|
|
2012-12-06 02:35:42 +08:00
|
|
|
# Location for large file tests.
|
|
|
|
SET(TEMP_LARGE "." CACHE STRING "Location to store large file tests.")
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
OPTION (ENABLE_INTERNAL_DOCS "Enable documentation of library internals. This is of interest only to those developing the netCDF library." OFF)
|
|
|
|
IF(ENABLE_INTERNAL_DOCS)
|
|
|
|
SET(BUILD_INTERNAL_DOCS ON)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
OPTION (ENABLE_FSYNC "Enable experimental fsync code." OFF)
|
|
|
|
IF(ENABLE_FSYNC)
|
|
|
|
SET(USE_FSYNC ON)
|
|
|
|
ENDIF()
|
|
|
|
|
2012-12-21 05:50:45 +08:00
|
|
|
# Linux specific large file support flags.
|
|
|
|
# Modelled after check in CMakeLists.txt for hdf5.
|
|
|
|
IF (NOT WINDOWS)
|
|
|
|
OPTION(ENABLE_LFS "Enable large (64-bit) files on linux." ON)
|
|
|
|
# TODO: There needs to be a check here to ensure
|
|
|
|
# that large file support is actually supported.
|
|
|
|
|
|
|
|
IF(ENABLE_LFS)
|
|
|
|
SET(_FILE_OFFSET_BITS 64)
|
|
|
|
SET(_LARGEFILE64_SOURCE TRUE)
|
|
|
|
SET(_LARGEFILE_SOURCE TRUE)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
# Provide the option to perform coverage tests.
|
|
|
|
OPTION (ENABLE_COVERAGE_TESTS "Enable compiler flags needed to perform coverage tests." OFF)
|
|
|
|
IF(ENABLE_COVERAGE_TESTS)
|
2012-10-04 04:47:34 +08:00
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -W -profile-arcs -ftest-coverage")
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
2012-10-03 04:56:46 +08:00
|
|
|
MESSAGE(STATUS "Coverage Tests: On.")
|
|
|
|
ENDIF()
|
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
OPTION (ENABLE_EXAMPLE_TESTS "Run extra example tests. Requires GNU Sed. Ignored if netCDF-4 is not Enabled" OFF)
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(NOT ENABLE_NETCDF_4 AND ENABLE_EXAMPLE_TESTS)
|
|
|
|
SET (ENABLE_EXAMPLE_TESTS OFF)
|
|
|
|
ENDIF()
|
|
|
|
|
2013-02-13 06:22:54 +08:00
|
|
|
SET(STATUS_PARALLEL "OFF")
|
|
|
|
OPTION(ENABLE_PARALLEL "Build netCDF-4 with parallel IO" OFF)
|
|
|
|
IF(ENABLE_PARALLEL)
|
2013-02-07 07:09:19 +08:00
|
|
|
SET(USE_PARALLEL ON CACHE BOOL "")
|
|
|
|
# Check for H5Pget_fapl_mpiposx, define USE_PARALLEL_POSIX
|
2013-02-13 06:22:54 +08:00
|
|
|
CHECK_LIBRARY_EXISTS(${HDF5_LIB} H5Pget_fapl_mpioposix "" USE_PARALLEL_POSIX)
|
2013-02-07 07:09:19 +08:00
|
|
|
|
|
|
|
# Else Check for H5Pget_fapl_mpio, define USE_PARALLEL_MPIO
|
|
|
|
IF(NOT USE_PARALLEL_POSIX)
|
2013-02-13 06:22:54 +08:00
|
|
|
CHECK_LIBRARY_EXISTS(${HDF5_LIB} H5Pget_fapl_mpio "" USE_PARALLEL_MPIO)
|
2013-02-07 07:09:19 +08:00
|
|
|
ENDIF()
|
2013-02-13 06:22:54 +08:00
|
|
|
|
2013-02-07 07:09:19 +08:00
|
|
|
IF(NOT USE_PARALLEL_POSIX AND NOT USE_PARALLEL_MPIO)
|
|
|
|
SET(USE_PARALLEL OFF CACHE BOOL "")
|
2013-02-13 06:22:54 +08:00
|
|
|
MESSAGE(STATUS "Cannot find HDF5 library built with parallel support. Disabling parallel build.")
|
|
|
|
ENDIF()
|
|
|
|
SET(STATUS_PARALLEL "ON")
|
|
|
|
ENDIF()
|
2013-02-07 07:09:19 +08:00
|
|
|
|
2013-02-13 06:22:54 +08:00
|
|
|
# Options to enable parallel IO, tests.
|
|
|
|
SET(STATUS_PNETCDF "OFF")
|
|
|
|
OPTION(ENABLE_PNETCDF "Build netCDF-4 with parallel I/O for classic and 64-bit offset files using parallel-netcdf." OFF)
|
|
|
|
IF(ENABLE_PNETCDF)
|
|
|
|
# Check for ncmpi_create in libpnetcdf, define USE_PNETCDF
|
|
|
|
# Does the user want to turn on PNETCDF read ability?
|
|
|
|
SET(USE_PNETCDF ON CACHE BOOL "")
|
|
|
|
FIND_LIBRARY(PNETCDF NAMES pnetcdf)
|
|
|
|
FIND_PATH(PNETCDF_INCLUDE_DIR pnetcdf.h)
|
|
|
|
IF(NOT PNETCDF)
|
|
|
|
MESSAGE(STATUS "Cannot find pnetcdf library. Disabling pnetcdf support.")
|
|
|
|
SET(USE_PNETCDF OFF CACHE BOOL "")
|
2013-02-07 07:09:19 +08:00
|
|
|
ENDIF()
|
2013-02-13 06:22:54 +08:00
|
|
|
SET(STATUS_PNETCDF "ON")
|
|
|
|
INCLUDE_DIRECTORIES(${PNETCDF_INCLUDE_DIR})
|
|
|
|
SET(HAVE_LIBPNETCDF ON)
|
2013-02-07 07:09:19 +08:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
OPTION (ENABLE_PARALLEL_TESTS "Enable Parallel IO Tests. Ignored if netCDF4 is not enabled, or if there is no parallel I/O Support." ${USE_PARALLEL})
|
2013-02-13 06:22:54 +08:00
|
|
|
IF(ENABLE_PARALLEL_TESTS AND USE_PARALLEL)
|
|
|
|
SET(TEST_PARALLEL ON CACHE BOOL "")
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
OPTION (ENABLE_DOXYGEN "Enable generation of doxygen." OFF)
|
|
|
|
IF(ENABLE_DOXYGEN)
|
|
|
|
SET(BUILD_DOCS ON CACHE BOOL "")
|
|
|
|
OPTION(ENABLE_INTERNAL_DOCS "Build internal documentation. This is of interest to developers only." OFF)
|
|
|
|
IF(ENABLE_INTERNAL_DOCS)
|
|
|
|
SET(BUILD_INTERNAL_DOCS YES CACHE STRING "")
|
|
|
|
ELSE()
|
|
|
|
SET(BUILD_INTERNAL_DOCS NO CACHE STRING "")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
# Set some of the options as advanced.
|
|
|
|
MARK_AS_ADVANCED(ENABLE_INTERNAL_DOCS VALGRIND_TESTS ENABLE_PNETCDF BUILD_CDMREMOTE ENABLE_COVERAGE_TESTS)
|
2012-11-20 05:43:12 +08:00
|
|
|
MARK_AS_ADVANCED(ENABLE_DAP_REMOTE_TESTS ENABLE_DAP_LONG_TESTS USE_REMOTE_CDASH)
|
2012-10-03 04:56:46 +08:00
|
|
|
#####
|
|
|
|
# End option checks.
|
|
|
|
#####
|
|
|
|
|
|
|
|
#####
|
|
|
|
# System inspection checks
|
|
|
|
#####
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/oc2)
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libsrc)
|
|
|
|
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/libsrc)
|
2012-12-21 05:50:45 +08:00
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
#
|
|
|
|
# Library include checks
|
|
|
|
CHECK_INCLUDE_FILE("math.h" HAVE_MATH_H)
|
|
|
|
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
2013-01-16 06:43:09 +08:00
|
|
|
# Solve a compatibility issue in ncgen/, which checks
|
|
|
|
# for NO_UNISTD_H
|
|
|
|
IF(NOT HAVE_UNISTD_H)
|
|
|
|
SET(YY_NO_UNISTD_H TRUE)
|
|
|
|
ENDIF()
|
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
|
|
|
|
CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H)
|
|
|
|
CHECK_INCLUDE_FILE("dirent.h" HAVE_DIRENT_H)
|
|
|
|
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
|
|
|
|
CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
|
|
|
|
CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H)
|
|
|
|
CHECK_INCLUDE_FILE("getopt.h" HAVE_GETOPT_H)
|
|
|
|
CHECK_INCLUDE_FILE("stdbool.h" HAVE_STDBOOL_H)
|
|
|
|
CHECK_INCLUDE_FILE("locale.h" HAVE_LOCAL_H)
|
|
|
|
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
|
|
|
CHECK_INCLUDE_FILE("stdio.h" HAVE_STDIO_H)
|
|
|
|
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
|
2012-12-21 05:50:45 +08:00
|
|
|
CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H)
|
2012-10-03 04:56:46 +08:00
|
|
|
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
|
|
|
|
CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/dir.h" HAVE_SYS_DIR_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/ndir.h" HAVE_SYS_NDIR_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/wait.h" HAVE_SYS_WAIT_H)
|
|
|
|
CHECK_INCLUDE_FILE("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
|
|
|
CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H)
|
|
|
|
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
|
|
|
CHECK_INCLUDE_FILE("pstdint.h" HAVE_PSTDINT_H)
|
|
|
|
CHECK_INCLUDE_FILE("endian.h" HAVE_ENDIAN_H)
|
|
|
|
|
|
|
|
# Type checks
|
|
|
|
CHECK_TYPE_SIZE("double" SIZEOF_DOUBLE)
|
|
|
|
CHECK_TYPE_SIZE("float" SIZEOF_FLOAT)
|
|
|
|
CHECK_TYPE_SIZE("int" SIZEOF_INT)
|
|
|
|
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
|
|
|
|
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
|
|
|
|
CHECK_TYPE_SIZE("off_t" SIZEOF_OFF_T)
|
2012-12-21 05:50:45 +08:00
|
|
|
CHECK_TYPE_SIZE("off64_t" SIZEOF_OFF64_T)
|
2012-10-03 04:56:46 +08:00
|
|
|
CHECK_TYPE_SIZE("short" SIZEOF_SHORT)
|
|
|
|
CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
|
|
|
|
CHECK_TYPE_SIZE("uchar" SIZEOF_UCHAR)
|
2012-12-06 02:35:42 +08:00
|
|
|
CHECK_TYPE_SIZE("int64_t" SIZEOF_INT64_T)
|
|
|
|
CHECK_TYPE_SIZE("uint64_t" SIZEOF_UINT64_T)
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
# Check for various functions.
|
|
|
|
CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC)
|
|
|
|
CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
|
|
|
|
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
|
|
|
|
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
|
|
|
|
CHECK_FUNCTION_EXISTS(strchr HAVE_STRCHR)
|
|
|
|
CHECK_FUNCTION_EXISTS(strrchr HAVE_STRRCHR)
|
|
|
|
CHECK_FUNCTION_EXISTS(strcat HAVE_STRCAT)
|
|
|
|
CHECK_FUNCTION_EXISTS(strcpy HAVE_STRCPY)
|
|
|
|
CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
|
|
|
|
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
|
|
|
|
CHECK_FUNCTION_EXISTS(strtod HAVE_STRTOD)
|
|
|
|
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
|
|
|
|
CHECK_FUNCTION_EXISTS(strtoull HAVE_STROULL)
|
|
|
|
CHECK_FUNCTION_EXISTS(strstr HAVE_STRSTR)
|
|
|
|
CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
|
|
|
|
CHECK_FUNCTION_EXISTS(rand HAVE_RAND)
|
|
|
|
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
|
|
|
|
CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC)
|
|
|
|
CHECK_FUNCTION_EXISTS(MPI_Comm_f2C HAVE_MPI_COMM_F2C)
|
|
|
|
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
|
|
|
|
CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
|
|
|
|
CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
|
|
|
|
CHECK_FUNCTION_EXISTS(mremap HAVE_MREMAP)
|
|
|
|
CHECK_FUNCTION_EXISTS(getrlimit HAVE_GETRLIMIT)
|
|
|
|
#####
|
|
|
|
# End system inspection checks.
|
|
|
|
#####
|
|
|
|
|
|
|
|
|
|
|
|
# Check for the math library so it can be explicitely linked.
|
|
|
|
IF(NOT WIN32)
|
|
|
|
FIND_LIBRARY(HAVE_LIBM NAMES math m libm)
|
|
|
|
MESSAGE(STATUS "Found Math library: ${HAVE_LIBM}")
|
|
|
|
IF(NOT HAVE_LIBM)
|
|
|
|
MESSAGE(FATAL_ERROR "Unable to find the math library.")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Create config.h file
|
2013-02-20 07:29:41 +08:00
|
|
|
configure_file("${netCDF_SOURCE_DIR}/cmake_config.h.in"
|
|
|
|
"${netCDF_BINARY_DIR}/config.h")
|
|
|
|
configure_file("${netCDF_SOURCE_DIR}/cmake_nc-config.in"
|
|
|
|
"${netCDF_SOURCE_DIR}/nc-config")
|
|
|
|
FILE(COPY "${netCDF_SOURCE_DIR}/nc-config"
|
|
|
|
DESTINATION "${netCDF_BINARY_DIR}"
|
2012-10-03 04:56:46 +08:00
|
|
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
|
2013-02-20 07:29:41 +08:00
|
|
|
EXECUTE_PROCESS(COMMAND "chmod 755 ${netCDF_BINARY_DIR}/nc-config")
|
2012-10-03 04:56:46 +08:00
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
INSTALL(PROGRAMS ${netCDF_BINARY_DIR}/nc-config DESTINATION bin COMPONENT utilities)
|
|
|
|
INCLUDE_DIRECTORIES(${netCDF_BINARY_DIR})
|
2012-10-03 04:56:46 +08:00
|
|
|
# End autotools-style checs for config.h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
# Set core names of the libraries.
|
|
|
|
#####
|
2013-02-20 07:29:41 +08:00
|
|
|
SET (netCDF_LIB_CORENAME "netcdf")
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
#####
|
|
|
|
# Set the true names of all the libraries, if customized by external project
|
|
|
|
#####
|
|
|
|
# Recurse into other subdirectories.
|
|
|
|
#add_subdirectory(h5_test)
|
|
|
|
#add_subdirectory(man4)
|
|
|
|
#add_subdirectory(man4/images)
|
|
|
|
add_subdirectory("include")
|
|
|
|
add_subdirectory(libdispatch)
|
|
|
|
add_subdirectory(libsrc)
|
|
|
|
|
|
|
|
IF (USE_HDF5)
|
|
|
|
add_subdirectory(libsrc4)
|
|
|
|
ENDIF (USE_HDF5)
|
|
|
|
|
|
|
|
IF (USE_DAP)
|
|
|
|
ADD_SUBDIRECTORY(oc2)
|
|
|
|
ADD_SUBDIRECTORY(libdap2)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF (BUILD_CDMREMOTE)
|
|
|
|
ADD_SUBDIRECTORY(libcdmr)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
add_subdirectory(liblib)
|
|
|
|
#MESSAGE(STATUS "Linking with: ${ALL_TLL_LIBS}")
|
|
|
|
|
2012-10-10 04:56:27 +08:00
|
|
|
# For tests and utilities, we are no longer
|
|
|
|
# exporting symbols but rather importing them.
|
|
|
|
IF(BUILD_DLL)
|
|
|
|
REMOVE_DEFINITIONS(-DDLL_EXPORT)
|
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
|
2012-10-10 04:56:27 +08:00
|
|
|
# Enable Utilities.
|
2012-10-03 04:56:46 +08:00
|
|
|
IF (BUILD_UTILITIES)
|
|
|
|
INCLUDE_DIRECTORIES(ncdump)
|
|
|
|
ADD_SUBDIRECTORY(ncgen)
|
|
|
|
ADD_SUBDIRECTORY(ncgen3)
|
|
|
|
ADD_SUBDIRECTORY(ncdump)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Enable tests
|
|
|
|
IF(ENABLE_TESTS)
|
|
|
|
ADD_SUBDIRECTORY(nctest)
|
|
|
|
ADD_SUBDIRECTORY(nc_test)
|
|
|
|
IF(USE_NETCDF4)
|
|
|
|
ADD_SUBDIRECTORY(nc_test4)
|
|
|
|
ADD_SUBDIRECTORY(h5_test)
|
|
|
|
ENDIF()
|
2013-01-26 01:51:33 +08:00
|
|
|
IF(USE_DAP AND ENABLE_DAP_REMOTE_TESTS)
|
2012-10-03 04:56:46 +08:00
|
|
|
ADD_SUBDIRECTORY(ncdap_test)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(ENABLE_EXAMPLES)
|
|
|
|
ADD_SUBDIRECTORY(examples)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Code to generate an export header
|
2012-10-04 04:47:34 +08:00
|
|
|
#GENERATE_EXPORT_HEADER(netcdf
|
|
|
|
# BASE_NAME netcdf
|
|
|
|
# EXPORT_MACRO_NAME netcdf_EXPORT
|
|
|
|
# EXPORT_FILE_NAME netcdf_Export.h
|
|
|
|
# STATIC_DEFINE netcdf_BUILT_AS_STATIC
|
|
|
|
#)
|
2012-10-03 04:56:46 +08:00
|
|
|
|
|
|
|
#####
|
|
|
|
# Build doxygen documentation, if need be.
|
|
|
|
#####
|
|
|
|
IF(BUILD_DOCS)
|
|
|
|
ADD_SUBDIRECTORY(man4)
|
|
|
|
ENDIF()
|
|
|
|
#####
|
|
|
|
# Moving on to CPack, install packages.
|
|
|
|
#####
|
2013-02-20 07:29:41 +08:00
|
|
|
INSTALL(FILES ${netCDF_SOURCE_DIR}/include/netcdf.h
|
2012-11-20 05:43:12 +08:00
|
|
|
DESTINATION include COMPONENT headers)
|
2013-02-20 07:29:41 +08:00
|
|
|
IF(ENABLE_PNETCDF OR ENABLE_PARALLEL)
|
|
|
|
INSTALL(FILES ${netCDF_SOURCE_DIR}/include/netcdf_par.h
|
|
|
|
DESTINATION include COMPONENT headers)
|
|
|
|
ENDIF()
|
2012-11-20 05:43:12 +08:00
|
|
|
# Install the dependencies.
|
|
|
|
IF(MSVC)
|
|
|
|
INSTALL(DIRECTORY ${CMAKE_PREFIX_PATH} DESTINATION "deps" COMPONENT dependencies)
|
|
|
|
ENDIF()
|
|
|
|
|
2012-10-12 06:31:50 +08:00
|
|
|
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(ENABLE_DOXYGEN)
|
2012-11-20 05:43:12 +08:00
|
|
|
INSTALL(DIRECTORY man4 DESTINATION "." COMPONENT documentation)
|
2012-10-03 04:56:46 +08:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Subdirectory CMakeLists.txt files should specify their own
|
|
|
|
# 'install' files.
|
|
|
|
# Including 'CPack' kicks everything off.
|
|
|
|
INCLUDE(InstallRequiredSystemLibraries)
|
|
|
|
CONFIGURE_FILE(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/FixBundle.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
#INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake)
|
|
|
|
|
2012-11-20 05:43:12 +08:00
|
|
|
# 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 (
|
2013-02-20 07:29:41 +08:00
|
|
|
${netCDF_SOURCE_DIR}/netcdf-config.cmake.in
|
|
|
|
${netCDF_BINARY_DIR}/netcdf-config.cmake @ONLY)
|
2012-11-20 05:43:12 +08:00
|
|
|
|
|
|
|
configure_file (
|
2013-02-20 07:29:41 +08:00
|
|
|
${netCDF_SOURCE_DIR}/netcdf-config-version.cmake.in
|
|
|
|
${netCDF_BINARY_DIR}/netcdf-config-version.cmake @ONLY)
|
2012-11-20 05:43:12 +08:00
|
|
|
|
2013-02-20 07:29:41 +08:00
|
|
|
install (FILES ${netCDF_BINARY_DIR}/netcdf-config.cmake
|
|
|
|
${netCDF_BINARY_DIR}/netcdf-config-version.cmake
|
2012-11-20 05:43:12 +08:00
|
|
|
DESTINATION share/cmake)
|
|
|
|
|
|
|
|
# End CMake package configuration files.
|
2012-10-03 04:56:46 +08:00
|
|
|
#####
|
|
|
|
# Various options for CPACK
|
|
|
|
#####
|
|
|
|
|
|
|
|
##
|
|
|
|
# Declare exclusions list used when building a source file.
|
|
|
|
# NOTE!! This list uses regular expressions, NOT wildcards!!
|
|
|
|
##
|
|
|
|
SET (CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}"
|
2013-02-20 07:29:41 +08:00
|
|
|
"/expecttds3/"
|
|
|
|
"/nocacheremote3/"
|
|
|
|
"/nocacheremote4/"
|
|
|
|
"/special3/"
|
2012-10-03 04:56:46 +08:00
|
|
|
"${CMAKE_BINARY_DIR}/*"
|
|
|
|
"/myhtml/*"
|
|
|
|
"/.svn/"
|
2013-02-20 07:29:41 +08:00
|
|
|
"my.*\\\\.sh"
|
2012-12-21 05:50:45 +08:00
|
|
|
"/.deps/"
|
|
|
|
"/.libs"
|
|
|
|
"/libcf/"
|
|
|
|
"/html/"
|
2013-02-20 07:29:41 +08:00
|
|
|
".*\\\\.jar"
|
|
|
|
".*\\\\.jdl"
|
|
|
|
".*\\\\.sed"
|
|
|
|
".*\\\\.proto"
|
|
|
|
".*\\\\.texi"
|
|
|
|
".*\\\\.example"
|
|
|
|
"Make0"
|
|
|
|
"/obsolete/"
|
|
|
|
"/unknown/"
|
|
|
|
"/udunits/"
|
2012-10-03 04:56:46 +08:00
|
|
|
".*~"
|
|
|
|
)
|
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/COPYRIGHT
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/COPYRIGHT.txt
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
|
|
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/COPYRIGHT.txt")
|
2012-12-06 02:35:42 +08:00
|
|
|
IF(NOT CPACK_PACK_VERSION)
|
2013-01-31 05:13:32 +08:00
|
|
|
SET(CPACK_PACKAGE_VERSION ${VERSION})
|
2012-12-06 02:35:42 +08:00
|
|
|
ENDIF()
|
2012-10-03 04:56:46 +08:00
|
|
|
IF(APPLE)
|
2013-02-20 07:29:41 +08:00
|
|
|
SET(CPACK_SOURCE_GENERATOR "TGZ")
|
|
|
|
#SET(CPACK_SOURCE_GENERATOR "TBZ2" "TGZ" "ZIP")
|
2012-10-03 04:56:46 +08:00
|
|
|
SET(CPACK_GENERATOR "PackageMaker" "STGZ" "TBZ2" "TGZ" "ZIP")
|
|
|
|
ENDIF()
|
|
|
|
|
2012-10-12 06:31:50 +08:00
|
|
|
# Create an 'uninstall' target.
|
|
|
|
CONFIGURE_FILE(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
2012-10-30 02:46:56 +08:00
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
|
2012-10-12 06:31:50 +08:00
|
|
|
ADD_CUSTOM_TARGET(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
2012-10-03 04:56:46 +08:00
|
|
|
|
2012-10-30 02:46:56 +08:00
|
|
|
|
2012-11-20 05:43:12 +08:00
|
|
|
## 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.")
|
2012-10-03 04:56:46 +08:00
|
|
|
print_conf_summary()
|
|
|
|
#MESSAGE(STATUS "CPACK_SOURCE_IGNORE_FILES: ${CPACK_SOURCE_IGNORE_FILES}")
|
|
|
|
# CPack inclusion must come last.
|
|
|
|
INCLUDE(CPack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|