2013-08-15 23:43:59 +08:00
## This is a CMake file, part of Unidata's netCDF package.
# Copyright 2012-2013, see the COPYRIGHT file for more information.
2013-10-01 05:51:34 +08:00
##################################
# Set Project Properties
##################################
2012-10-03 04:56:46 +08:00
#Minimum required CMake Version
cmake_minimum_required ( VERSION 2.8.8 )
2013-10-01 05:51:34 +08:00
2012-10-03 04:56:46 +08:00
#Project Name
2013-02-20 07:29:41 +08:00
project ( netCDF C )
2013-03-28 03:15:00 +08:00
set ( PACKAGE "netCDF" CACHE STRING "" )
2014-05-13 06:05:39 +08:00
#####
# Version Info:
#
# Release Version
# Library Version
# SO Version
#
# SO Version is computed from library version. See:
# http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
#####
2013-02-20 07:29:41 +08:00
SET ( netCDF_VERSION_MAJOR 4 )
SET ( netCDF_VERSION_MINOR 3 )
2014-04-24 06:00:49 +08:00
SET ( netCDF_VERSION_PATCH 3 )
SET ( netCDF_VERSION_NOTE "-rc1" )
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 } )
2014-05-13 06:05:39 +08:00
SET ( netCDF_LIB_VERSION 7.2.0 )
SET ( netCDF_SO_VERSION 7 )
2014-02-20 07:32:26 +08:00
SET ( PACKAGE_VERSION ${ VERSION } )
2014-04-22 06:11:48 +08:00
# Get system configuration, Use it to determine osname, os release, cpu. These
# will be used when committing to CDash.
2013-03-12 05:13:51 +08:00
find_program ( UNAME NAMES uname )
2013-03-20 06:40:15 +08:00
IF ( UNAME )
2014-04-22 01:15:33 +08:00
macro ( getuname name flag )
2014-03-07 23:46:26 +08:00
exec_program ( "${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}" )
2014-04-22 01:15:33 +08:00
endmacro ( getuname )
getuname ( osname -s )
getuname ( osrel -r )
getuname ( cpu -m )
set ( BUILDNAME "${osname}-${osrel}-${cpu}" CACHE STRING "Build name variable for CDash" )
2013-03-20 06:40:15 +08:00
ENDIF ( )
2013-09-17 01:45:34 +08:00
2014-02-05 07:13:18 +08:00
# Determine if DOXYGEN and DOT are available. These will be used
# when building the documentation.
2014-05-30 04:07:45 +08:00
2014-05-22 04:13:23 +08:00
FIND_PACKAGE ( Doxygen )
2014-02-05 07:13:18 +08:00
FIND_PROGRAM ( NC_DOT NAMES dot )
2013-08-14 00:00:22 +08:00
# For CMAKE_INSTALL_LIBDIR
INCLUDE ( GNUInstallDirs )
2012-10-03 04:56:46 +08:00
IF ( MSVC )
2014-04-22 01:15:33 +08:00
SET ( GLOBAL PROPERTY USE_FOLDERS ON )
2012-10-03 04:56:46 +08:00
ENDIF ( )
#Add custom CMake Module
2014-04-22 06:11:48 +08:00
SET ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/"
2014-04-22 01:15:33 +08:00
C A C H E I N T E R N A L " L o c a t i o n o f o u r c u s t o m C M a k e m o d u l e s . " )
2012-10-03 04:56:46 +08:00
2013-10-01 05:51:34 +08:00
# auto-configure style checks, other CMake modules.
2014-04-22 06:11:48 +08:00
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/CheckCSourceCompiles.cmake )
INCLUDE ( ${ CMAKE_ROOT } /Modules/TestBigEndian.cmake )
INCLUDE ( ${ CMAKE_ROOT } /Modules/CheckSymbolExists.cmake )
INCLUDE ( ${ CMAKE_ROOT } /Modules/GetPrerequisites.cmake )
2014-03-12 04:31:41 +08:00
2014-04-03 04:26:42 +08:00
INCLUDE ( CheckCCompilerFlag )
2013-03-26 04:28:40 +08:00
FIND_PACKAGE ( PkgConfig QUIET )
2013-03-28 03:15:00 +08:00
2014-04-03 04:26:42 +08:00
# A macro to check if a C linker supports a particular flag.
MACRO ( CHECK_C_LINKER_FLAG M_FLAG M_RESULT )
SET ( T_REQ_FLAG "${CMAKE_REQUIRED_FLAGS}" )
SET ( CMAKE_REQUIRED_FLAGS "${M_FLAG}" )
CHECK_C_SOURCE_COMPILES ( "int main() {return 0;}" ${ M_RESULT } )
SET ( CMAKE_REQUIRED_FLAGS "${T_REQ_FLAG}" )
ENDMACRO ( )
2013-10-01 05:51:34 +08:00
# Enable 'dist and distcheck'.
# File adapted from http://ensc.de/cmake/FindMakeDist.cmake
2013-03-28 03:15:00 +08:00
FIND_PACKAGE ( MakeDist )
2013-10-01 05:51:34 +08:00
# End 'enable dist and distcheck'
# Set the build type.
2014-04-22 06:11:48 +08:00
IF ( NOT CMAKE_BUILD_TYPE )
2014-03-07 23:46:26 +08:00
SET ( CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None, Debug, Release."
2014-04-22 01:15:33 +08:00
F O R C E )
2013-10-01 05:51:34 +08:00
ENDIF ( )
2014-04-03 04:26:42 +08:00
# Set build type uppercase
STRING ( TOUPPER ${ CMAKE_BUILD_TYPE } CMAKE_BUILD_TYPE )
2014-06-03 05:14:27 +08:00
# Determine the configure date.
EXECUTE_PROCESS ( COMMAND date
O U T P U T _ V A R I A B L E C O N F I G _ D A T E )
2013-10-01 05:51:34 +08:00
################################
# End Project Properties
################################
################################
# Set CTest Properties
################################
ENABLE_TESTING ( )
INCLUDE ( CTest )
# Copy the CTest customization file into binary directory, as required.
FILE ( COPY ${ CMAKE_SOURCE_DIR } /CTestCustom.cmake DESTINATION ${ CMAKE_BINARY_DIR } )
# Set Memory test program for non-MSVC based builds.
# Assume valgrind for now.
IF ( NOT MSVC )
2014-04-22 06:11:48 +08:00
SET ( CTEST_MEMORYCHECK_COMMAND valgrind CACHE STRING "" )
2013-10-01 05:51:34 +08:00
ENDIF ( )
# Set variable to define the build type.
INCLUDE ( GenerateExportHeader )
################################
# End CTest Properties
################################
2013-05-25 05:19:07 +08:00
2013-03-28 03:15:00 +08:00
2013-10-01 05:51:34 +08:00
################################
# Compiler Configuration
################################
2014-01-25 02:10:41 +08:00
# Default building shared libraries.
2013-10-01 05:51:34 +08:00
OPTION ( BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON )
2014-04-22 06:11:48 +08:00
SET ( LIB_TYPE STATIC )
IF ( BUILD_SHARED_LIBS )
2014-03-07 23:46:26 +08:00
SET ( LIB_TYPE SHARED )
IF ( CMAKE_COMPILER_IS_GNUCC OR APPLE )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
2014-04-03 04:26:42 +08:00
SET ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIC" )
2014-03-07 23:46:26 +08:00
ENDIF ( )
2013-10-01 05:51:34 +08:00
ENDIF ( )
2014-01-25 02:10:41 +08:00
# Set some default linux gcc & apple compiler options for
# debug builds.
2013-10-01 05:51:34 +08:00
IF ( CMAKE_COMPILER_IS_GNUCC OR APPLE )
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_COVERAGE_TESTS "Enable compiler flags needed to perform coverage tests." OFF )
OPTION ( ENABLE_CONVERSION_WARNINGS "Enable warnings for implicit conversion from 64 to 32-bit datatypes." ON )
OPTION ( ENABLE_USED_VAR_PAR_WARNINGS "Enable warnings for unused parameters and variables. Creates very noisy output." OFF )
OPTION ( ENABLE_LARGE_FILE_TESTS "Enable large file tests." OFF )
2014-03-07 23:40:50 +08:00
2014-01-25 02:10:41 +08:00
# Debugging flags
2014-03-20 03:56:09 +08:00
SET ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall" )
2013-10-01 05:51:34 +08:00
2014-05-21 05:31:08 +08:00
# Check to see if -Wl,--no-undefined is supported.
CHECK_C_LINKER_FLAG ( "-Wl,--no-undefined" LIBTOOL_HAS_NO_UNDEFINED )
2014-04-22 06:11:48 +08:00
2014-04-03 04:26:42 +08:00
IF ( LIBTOOL_HAS_NO_UNDEFINED )
2014-05-21 05:31:08 +08:00
SET ( CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-undefined" )
2014-04-03 04:26:42 +08:00
ENDIF ( )
SET ( CMAKE_REQUIRED_FLAGS "${TMP_CMAKE_REQUIRED_FLAGS}" )
2014-04-22 06:11:48 +08:00
2014-01-25 02:10:41 +08:00
# Coverage tests need to have optimization turned off.
2014-03-20 03:56:09 +08:00
IF ( ENABLE_COVERAGE_TESTS )
2014-01-25 02:10:41 +08:00
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage" )
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage" )
2014-03-07 23:40:50 +08:00
MESSAGE ( STATUS "Coverage Tests: On." )
2014-01-25 02:10:41 +08:00
ENDIF ( )
2014-04-22 06:11:48 +08:00
2014-03-20 03:56:09 +08:00
SET ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O2" )
2014-03-07 23:40:50 +08:00
2014-01-25 02:10:41 +08:00
# Unused var and parameter warnings create a lot of noise.
2014-03-07 23:40:50 +08:00
IF ( NOT ENABLE_UNUSED_VAR_PAR_WARNINGS )
2014-01-25 02:10:41 +08:00
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable -Wno-unused-parameter" )
ENDIF ( )
2014-03-07 23:40:50 +08:00
2014-01-25 02:10:41 +08:00
# Warnings for 64-to-32 bit conversions.
IF ( ENABLE_CONVERSION_WARNINGS )
2014-04-03 04:26:42 +08:00
CHECK_C_COMPILER_FLAG ( -Wconversion CC_HAS_WCONVERSION )
CHECK_C_COMPILER_FLAG ( -Wshorten-64-to-32 CC_HAS_SHORTEN_64_32 )
2014-04-22 06:11:48 +08:00
2014-04-03 04:26:42 +08:00
IF ( CC_HAS_SHORTEN_64_32 )
2014-03-20 03:56:09 +08:00
SET ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshorten-64-to-32" )
2014-04-03 04:26:42 +08:00
ENDIF ( )
IF ( CC_HAS_WCONVERSION )
2014-04-22 06:11:48 +08:00
SET ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wconversion" )
2014-04-03 04:26:42 +08:00
ENDIF ( )
2014-01-25 02:10:41 +08:00
ENDIF ( ENABLE_CONVERSION_WARNINGS )
ENDIF ( CMAKE_COMPILER_IS_GNUCC OR APPLE )
# End default linux gcc & apple compiler options.
2013-10-01 05:51:34 +08:00
ADD_DEFINITIONS ( )
2013-09-19 04:49:37 +08:00
# Supress CRT Warnings.
2012-11-08 01:34:05 +08:00
# Only necessary for Windows
IF ( MSVC )
2014-03-07 23:46:26 +08:00
ADD_DEFINITIONS ( -D_CRT_SECURE_NO_WARNINGS )
2012-12-14 06:09:41 +08:00
ENDIF ( )
2013-10-01 05:51:34 +08:00
################################
# End Compiler Configuration
################################
################################
# Define Utility Macros
################################
2013-05-25 05:19:07 +08:00
# Macro to append files to the EXTRA_DIST files.
SET ( EXTRA_DIST "" )
MACRO ( ADD_EXTRA_DIST files )
FOREACH ( F ${ files } )
SET ( EXTRA_DIST ${ EXTRA_DIST } ${ CMAKE_CURRENT_SOURCE_DIR } / ${ F } )
SET ( EXTRA_DIST ${ EXTRA_DIST } PARENT_SCOPE )
ENDFOREACH ( )
ENDMACRO ( )
2012-10-03 04:56:46 +08:00
# A basic script used to convert m4 files
2013-09-04 04:22:55 +08:00
FIND_PROGRAM ( NC_M4 NAMES m4 )
2012-10-03 04:56:46 +08:00
MACRO ( GEN_m4 filename )
2014-03-07 23:46:26 +08:00
IF ( NOT EXISTS ${ CMAKE_CURRENT_SOURCE_DIR } / ${ filename } .c )
2014-04-22 01:15:33 +08:00
ADD_CUSTOM_COMMAND (
O U T P U T $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { f i l e n a m e } . c
C O M M A N D $ { N C _ M 4 }
A R G S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { f i l e n a m e } . m 4 > $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { f i l e n a m e } . c
V E R B A T I M
)
2014-03-07 23:46:26 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
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 )
2014-03-07 23:46:26 +08:00
ADD_EXECUTABLE ( ${ prefix } _ ${ F } ${ F } .c )
TARGET_LINK_LIBRARIES ( ${ prefix } _ ${ F } netcdf )
IF ( MSVC )
SET_TARGET_PROPERTIES ( ${ prefix } _ ${ F }
P R O P E R T I E S L I N K _ F L A G S _ D E B U G " / N O D E F A U L T L I B : M S V C R T "
)
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 ( )
2013-02-13 06:22:54 +08:00
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 )
2014-03-07 23:46:26 +08:00
ADD_EXECUTABLE ( ${ prefix } _ ${ F } ${ F } .c )
TARGET_LINK_LIBRARIES ( ${ prefix } _ ${ F } netcdf )
IF ( MSVC )
SET_TARGET_PROPERTIES ( ${ prefix } _ ${ F }
P R O P E R T I E S L I N K _ F L A G S _ D E B U G " / N O D E F A U L T L I B : M S V C R T "
)
ENDIF ( )
ADD_TEST ( ${ prefix } _ ${ F } bash "-c" "TOPSRCDIR=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${prefix}_${F}" )
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.
2014-03-07 23:40:50 +08:00
MACRO ( build_bin_test F )
2014-03-07 23:46:26 +08:00
ADD_EXECUTABLE ( ${ F } ${ F } .c )
TARGET_LINK_LIBRARIES ( ${ F } netcdf )
IF ( MSVC )
SET_TARGET_PROPERTIES ( ${ F }
P R O P E R T I E S L I N K _ F L A G S _ D E B U G " / N O D E F A U L T L I B : M S V C R T "
2014-04-22 01:15:33 +08:00
)
2014-03-07 23:46:26 +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 )
2014-03-07 23:46:26 +08:00
build_bin_test ( ${ F } )
ADD_TEST ( ${ F } ${ EXECUTABLE_OUTPUT_PATH } / ${ F } )
IF ( MSVC )
SET_PROPERTY ( TEST ${ F } PROPERTY FOLDER "tests/" )
ENDIF ( )
2013-02-13 06:22:54 +08:00
ENDMACRO ( )
2013-03-12 05:13:51 +08:00
# Binary tests which are used by a script looking for a specific name.
MACRO ( build_bin_test_no_prefix F )
2014-03-07 23:46:26 +08:00
build_bin_test ( ${ F } )
ADD_TEST ( ${ F } ${ EXECUTABLE_OUTPUT_PATH } / ${ F } )
IF ( MSVC )
SET_PROPERTY ( TEST ${ F } PROPERTY FOLDER "tests/" )
ENDIF ( )
2013-03-12 05:13:51 +08:00
ENDMACRO ( )
2012-10-03 04:56:46 +08:00
MACRO ( add_bin_test prefix F )
2014-03-07 23:46:26 +08:00
ADD_EXECUTABLE ( ${ prefix } _ ${ F } ${ F } .c )
TARGET_LINK_LIBRARIES ( ${ prefix } _ ${ F } netcdf )
IF ( MSVC )
SET_TARGET_PROPERTIES ( ${ prefix } _ ${ F }
P R O P E R T I E S L I N K _ F L A G S _ D E B U G " / N O D E F A U L T L I B : M S V C R T "
)
ENDIF ( )
ADD_TEST ( ${ prefix } _ ${ F } ${ EXECUTABLE_OUTPUT_PATH } / ${ prefix } _ ${ F } )
IF ( MSVC )
SET_PROPERTY ( TEST ${ prefix } _ ${ F } PROPERTY FOLDER "tests/" )
ENDIF ( )
2012-10-03 04:56:46 +08:00
ENDMACRO ( )
2014-03-18 02:18:39 +08:00
# A cmake script to print out information at the end of the configuration step.
2012-10-03 04:56:46 +08:00
MACRO ( print_conf_summary )
2014-03-07 23:46:26 +08:00
MESSAGE ( "" )
MESSAGE ( "" )
MESSAGE ( "Configuration Summary:" )
MESSAGE ( "" )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "Building Shared Libraries: ${BUILD_SHARED_LIBS}" )
MESSAGE ( STATUS "Building netCDF-4: ${ENABLE_NETCDF_4}" )
MESSAGE ( STATUS "Building DAP Support: ${ENABLE_DAP}" )
MESSAGE ( STATUS "Building Utilities: ${BUILD_UTILITIES}" )
2014-03-07 23:46:26 +08:00
IF ( CMAKE_PREFIX_PATH )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "CMake Prefix Path: ${CMAKE_PREFIX_PATH}" )
2014-03-07 23:46:26 +08:00
ENDIF ( )
MESSAGE ( "" )
2014-03-18 02:18:39 +08:00
IF ( ${ STATUS_PNETCDF } OR ${ STATUS_PARALLEL } )
MESSAGE ( "Building Parallel NetCDF" )
2014-04-24 01:17:03 +08:00
MESSAGE ( STATUS "Using pnetcdf: ${STATUS_PNETCDF}" )
MESSAGE ( STATUS "Using Parallel IO: ${STATUS_PARALLEL}" )
2014-03-08 04:58:09 +08:00
MESSAGE ( "" )
ENDIF ( )
2014-03-18 02:18:39 +08:00
2014-05-22 04:13:23 +08:00
MESSAGE ( "Tests Enabled: ${ENABLE_TESTS}" )
2014-03-18 02:18:39 +08:00
IF ( ENABLE_TESTS )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "DAP Remote Tests: ${ENABLE_DAP_REMOTE_TESTS}" )
MESSAGE ( STATUS "DAP AUTH Tests: ${ENABLE_DAP_AUTH_TESTS}" )
MESSAGE ( STATUS "Extra Tests: ${ENABLE_EXTRA_TESTS}" )
MESSAGE ( STATUS "Coverage Tests: ${ENABLE_COVERAGE_TESTS}" )
MESSAGE ( STATUS "Parallel Tests: ${ENABLE_PARALLEL_TESTS}" )
MESSAGE ( STATUS "Large File Tests: ${ENABLE_LARGE_FILE_TESTS}" )
2014-03-18 02:18:39 +08:00
ENDIF ( )
2014-04-22 06:11:48 +08:00
2014-03-18 02:18:39 +08:00
MESSAGE ( "" )
2014-03-08 04:58:09 +08:00
MESSAGE ( "Compiler:" )
2014-03-07 23:46:26 +08:00
MESSAGE ( "" )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "Build Type: ${CMAKE_BUILD_TYPE}" )
MESSAGE ( STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}" )
MESSAGE ( STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}" )
2014-03-20 03:56:09 +08:00
IF ( "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}" )
2014-03-20 03:56:09 +08:00
ENDIF ( )
IF ( "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE" )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}" )
2014-03-20 03:56:09 +08:00
ENDIF ( )
2014-03-07 23:46:26 +08:00
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "Linking against: ${ALL_TLL_LIBS}" )
2012-10-03 04:56:46 +08:00
2014-04-22 06:11:48 +08:00
MESSAGE ( "" )
2012-10-03 04:56:46 +08:00
ENDMACRO ( )
2014-04-22 06:11:48 +08:00
2012-10-03 04:56:46 +08:00
# Shell script Macro
MACRO ( add_sh_test prefix F )
2014-03-07 23:46:26 +08:00
IF ( NOT MSVC )
ADD_TEST ( ${ prefix } _ ${ F } bash "-c" "export srcdir=${CMAKE_CURRENT_SOURCE_DIR};export TOPSRCDIR=${CMAKE_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}/${F}.sh" )
ENDIF ( )
2012-10-03 04:56:46 +08:00
ENDMACRO ( )
2013-09-19 04:49:37 +08:00
# Macro for replacing '/MD' with '/MT'.
# Used only on Windows, /MD tells VS to use the shared
# CRT libs, MT tells VS to use the static CRT libs.
#
# Taken From:
2014-03-07 23:46:26 +08:00
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
2013-09-19 04:49:37 +08:00
#
2014-03-07 23:40:50 +08:00
MACRO ( specify_static_crt_flag )
SET ( vars
2013-09-19 04:49:37 +08:00
C M A K E _ C _ F L A G S
C M A K E _ C _ F L A G S _ D E B U G
C M A K E _ C _ F L A G S _ M I N S I Z E R E L
C M A K E _ C _ F L A G S _ R E L W I T H D E B I N F O
C M A K E _ C X X _ F L A G S C M A K E _ C X X _ F L A G S _ D E B U G
C M A K E _ C X X _ F L A G S _ R E L E A S E C M A K E _ C X X _ F L A G S _ M I N S I Z E R E L
C M A K E _ C X X _ F L A G S _ R E L W I T H D E B I N F O )
2014-03-07 23:40:50 +08:00
2013-09-19 04:49:37 +08:00
FOREACH ( flag_var ${ vars } )
IF ( ${ flag_var } MATCHES "/MD" )
STRING ( REGEX REPLACE "/MD" "/MT" ${ flag_var } "${${flag_var}}" )
ENDIF ( )
2014-03-07 23:40:50 +08:00
ENDFOREACH ( )
2013-09-19 04:49:37 +08:00
FOREACH ( flag_var ${ vars } )
MESSAGE ( STATUS " '${flag_var}': ${${flag_var}}" )
ENDFOREACH ( )
MESSAGE ( STATUS "" )
ENDMACRO ( )
2014-06-03 05:14:27 +08:00
# A function used to create autotools-style 'yes/no' definitions.
# If a variable is set, it 'yes' is returned. Otherwise, 'no' is
# returned.
FUNCTION ( is_enabled feature ret_val )
IF ( ${ feature } )
SET ( ${ ret_val } "yes" PARENT_SCOPE )
ELSE ( )
SET ( ${ ret_val } "no" PARENT_SCOPE )
ENDIF ( ${ feature } )
ENDFUNCTION ( )
# A function used to create autotools-style 'yes/no' definitions.
# If a variable is set, it 'yes' is returned. Otherwise, 'no' is
# returned.
FUNCTION ( is_disabled feature ret_val )
IF ( ${ feature } )
SET ( ${ ret_val } "no" PARENT_SCOPE )
ELSE ( )
SET ( ${ ret_val } "yes" PARENT_SCOPE )
ENDIF ( ${ feature } )
ENDFUNCTION ( )
2013-10-01 05:51:34 +08:00
################################
# End Macro Definitions
################################
2013-02-27 06:11:09 +08:00
##
# Configuration for post-install RPath
# Adapted from http://www.cmake.org/Wiki/CMake_RPATH_handling
##
IF ( NOT MSVC )
2014-03-07 23:46:26 +08:00
# use, i.e. don't skip the full RPATH for the build tree
SET ( CMAKE_SKIP_BUILD_RPATH FALSE )
# when building, don't use the install RPATH already
# (but later on when installing)
SET ( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
# Stanza for Apple RPATH.
# See: http://www.cmake.org/pipermail/cmake/2011-April/043826.html
#
IF ( APPLE )
SET ( CMAKE_INSTALL_NAME_DIR ${ CMAKE_INSTALL_PREFIX } / ${ CMAKE_INSTALL_LIBDIR } )
ENDIF ( APPLE )
SET ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
# the RPATH to be used when installing, but only if it's not a system directory
LIST ( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir )
IF ( "${isSystemDir}" STREQUAL "-1" )
SET ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
ENDIF ( "${isSystemDir}" STREQUAL "-1" )
2013-02-27 06:11:09 +08:00
ENDIF ( )
##
# End configuration for post-install RPath
##
2013-10-01 05:51:34 +08:00
################################
2012-10-03 04:56:46 +08:00
# Option checks
2013-10-01 05:51:34 +08:00
################################
SET ( CMAKE_INCLUDE_CURRENT_DIR ON )
2012-10-03 04:56:46 +08:00
# HDF5 cache variables.
2014-04-22 06:11:48 +08:00
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." )
SET ( NETCDF_LIB_NAME "" CACHE STRING "Default name of the netcdf library." )
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 "" )
2014-03-07 23:46:26 +08:00
SET ( MOD_NETCDF_NAME ON )
2012-11-01 06:17:33 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Set the appropriate compiler/architecture for universal OSX binaries.
IF ( ${ CMAKE_SYSTEM_NAME } EQUAL "Darwin" )
2014-03-07 23:46:26 +08:00
SET ( CMAKE_OSX_ARCHITECTURES i386;x86_64 )
2012-10-03 04:56:46 +08:00
ENDIF ( ${ CMAKE_SYSTEM_NAME } EQUAL "Darwin" )
2013-09-19 04:49:37 +08:00
# Option to use Static Runtimes in MSVC
IF ( MSVC )
OPTION ( NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF )
IF ( NC_USE_STATIC_CRT )
SET ( USE_STATIC_CRT ON )
specify_static_crt_flag ( )
ENDIF ( )
ENDIF ( )
2013-02-20 07:29:41 +08:00
# Option to build netCDF Version 2
2014-04-04 00:45:22 +08:00
OPTION ( ENABLE_V2_API "Build netCDF Version 2." ON )
2014-04-04 07:09:38 +08:00
SET ( BUILD_V2 ${ ENABLE_V2_API } )
2014-04-04 00:45:22 +08:00
IF ( NOT ENABLE_V2_API )
2014-04-04 07:09:38 +08:00
SET ( NO_NETCDF_2 ON )
2014-04-04 00:45:22 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Option to build utilities
2014-04-22 06:11:48 +08:00
OPTION ( BUILD_UTILITIES "Build ncgen, ncgen3, ncdump." ON )
2014-03-07 23:40:50 +08:00
2012-10-03 04:56:46 +08:00
# Option to use MMAP
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_MMAP "Use MMAP." OFF )
2013-02-15 04:24:02 +08:00
IF ( ENABLE_MMAP )
2014-03-07 23:46:26 +08:00
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 ( )
2013-02-15 04:24:02 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Option to use examples.
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_EXAMPLES "Build Examples" ON )
2012-10-03 04:56:46 +08:00
# Option to use Diskless
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_DISKLESS "Build Diskless." ON )
2012-10-03 04:56:46 +08:00
IF ( ENABLE_DISKLESS )
2014-03-07 23:46:26 +08:00
SET ( BUILD_DISKLESS ON )
SET ( USE_DISKLESS ON )
2012-10-03 04:56:46 +08:00
ENDIF ( )
2014-03-07 23:40:50 +08:00
# Option Logging, only valid for netcdf4.
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_LOGGING "Enable Logging." OFF )
2012-12-06 02:35:42 +08:00
IF ( ENABLE_LOGGING )
2014-03-07 23:46:26 +08:00
SET ( LOGGING ON )
2012-12-06 02:35:42 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Option to use HDF4
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_HDF4 "Build netCDF-4 with HDF5 read capability(HDF4, HDF5 and Zlib required)." OFF )
IF ( ENABLE_HDF4 )
2014-04-22 01:15:33 +08:00
SET ( USE_HDF4 ON )
# Check for include files, libraries.
FIND_PATH ( MFHDF_H_INCLUDE_DIR mfhdf.h )
IF ( NOT MFHDF_H_INCLUDE_DIR )
MESSAGE ( FATAL_ERROR "HDF4 Support specified, cannot find file mfhdf.h" )
ELSE ( )
SET ( HAVE_MFHDF_H ON CACHE BOOL "" )
INCLUDE_DIRECTORIES ( ${ MFHDF_H_INCLUDE_DIR } )
ENDIF ( )
FIND_LIBRARY ( HDF4_DF_LIB NAMES df libdf hdf )
IF ( NOT HDF4_DF_LIB )
MESSAGE ( FATAL_ERROR "Can't find or link to the hdf4 df library." )
ENDIF ( )
FIND_LIBRARY ( HDF4_MFHDF_LIB NAMES mfhdf libmfhdf )
IF ( NOT HDF4_MFHDF_LIB )
MESSAGE ( FATAL_ERROR "Can't find or link to the hdf4 mfhdf library." )
ENDIF ( )
SET ( HDF4_LIBRARIES ${ HDF4_MFHDF_LIB } ${ HDF4_DF_LIB } )
# End include files, libraries.
MESSAGE ( STATUS "HDF4 libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}" )
MESSAGE ( STATUS "Seeking HDF4 jpeg dependency." )
# Look for the jpeglib.h header file.
FIND_PATH ( JPEGLIB_H_INCLUDE_DIR jpeglib.h )
IF ( NOT JPEGLIB_H_INCLUDE_DIR )
MESSAGE ( FATAL_ERROR "HDF4 Support enabled but cannot find jpeglib.h" )
ELSE ( )
SET ( HAVE_JPEGLIB_H ON CACHE BOOL "" )
INCLUDE_DIRECTORIES ( ${ JPEGLIB_H_INCLUDE_DIR } )
ENDIF ( )
FIND_LIBRARY ( JPEG_LIB NAMES jpeg libjpeg )
IF ( NOT JPEG_LIB )
MESSAGE ( FATAL_ERROR "HDF4 Support enabled but cannot find libjpeg" )
ENDIF ( )
SET ( HDF4_LIBRARIES ${ JPEG_LIB } ${ HDF4_LIBRARIES } )
MESSAGE ( STATUS "Found JPEG libraries: ${JPEG_LIB}" )
# Option to enable HDF4 file tests.
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_HDF4_FILE_TESTS "Run HDF4 file tests. This fetches sample HDF4 files from the Unidata ftp site to test with(requires wget)." ON )
2014-04-22 01:15:33 +08:00
IF ( ENABLE_HDF4_FILE_TESTS )
FIND_PROGRAM ( PROG_WGET NAMES wget )
IF ( PROG_WGET )
SET ( USE_HDF4_FILE_TESTS ON )
ELSE ( )
MESSAGE ( STATUS "Unable to locate 'wget'. Disabling hdf4 file tests." )
SET ( USE_HDF4_FILE_TESTS OFF )
ENDIF ( )
ENDIF ( )
2014-04-22 06:11:48 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Option to Build DLL
IF ( WIN32 )
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_DLL "Build a Windows DLL." ${ BUILD_SHARED_LIBS } )
IF ( ENABLE_DLL )
2014-04-22 01:15:33 +08:00
SET ( BUILD_DLL ON CACHE BOOL "" )
2014-03-07 23:46:26 +08:00
ADD_DEFINITIONS ( -DDLL_NETCDF )
2014-04-22 01:15:33 +08:00
ADD_DEFINITIONS ( -DDLL_EXPORT )
2014-04-22 06:11:48 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
ENDIF ( )
# Did the user specify a default minimum blocksize for posixio?
2014-04-22 06:11:48 +08:00
SET ( NCIO_MINBLOCKSIZE 256 CACHE STRING "Minimum I/O Blocksize for netCDF classic and 64-bit offset format files." )
2012-10-03 04:56:46 +08:00
2013-02-20 07:29:41 +08:00
# Build netCDF4
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_NETCDF_4 "Enable netCDF-4" ON )
2012-10-03 04:56:46 +08:00
IF ( ENABLE_NETCDF_4 )
2014-03-07 23:46:26 +08:00
SET ( USE_NETCDF4 ON CACHE BOOL "" )
SET ( ENABLE_NETCDF_4 ON CACHE BOOL "" )
SET ( ENABLE_NETCDF4 ON CACHE BOOL "" )
2012-10-03 04:56:46 +08:00
ENDIF ( )
# Option for building RPC
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_RPC OFF "Enable RPC Client and Server." )
2012-10-03 04:56:46 +08:00
IF ( ENABLE_RPC )
2014-03-07 23:46:26 +08:00
SET ( BUILD_RPC ON CACHE BOOL "" )
2012-10-03 04:56:46 +08:00
ENDIF ( )
# Option to Enable HDF5
2014-04-22 06:11:48 +08:00
OPTION ( USE_SZIP "Use SZip" OFF )
OPTION ( USE_HDF5 "Use HDF5." ${ ENABLE_NETCDF_4 } )
2013-06-11 05:48:11 +08:00
2014-04-22 06:11:48 +08:00
IF ( USE_HDF5 OR ENABLE_NETCDF_4 )
2012-10-03 04:56:46 +08:00
SET ( USE_HDF5 ON )
SET ( USE_NETCDF4 ON )
2013-05-02 07:55:24 +08:00
# Accomodate developers who have hdf5 libraries and
# headers on their system, but do not have a the hdf
# .cmake files. If this is the case, they should
# specify HDF5_HL_LIB, HDF5_LIB, HDF5_INCLUDE_DIR manually.
IF ( HDF5_LIB AND HDF5_HL_LIB AND HDF5_INCLUDE_DIR )
2014-03-07 23:46:26 +08:00
SET ( HDF5_LIBRARIES ${ HDF5_LIB } ${ HDF5_HL_LIB } )
2014-03-18 02:18:39 +08:00
SET ( HDF5_C_LIBRARY ${ HDF5_LIB } )
SET ( HDF5_HL_LIBRARY ${ HDF5_HL_LIB } )
MESSAGE ( STATUS "Using HDF5 Library: ${HDF5_LIB}" )
MESSAGE ( STATUS "Using HDF5_HL LIbrary: ${HDF5_HL_LIB}" )
2013-05-02 07:55:24 +08:00
ELSE ( )
2013-06-21 04:38:23 +08:00
IF ( MSVC )
FIND_PACKAGE ( HDF5 COMPONENTS C HL NO_MODULE REQUIRED )
ELSE ( )
FIND_PACKAGE ( HDF5 COMPONENTS C HL REQUIRED )
ENDIF ( )
2013-03-26 04:28:40 +08:00
ENDIF ( )
2014-05-10 06:44:51 +08:00
2014-03-18 05:33:09 +08:00
IF ( NOT MSVC )
# Depending on the install, either HDF5_hdf_library or
2014-04-22 01:15:33 +08:00
# HDF5_C_LIBRARY may be defined. We must check for either.
IF ( HDF5_C_LIBRARY )
SET ( HDF5_hdf5_LIBRARY ${ HDF5_C_LIBRARY } )
ENDIF ( )
2014-04-22 06:11:48 +08:00
2014-04-22 01:15:33 +08:00
# Find out if HDF5 was built with parallel support.
# Do that by checking for the targets H5Pget_fapl_mpiposx and
# H5Pget_fapl_mpio in ${HDF5_LIB}.
CHECK_LIBRARY_EXISTS ( ${ HDF5_hdf5_LIBRARY } H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX )
CHECK_LIBRARY_EXISTS ( ${ HDF5_hdf5_LIBRARY } H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO )
2014-04-22 06:11:48 +08:00
2014-04-22 01:15:33 +08:00
IF ( HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO )
SET ( HDF5_IS_PARALLEL ON )
ENDIF ( )
2014-04-22 06:11:48 +08:00
2014-04-22 01:15:33 +08:00
IF ( HDF5_IS_PARALLEL_MPIO )
SET ( USE_PARALLEL_MPIO ON )
ENDIF ( )
2014-04-22 06:11:48 +08:00
2014-04-22 01:15:33 +08:00
IF ( HDF5_IS_PARALLEL_MPIPOSIX )
SET ( USE_PARALLEL_POSIX ON )
ENDIF ( )
2014-05-06 05:37:47 +08:00
OPTION ( ENABLE_DYNAMIC_LOADING "Enable Dynamic Loading" ON )
IF ( ENABLE_DYNAMIC_LOADING )
SET ( USE_LIBDL ON CACHE BOOL "" )
ENDIF ( )
2014-03-18 05:33:09 +08:00
ENDIF ( NOT MSVC )
2014-03-09 22:16:15 +08:00
# Assert HDF5 version.
SET ( HDF5_VERSION_REQUIRED 1.8.6 )
execute_process ( COMMAND sh -c "h5cc -showconfig | grep -i \" HDF5 version\ " | sed 's/^.*[^0-9]\\([0-9]*\\.[0-9]*\\.[0-9]*\\).*$/\\1/'"
2014-04-22 01:15:33 +08:00
O U T P U T _ V A R I A B L E H D F 5 _ V E R S I O N
E R R O R _ Q U I E T
)
2014-05-10 06:44:51 +08:00
2014-03-13 02:56:21 +08:00
# It cannot be assumed that libhdf5.settings exists. If it doesn't,
# the call to h5cc will have failed. At this point we will have to
# trust the user that they have configured their system properly.
2014-04-22 01:15:33 +08:00
IF ( "${HDF5_VERSION}" STREQUAL "" )
2014-03-13 02:56:21 +08:00
MESSAGE ( STATUS "Unable to determine hdf5 version. NetCDF requires at least version ${HDF5_VERSION_REQUIRED}" )
ELSE ( )
2014-04-22 06:11:48 +08:00
IF ( ${ HDF5_VERSION } VERSION_LESS ${ HDF5_VERSION_REQUIRED } )
2014-03-13 02:56:21 +08:00
MESSAGE ( FATAL_ERROR
2014-05-10 06:44:51 +08:00
" n e t C D F r e q u i r e s a t l e a s t H D F 5 $ { H D F 5 _ V E R S I O N _ R E Q U I R E D } . F o u n d $ { H D F 5 _ V E R S I O N } . " )
2014-03-13 02:56:21 +08:00
ENDIF ( )
2014-03-09 22:16:15 +08:00
ENDIF ( )
2014-05-10 06:44:51 +08:00
INCLUDE_DIRECTORIES ( ${ HDF5_INCLUDE_DIR } )
2014-03-07 23:40:50 +08:00
2013-06-11 05:48:11 +08:00
# Starting with hdf5 1.8.11, dynamic loading is an option.
# In case hdf5 has a dependency on libdl, the user must specify
# -DENABLE_DYNAMIC_LOADING=ON when configuring netcdf.
IF ( USE_LIBDL )
FIND_LIBRARY ( LIBDL NAMES dl dld )
FIND_PATH ( LIBDL_INCLUDE_DIR dlfcn.h )
IF ( NOT LIBDL )
MESSAGE ( ERROR "Cannot find libdl, but dynamic loading was specified." )
ENDIF ( )
IF ( NOT LIBDL_INCLUDE_DIR )
MESSAGE ( ERROR "Cannot find dlfcn.h, but dynamic loading was specified." )
ENDIF ( )
MESSAGE ( STATUS "Found libdl: ${LIBDL}" )
SET ( HAVE_LIBDL ON )
INCLUDE_DIRECTORIES ( ${ LIBDL_INCLUDE_DIR } )
ENDIF ( )
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 )
2014-04-22 01:15:33 +08:00
FIND_PACKAGE ( SZIP NO_MODULE )
INCLUDE_DIRECTORIES ( ${ SZIP_INCLUDE_DIR } )
2012-10-03 04:56:46 +08:00
ENDIF ( )
2014-03-07 23:40:50 +08:00
2013-08-29 02:57:07 +08:00
SET ( H5_USE_16_API 1 )
2014-04-22 06:11:48 +08:00
OPTION ( NC_ENABLE_HDF_16_API "Enable HDF5 1.6.x Compatibility(Required)" ON )
2013-08-29 02:57:07 +08:00
IF ( NOT NC_ENABLE_HDF_16_API )
SET ( H5_USE_16_API 0 )
ENDIF ( )
2014-03-07 23:40:50 +08:00
2012-10-03 04:56:46 +08:00
# Check for ZLib, but only if using HDF5.
FIND_PACKAGE ( ZLIB )
IF ( NOT ZLIB_LIBRARY )
2014-04-22 01:15:33 +08:00
MESSAGE ( FATAL_ERROR "HDF5 Support specified, cannot find ZLib." )
2012-10-03 04:56:46 +08:00
ENDIF ( )
SET ( USE_ZLIB ON )
INCLUDE_DIRECTORIES ( ${ ZLIB_INCLUDE_DIRS } )
2014-04-22 06:11:48 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Option to Build DAP Client
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_DAP "Enable DAP Client." ON )
IF ( ENABLE_DAP )
2014-03-07 23:46:26 +08:00
SET ( USE_DAP ON )
FIND_PACKAGE ( CURL )
IF ( NOT CURL_LIBRARY )
MESSAGE ( FATAL_ERROR "DAP Support specified, CURL libraries are not found." )
ENDIF ( )
2014-03-12 04:31:41 +08:00
2014-03-19 02:58:34 +08:00
ADD_DEFINITIONS ( -DCURL_STATICLIB=1 )
INCLUDE_DIRECTORIES ( ${ CURL_INCLUDE_DIRS } )
2014-03-18 05:57:44 +08:00
# Check to see if CURLOPT_USERNAME is defined. It is present starting version 7.19.1
CHECK_C_SOURCE_COMPILES ( "
2014-04-22 06:11:48 +08:00
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ U S E R N A M E ; } " H A V E _ C U R L O P T _ U S E R N A M E )
2014-03-18 05:57:44 +08:00
2014-05-10 06:44:51 +08:00
# Check to see if CURLOPT_PASSWORD is defined. It is present starting version 7.19.1
CHECK_C_SOURCE_COMPILES ( "
2014-04-22 06:11:48 +08:00
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ P A S S W O R D ; } " H A V E _ C U R L O P T _ P A S S W O R D )
2014-03-12 04:31:41 +08:00
2014-05-10 06:44:51 +08:00
# Check to see if CURLOPT_KEYPASSWD is defined. It is present starting version 7.16.4
CHECK_C_SOURCE_COMPILES ( "
2014-04-22 06:11:48 +08:00
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L O P T _ K E Y P A S S W D ; } " H A V E _ C U R L O P T _ K E Y P A S S W D )
2014-03-12 04:31:41 +08:00
2014-05-10 06:44:51 +08:00
# Check to see if CURLINFO_RESPONSE_CODE is defined. It showed up in curl 7.10.7
CHECK_C_SOURCE_COMPILES ( "
2014-04-22 06:11:48 +08:00
#include <curl/curl.h>
i n t main ( ) { i n t x = C U R L I N F O _ R E S P O N S E _ C O D E ; } " H A V E _ C U R L I N F O _ R E S P O N S E _ C O D E )
2012-10-03 04:56:46 +08:00
ENDIF ( )
2014-04-22 06:11:48 +08:00
# Check to see if libtool supports
2014-04-03 04:26:42 +08:00
2014-02-05 07:13:18 +08:00
# Check for the math library so it can be explicitely linked.
IF ( NOT WIN32 )
2014-04-22 01:15:33 +08:00
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 ( )
2014-02-05 07:13:18 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# 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 )
2014-03-08 04:58:09 +08:00
IF ( ENABLE_DAP_REMOTE_TESTS )
2014-04-24 01:17:03 +08:00
OPTION ( ENABLE_DAP_AUTH_TESTS "Enable DAP remote authorization tests." OFF )
2014-03-08 04:58:09 +08:00
ENDIF ( )
2013-02-20 07:29:41 +08:00
# If netCDF4 and DAP, Option for DAP groups.
2014-03-07 23:40:50 +08:00
IF ( ENABLE_NETCDF_4 AND USE_DAP )
2014-04-22 01:15:33 +08:00
OPTION ( ENABLE_DAP_GROUPS "Whether netcdf4 group names should be enabled." ON )
2012-10-03 04:56:46 +08:00
ELSE ( )
2014-03-07 23:46:26 +08:00
SET ( ENABLE_DAP_GROUPS OFF CACHE BOOL "Whether netcdf4 group names should be enabled." )
2012-10-03 04:56:46 +08:00
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 )
2014-03-07 23:46:26 +08:00
SET ( EXTRA_TESTS ON )
2013-01-16 06:43:09 +08:00
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 )
2014-03-07 23:46:26 +08:00
OPTION ( ENABLE_XGETOPT "Enable bundled XGetOpt instead of external getopt()." ON )
IF ( ENABLE_XGETOPT )
SET ( USE_X_GETOPT ON CACHE BOOL "" )
ENDIF ( )
2012-10-03 04:56:46 +08:00
ENDIF ( )
SET ( MATH "" )
IF ( NOT WIN32 )
2014-03-07 23:46:26 +08:00
# 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 ( )
2012-10-03 04:56:46 +08:00
ENDIF ( )
# Enable Tests
#IF(NOT MSVC)
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_TESTS "Enable basic tests, run with 'make test'." ON )
2014-03-07 23:40:50 +08:00
IF ( ENABLE_TESTS )
2014-04-22 01:15:33 +08:00
SET ( BUILD_TESTSETS ON CACHE BOOL "" )
2014-04-16 08:16:08 +08:00
2014-04-22 01:15:33 +08:00
# Options for CTest-based tests, dashboards.
SET ( NC_CTEST_PROJECT_NAME "netcdf-c" CACHE STRING "Project Name for CTest-based testing purposes." )
SET ( NC_CTEST_DROP_SITE "my.cdash.org" CACHE STRING "Dashboard location for CTest-based testing purposes." )
SET ( NC_CTEST_DROP_LOC_PREFIX "" CACHE STRING "Prefix for Dashboard location on remote server when using CTest-based testing." )
2014-04-16 08:16:08 +08:00
2014-04-22 01:15:33 +08:00
# Create a CTestConfig file from the template.
CONFIGURE_FILE ( "${netCDF_SOURCE_DIR}/CTestConfig.cmake.in"
" $ { n e t C D F _ S O U R C E _ D I R } / C T e s t C o n f i g . c m a k e "
@ O N L Y
)
2014-04-16 08:16:08 +08:00
2012-12-21 05:50:45 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Enable Large file tests
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." )
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_FSYNC "Enable experimental fsync code." OFF )
2012-10-03 04:56:46 +08:00
IF ( ENABLE_FSYNC )
2014-03-07 23:46:26 +08:00
SET ( USE_FSYNC ON )
2012-10-03 04:56:46 +08:00
ENDIF ( )
2014-04-10 05:20:16 +08:00
# Temporary
OPTION ( ENABLE_JNA "Enable jna bug fix code." OFF )
IF ( ENABLE_JNA )
SET ( JNA ON )
ENDIF ( )
2012-12-21 05:50:45 +08:00
# Linux specific large file support flags.
# Modelled after check in CMakeLists.txt for hdf5.
2013-10-17 06:44:11 +08:00
OPTION ( ENABLE_LARGE_FILE_SUPPORT "Enable large file support." ON )
IF ( ENABLE_LARGE_FILE_SUPPORT )
IF ( MSVC )
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE" )
SET ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE" )
SET ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LARGEADDRESSAWARE" )
ELSE ( )
2012-12-21 05:50:45 +08:00
SET ( _FILE_OFFSET_BITS 64 )
SET ( _LARGEFILE64_SOURCE TRUE )
SET ( _LARGEFILE_SOURCE TRUE )
ENDIF ( )
ENDIF ( )
2014-04-22 06:11:48 +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 )
2014-04-22 06:11:48 +08:00
SET ( ENABLE_EXAMPLE_TESTS OFF )
2012-10-03 04:56:46 +08:00
ENDIF ( )
2013-10-01 05:51:34 +08:00
# Enable Parallel (different than pnetcdf).
2013-02-13 06:22:54 +08:00
SET ( STATUS_PARALLEL "OFF" )
2014-03-18 02:18:39 +08:00
OPTION ( ENABLE_PARALLEL "Build netCDF-4 with parallel IO" "${HDF5_IS_PARALLEL}" )
2013-03-09 07:36:40 +08:00
IF ( ENABLE_PARALLEL AND ENABLE_NETCDF_4 )
2014-03-07 23:46:26 +08:00
IF ( NOT HDF5_IS_PARALLEL )
SET ( USE_PARALLEL OFF CACHE BOOL "" )
MESSAGE ( STATUS "Cannot find HDF5 library built with parallel support. Disabling parallel build." )
2014-03-07 23:40:50 +08:00
ELSE ( )
2014-04-04 06:57:17 +08:00
SET ( USE_PARALLEL ON CACHE BOOL "" )
2014-03-07 23:46:26 +08:00
SET ( STATUS_PARALLEL "ON" )
ENDIF ( )
2013-02-13 06:22:54 +08:00
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" )
2013-03-16 04:31:07 +08:00
OPTION ( ENABLE_PNETCDF "Build with parallel I/O for classic and 64-bit offset files using parallel-netcdf." OFF )
2013-02-13 06:22:54 +08:00
IF ( ENABLE_PNETCDF )
2014-03-07 23:46:26 +08:00
# 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 )
2014-04-22 06:11:48 +08:00
MESSAGE ( STATUS "Cannot find pNetCDF library. Disabling pNetCDF support." )
2014-03-07 23:46:26 +08:00
SET ( USE_PNETCDF OFF CACHE BOOL "" )
ENDIF ( )
SET ( STATUS_PNETCDF "ON" )
INCLUDE_DIRECTORIES ( ${ PNETCDF_INCLUDE_DIR } )
SET ( HAVE_LIBPNETCDF ON )
2014-04-22 01:15:33 +08:00
# pnetcdf => parallel
SET ( STATUS_PARALLEL "ON" )
2013-02-07 07:09:19 +08:00
ENDIF ( )
2013-10-01 05:51:34 +08:00
# Enable Parallel Tests.
2014-04-22 06:11:48 +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 )
2014-03-07 23:46:26 +08:00
SET ( TEST_PARALLEL ON CACHE BOOL "" )
2013-02-13 06:22:54 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
2013-10-01 05:51:34 +08:00
# Determine whether or not to generate documentation.
2014-04-22 06:11:48 +08:00
OPTION ( ENABLE_DOXYGEN "Enable generation of doxygen." OFF )
2012-10-03 04:56:46 +08:00
IF ( ENABLE_DOXYGEN )
2014-05-22 04:13:23 +08:00
IF ( DOXYGEN_FOUND )
2014-02-05 07:13:18 +08:00
# Offer the option to build internal documentation.
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 ( )
2014-05-22 04:13:23 +08:00
2014-02-28 05:19:28 +08:00
# Option to turn on the TODO list in the doxygen-generated documentation.
2014-03-09 08:39:09 +08:00
OPTION ( ENABLE_DOXYGEN_TASKS "Turn on test, todo, bug lists in documentation. This is of interest to developers only." OFF )
IF ( ENABLE_DOXYGEN_TASKS )
SET ( SHOW_DOXYGEN_TAG_LIST YES CACHE STRING "" )
2014-05-22 04:13:23 +08:00
ELSE ( ENABLE_DOXYGEN_TASKS )
2014-02-28 05:19:28 +08:00
SET ( SHOW_DOXYGEN_TODO_LIST NO CACHE STRING "" )
2014-05-22 04:13:23 +08:00
ENDIF ( ENABLE_DOXYGEN_TASKS )
2014-02-28 05:19:28 +08:00
2014-02-05 07:13:18 +08:00
# Specify whether or not 'dot' was found on the system path.
IF ( NC_DOT )
SET ( HAVE_DOT YES CACHE STRING "" )
ELSE ( NC_DOT )
SET ( HAVE_DOT NO CACHE_STRING "" )
ENDIF ( NC_DOT )
2014-05-22 04:13:23 +08:00
ELSE ( DOXYGEN_FOUND )
2014-02-05 07:13:18 +08:00
MESSAGE ( STATUS "Unable to build internal documentation. Doxygen does not appear to be on your executable path. Install doxygen and configure the project again." )
2014-05-22 04:13:23 +08:00
SET ( ENABLE_DOXYGEN=OFF )
ENDIF ( DOXYGEN_FOUND )
2012-10-03 04:56:46 +08:00
ENDIF ( )
2013-10-10 06:02:13 +08:00
# By default, MSVC has a stack size of 1000000.
# Allow a user to override this.
IF ( MSVC )
2013-11-01 01:10:20 +08:00
SET ( NC_MSVC_STACK_SIZE 40000000 CACHE STRING "Default stack size for MSVC-based projects." )
2013-10-10 06:05:50 +08:00
# By default, CMake sets the stack to 1000000.
# Remove this limitation.
# See here for more details:
# http://www.cmake.org/pipermail/cmake/2009-April/028710.html
2013-10-10 06:02:13 +08:00
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:${NC_MSVC_STACK_SIZE}" )
SET ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /STACK:${NC_MSVC_STACK_SIZE}" )
SET ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /STACK:${NC_MSVC_STACK_SIZE}" )
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Set some of the options as advanced.
2013-08-23 05:26:42 +08:00
MARK_AS_ADVANCED ( ENABLE_INTERNAL_DOCS VALGRIND_TESTS ENABLE_PNETCDF 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 )
2013-10-01 05:51:34 +08:00
################################
# Option checks
################################
2012-10-03 04:56:46 +08:00
#####
# 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 )
2014-03-07 23:46:26 +08:00
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 )
2014-03-07 23:46:26 +08:00
SET ( YY_NO_UNISTD_H TRUE )
2013-01-16 06:43:09 +08:00
ENDIF ( )
2014-03-07 23:46:26 +08:00
CHECK_INCLUDE_FILE ( "alloca.h" HAVE_ALLOCA_H )
2013-03-28 03:15:00 +08:00
CHECK_INCLUDE_FILE ( "malloc.h" HAVE_MALLOC_H )
2014-03-07 23:46:26 +08:00
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 )
2014-03-07 23:46:26 +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 )
2012-10-03 04:56:46 +08:00
CHECK_INCLUDE_FILE ( "sys/param.h" HAVE_SYS_PARAM_H )
2014-03-07 23:46:26 +08:00
CHECK_INCLUDE_FILE ( "sys/stat.h" HAVE_SYS_STAT_H )
CHECK_INCLUDE_FILE ( "sys/time.h" HAVE_SYS_TIME_H )
2012-10-03 04:56:46 +08:00
CHECK_INCLUDE_FILE ( "sys/types.h" HAVE_SYS_TYPES_H )
2014-03-07 23:46:26 +08:00
CHECK_INCLUDE_FILE ( "sys/wait.h" HAVE_SYS_WAIT_H )
2012-10-03 04:56:46 +08:00
CHECK_INCLUDE_FILE ( "sys/resource.h" HAVE_SYS_RESOURCE_H )
2014-03-07 23:46:26 +08:00
CHECK_INCLUDE_FILE ( "fcntl.h" HAVE_FCNTL_H )
2012-10-03 04:56:46 +08:00
CHECK_INCLUDE_FILE ( "inttypes.h" HAVE_INTTYPES_H )
2014-03-07 23:46:26 +08:00
CHECK_INCLUDE_FILE ( "pstdint.h" HAVE_PSTDINT_H )
CHECK_INCLUDE_FILE ( "endian.h" HAVE_ENDIAN_H )
2013-04-03 06:09:31 +08:00
CHECK_INCLUDE_FILE ( "BaseTsd.h" HAVE_BASETSD_H )
2014-02-08 00:51:47 +08:00
CHECK_INCLUDE_FILE ( "stddef.h" HAVE_STDDEF_H )
2012-10-03 04:56:46 +08:00
# Type checks
2014-03-29 07:11:26 +08:00
CHECK_TYPE_SIZE ( "char" SIZEOF_CHAR )
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 )
CHECK_TYPE_SIZE ( "off64_t" SIZEOF_OFF64_T )
CHECK_TYPE_SIZE ( "short" SIZEOF_SHORT )
CHECK_TYPE_SIZE ( "size_t" SIZEOF_SIZE_T )
CHECK_TYPE_SIZE ( "ssize_t" SIZEOF_SSIZE_T )
2013-08-31 05:16:17 +08:00
# __int64 is used on Windows for large file support.
2014-03-29 07:11:26 +08:00
CHECK_TYPE_SIZE ( "__int64" SIZEOF___INT_64 )
CHECK_TYPE_SIZE ( "uchar" SIZEOF_UCHAR )
CHECK_TYPE_SIZE ( "int64_t" SIZEOF_INT64_T )
CHECK_TYPE_SIZE ( "uint64_t" SIZEOF_UINT64_T )
2012-10-03 04:56:46 +08:00
2013-08-31 05:25:28 +08:00
# On windows systems, we redefine off_t as __int64
# to enable LFS. This is true on 32 and 64 bit system.s
# We must redefine SIZEOF_OFF_T to match.
2013-08-31 05:16:17 +08:00
IF ( MSVC AND SIZEOF___INT_64 )
2013-08-31 05:25:28 +08:00
SET ( SIZEOF_OFF_T ${ SIZEOF___INT_64 } )
2013-08-31 05:16:17 +08:00
ENDIF ( )
2013-05-25 05:19:07 +08:00
IF ( SIZEOF_SSIZE_T )
2014-03-07 23:46:26 +08:00
SET ( HAVE_SSIZE_T 1 )
2013-05-25 05:19:07 +08:00
ELSE ( )
2014-03-07 23:46:26 +08:00
CHECK_TYPE_SIZE ( "SSIZE_T" SIZEOF_SSIZE_T )
IF ( SIZEOF_SSIZE_T )
SET ( HAVE_SSIZE_T 1 )
ENDIF ( )
2013-05-25 05:19:07 +08:00
ENDIF ( )
2013-04-03 06:09:31 +08:00
2014-03-07 23:40:50 +08:00
# Check for various functions.
2014-03-07 23:46:26 +08:00
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 )
2013-11-05 03:58:33 +08:00
CHECK_FUNCTION_EXISTS ( _filelengthi64 HAVE_FILE_LENGTH_I64 )
2013-03-28 03:15:00 +08:00
2012-10-03 04:56:46 +08:00
#####
# End system inspection checks.
#####
2014-03-09 08:39:09 +08:00
# Create config.h file.
2014-05-30 03:23:24 +08:00
configure_file ( "${netCDF_SOURCE_DIR}/config.h.cmake.in"
2014-03-07 23:46:26 +08:00
" $ { n e t C D F _ B I N A R Y _ D I R } / c o n f i g . h " )
2013-09-17 01:45:34 +08:00
ADD_DEFINITIONS ( -DHAVE_CONFIG_H )
2013-02-20 07:29:41 +08:00
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.
#####
2014-04-22 06:11:48 +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 ( "include" )
add_subdirectory ( libdispatch )
add_subdirectory ( libsrc )
2014-04-22 06:11:48 +08:00
IF ( USE_PNETCDF )
2014-04-22 01:15:33 +08:00
add_subdirectory ( libsrc5 )
2014-04-22 06:11:48 +08:00
ENDIF ( USE_PNETCDF )
2013-03-16 04:31:07 +08:00
2014-04-22 06:11:48 +08:00
IF ( USE_HDF5 )
2014-04-22 01:15:33 +08:00
add_subdirectory ( libsrc4 )
2014-04-22 06:11:48 +08:00
ENDIF ( USE_HDF5 )
2012-10-03 04:56:46 +08:00
2014-04-22 06:11:48 +08:00
IF ( USE_DAP )
2014-03-07 23:46:26 +08:00
ADD_SUBDIRECTORY ( oc2 )
ADD_SUBDIRECTORY ( libdap2 )
2012-10-03 04:56:46 +08:00
ENDIF ( )
add_subdirectory ( liblib )
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 )
2014-03-07 23:46:26 +08:00
REMOVE_DEFINITIONS ( -DDLL_EXPORT )
2012-10-10 04:56:27 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
2012-10-10 04:56:27 +08:00
# Enable Utilities.
2014-04-22 06:11:48 +08:00
IF ( BUILD_UTILITIES )
2014-03-07 23:46:26 +08:00
INCLUDE_DIRECTORIES ( ncdump )
ADD_SUBDIRECTORY ( ncgen )
ADD_SUBDIRECTORY ( ncgen3 )
ADD_SUBDIRECTORY ( ncdump )
2012-10-03 04:56:46 +08:00
ENDIF ( )
# Enable tests
IF ( ENABLE_TESTS )
2014-04-04 00:45:22 +08:00
IF ( ENABLE_V2_API )
2014-04-04 07:09:38 +08:00
ADD_SUBDIRECTORY ( nctest )
2014-04-04 00:45:22 +08:00
ENDIF ( )
2014-03-07 23:46:26 +08:00
ADD_SUBDIRECTORY ( nc_test )
IF ( USE_NETCDF4 )
2014-04-22 01:15:33 +08:00
ADD_SUBDIRECTORY ( nc_test4 )
2014-03-07 23:46:26 +08:00
ADD_SUBDIRECTORY ( h5_test )
ENDIF ( )
IF ( USE_DAP AND ENABLE_DAP_REMOTE_TESTS )
ADD_SUBDIRECTORY ( ncdap_test )
ENDIF ( )
IF ( ENABLE_EXAMPLES )
ADD_SUBDIRECTORY ( examples )
ENDIF ( )
2012-10-03 04:56:46 +08:00
ENDIF ( )
# Code to generate an export header
2012-10-04 04:47:34 +08:00
#GENERATE_EXPORT_HEADER(netcdf
2014-03-07 23:46:26 +08:00
# BASE_NAME netcdf
# EXPORT_MACRO_NAME netcdf_EXPORT
# EXPORT_FILE_NAME netcdf_Export.h
# STATIC_DEFINE netcdf_BUILT_AS_STATIC
2012-10-04 04:47:34 +08:00
#)
2012-10-03 04:56:46 +08:00
#####
# Build doxygen documentation, if need be.
#####
2014-05-22 04:40:39 +08:00
ADD_SUBDIRECTORY ( docs )
2012-10-03 04:56:46 +08:00
#####
# Moving on to CPack, install packages.
#####
2013-02-20 07:29:41 +08:00
INSTALL ( FILES ${ netCDF_SOURCE_DIR } /include/netcdf.h
2014-05-22 05:15:56 +08:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
C O M P O N E N T h e a d e r s )
2013-02-20 07:29:41 +08:00
IF ( ENABLE_PNETCDF OR ENABLE_PARALLEL )
2014-03-07 23:46:26 +08:00
INSTALL ( FILES ${ netCDF_SOURCE_DIR } /include/netcdf_par.h
2014-05-22 05:15:56 +08:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
C O M P O N E N T h e a d e r s )
2013-02-20 07:29:41 +08:00
ENDIF ( )
2014-03-19 02:58:34 +08:00
# Install the dependencies. This is Windows/Visual studio only,
# and mirrors the configuration used on the build system. It is
# a less-than-optimal system, but it's what we currently have, and
# the only way to avoid making the user build all the dependencies
# themselves.
2012-11-20 05:43:12 +08:00
IF ( MSVC )
2014-03-07 23:46:26 +08:00
INSTALL ( DIRECTORY ${ CMAKE_PREFIX_PATH } DESTINATION "deps" COMPONENT dependencies )
2012-11-20 05:43:12 +08:00
ENDIF ( )
2012-10-03 04:56:46 +08:00
# Subdirectory CMakeLists.txt files should specify their own
# 'install' files.
# Including 'CPack' kicks everything off.
INCLUDE ( InstallRequiredSystemLibraries )
CONFIGURE_FILE (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / F i x B u n d l e . c m a k e . i n
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / F i x B u n d l e . c m a k e
@ O N L Y
2014-04-22 01:15:33 +08:00
)
2012-10-03 04:56:46 +08:00
#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.
2014-04-22 06:11:48 +08:00
install ( EXPORT netcdf-targets
2014-03-07 23:46:26 +08:00
D E S T I N A T I O N s h a r e / c m a k e
C O M P O N E N T d o c u m e n t a t i o n )
2012-11-20 05:43:12 +08:00
2014-04-22 06:11:48 +08:00
configure_file (
2014-03-07 23:46:26 +08:00
$ { n e t C D F _ S O U R C E _ D I R } / n e t c d f - c o n f i g . c m a k e . i n
$ { n e t C D F _ B I N A R Y _ D I R } / n e t c d f - c o n f i g . c m a k e @ O N L Y )
2012-11-20 05:43:12 +08:00
2014-04-22 06:11:48 +08:00
configure_file (
2014-03-07 23:46:26 +08:00
$ { n e t C D F _ S O U R C E _ D I R } / n e t c d f - c o n f i g - v e r s i o n . c m a k e . i n
$ { n e t C D F _ B I N A R Y _ D I R } / n e t c d f - c o n f i g - v e r s i o n . c m a k e @ O N L Y )
2012-11-20 05:43:12 +08:00
2014-04-22 06:11:48 +08:00
install ( FILES ${ netCDF_BINARY_DIR } /netcdf-config.cmake
2014-04-22 01:15:33 +08:00
$ { n e t C D F _ B I N A R Y _ D I R } / n e t c d f - c o n f i g - v e r s i o n . c m a k e
2014-05-09 19:40:28 +08:00
D E S T I N A T I O N s h a r e / c m a k e / n e t c d f )
2012-11-20 05:43:12 +08:00
2014-02-07 07:17:30 +08:00
###
# Create pkgconfig files.
###
IF ( NOT DEFINED CMAKE_INSTALL_LIBDIR )
SET ( CMAKE_INSTALL_LIBDIR lib )
ENDIF ( NOT DEFINED CMAKE_INSTALL_LIBDIR )
2014-03-07 23:40:50 +08:00
# Set
2014-02-07 07:17:30 +08:00
SET ( prefix ${ CMAKE_INSTALL_PREFIX } )
SET ( exec_prefix ${ CMAKE_INSTALL_PREFIX } )
SET ( libdir ${ CMAKE_INSTALL_PREFIX } / ${ CMAKE_INSTALL_LIBDIR } )
SET ( includedir ${ CMAKE_INSTALL_PREFIX } /include )
SET ( CC ${ CMAKE_C_COMPILER } )
2014-02-20 07:32:26 +08:00
2014-02-07 07:17:30 +08:00
# Process all dependency libraries and create a string
# used when parsing netcdf.pc.in
2014-06-03 05:14:27 +08:00
FOREACH ( _LIB ${ ALL_TLL_LIBS } )
GET_FILENAME_COMPONENT ( _LIB_NAME ${ _LIB } NAME_WE )
STRING ( REGEX REPLACE "^lib" "" _NAME ${ _LIB_NAME } )
LIST ( APPEND NC_LIBS "-l${_NAME}" )
GET_FILENAME_COMPONENT ( _LIB_DIR ${ _LIB } PATH )
LIST ( APPEND LINKFLAGS "-L${_LIB_DIR}" )
ENDFOREACH ( )
2014-02-07 07:17:30 +08:00
SET ( NC_LIBS "-lnetcdf ${NC_LIBS}" )
STRING ( REPLACE ";" " " NC_LIBS "${NC_LIBS}" )
STRING ( REPLACE ";" " " LINKFLAGS "${LINKFLAGS}" )
LIST ( REMOVE_DUPLICATES NC_LIBS )
LIST ( REMOVE_DUPLICATES LINKFLAGS )
2014-04-22 06:11:48 +08:00
configure_file (
2014-02-07 07:17:30 +08:00
$ { n e t C D F _ S O U R C E _ D I R } / n e t c d f . p c . i n
$ { n e t C D F _ B I N A R Y _ D I R } / n e t c d f . p c @ O N L Y )
2014-03-09 08:39:09 +08:00
FILE ( MAKE_DIRECTORY ${ netCDF_BINARY_DIR } /tmp )
2014-05-30 03:23:24 +08:00
configure_file ( "${netCDF_SOURCE_DIR}/nc-config.cmake.in"
2014-03-09 08:39:09 +08:00
" $ { n e t C D F _ B I N A R Y _ D I R } / t m p / n c - c o n f i g " @ O N L Y )
FILE ( COPY "${netCDF_BINARY_DIR}/tmp/nc-config"
D E S T I N A T I O N $ { n e t C D F _ B I N A R Y _ D I R } /
F I L E _ P E R M I S S I O N S O W N E R _ R E A D O W N E R _ W R I T E O W N E R _ E X E C U T E G R O U P _ R E A D G R O U P _ E X E C U T E W O R L D _ R E A D W O R L D _ E X E C U T E )
2014-04-22 06:11:48 +08:00
INSTALL ( FILES ${ netCDF_BINARY_DIR } /netcdf.pc
2014-06-03 04:03:42 +08:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / p k g c o n f i g
C O M P O N E N T u t i l i t i e s )
2014-02-07 07:17:30 +08:00
2014-05-22 05:15:56 +08:00
INSTALL ( PROGRAMS ${ netCDF_BINARY_DIR } /nc-config
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
C O M P O N E N T u t i l i t i e s )
2014-03-09 08:39:09 +08:00
2014-02-07 07:17:30 +08:00
###
2014-03-09 08:39:09 +08:00
# End pkgconfig, nc-config file creation.
2014-02-07 07:17:30 +08:00
###
####
2012-11-20 05:43:12 +08:00
# 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.
2014-03-07 23:40:50 +08:00
# NOTE!! This list uses regular expressions, NOT wildcards!!
##
2014-04-22 06:11:48 +08:00
SET ( CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}"
2014-03-07 23:46:26 +08:00
" / e x p e c t t d s 3 / "
" / n o c a c h e r e m o t e 3 / "
" / n o c a c h e r e m o t e 4 / "
" / s p e c i a l 3 / "
" $ { C M A K E _ B I N A R Y _ D I R } / * "
" / m y h t m l / * "
" / . s v n / "
" m y . * \ \ \ \ . s h "
" / . d e p s / "
" / . l i b s "
" / h t m l / "
" . * \ \ \ \ . j a r "
" . * \ \ \ \ . j d l "
" . * \ \ \ \ . s e d "
" . * \ \ \ \ . p r o t o "
" . * \ \ \ \ . t e x i "
" . * \ \ \ \ . e x a m p l e "
" M a k e 0 "
" / o b s o l e t e / "
" / u n k n o w n / "
" . * ~ "
2014-04-22 01:15:33 +08:00
)
2012-10-03 04:56:46 +08:00
CONFIGURE_FILE ( ${ CMAKE_CURRENT_SOURCE_DIR } /COPYRIGHT
2014-03-07 23:46:26 +08:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / C O P Y R I G H T . t x t
@ O N L Y
2014-04-22 01:15:33 +08:00
)
2012-10-03 04:56:46 +08:00
SET ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/COPYRIGHT.txt" )
2012-12-06 02:35:42 +08:00
IF ( NOT CPACK_PACK_VERSION )
2014-03-07 23:46:26 +08:00
SET ( CPACK_PACKAGE_VERSION ${ VERSION } )
2012-12-06 02:35:42 +08:00
ENDIF ( )
2013-03-09 07:36:40 +08:00
2012-10-03 04:56:46 +08:00
IF ( APPLE )
2013-02-20 07:29:41 +08:00
SET ( CPACK_SOURCE_GENERATOR "TGZ" )
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 (
2014-03-07 23:46:26 +08:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e _ u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
2012-10-30 02:46:56 +08:00
2012-10-12 06:31:50 +08:00
ADD_CUSTOM_TARGET ( uninstall
2014-03-07 23:46:26 +08:00
C O M M A N D $ { C M A K E _ C O M M A N D } - P $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e )
2012-10-03 04:56:46 +08:00
2012-11-20 05:43:12 +08:00
## Customize some of the package component descriptions
2014-04-22 06:11:48 +08:00
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" )
2012-11-20 05:43:12 +08:00
set ( CPACK_COMPONENT_UTILITIES_DESCRIPTION
2014-03-07 23:46:26 +08:00
" T h e n e t C D F U t i l i t i e s " )
2012-11-20 05:43:12 +08:00
set ( CPACK_COMPONENT_LIBRARIES_DESCRIPTION
2014-03-07 23:46:26 +08:00
" T h e n e t C D F L i b r a r i e s " )
2012-11-20 05:43:12 +08:00
set ( CPACK_COMPONENT_HEADERS_DESCRIPTION
2014-03-07 23:46:26 +08:00
" C h e a d e r f i l e s f o r u s e w i t h n e t C D F " )
2012-11-20 05:43:12 +08:00
set ( CPACK_COMPONENT_DEPENDENCIES_DESCRIPTION
2014-03-07 23:46:26 +08:00
" D e p e n d e n c i e s f o r t h i s b u i l d o f n e t C D F " )
2012-11-20 05:43:12 +08:00
set ( CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION
2014-03-07 23:46:26 +08:00
" T h e n e t C D F u s e r d o c u m e n t a t i o n . " )
2012-10-03 04:56:46 +08:00
print_conf_summary ( )
2013-05-25 05:19:07 +08:00
# Enable Makedist files.
2013-06-04 00:42:04 +08:00
ADD_MAKEDIST ( )
2014-05-30 03:23:24 +08:00
ENABLE_MAKEDIST ( README.md COPYRIGHT RELEASE_NOTES.md INSTALL INSTALL.cmake test_prog.c lib_flags.am cmake CMakeLists.txt COMPILE.cmake.txt config.h.cmake.in cmake_uninstall.cmake.in netcdf-config-version.cmake.in netcdf-config.cmake.in FixBundle.cmake.in nc-config.cmake.in configure configure.ac install-sh config.h.in config.sub CTestConfig.cmake.in )
2013-05-25 05:19:07 +08:00
2014-06-03 04:03:42 +08:00
#####
# Configure and print the libnetcdf.settings file.
#####
2014-06-03 05:14:27 +08:00
# Set variables to mirror those used by autoconf.
2014-06-03 04:03:42 +08:00
# This way we don't need to maintain two separate template
# files.
2014-06-03 05:14:27 +08:00
SET ( host_cpu "${cpu}" )
SET ( host_vendor "${osname}" )
SET ( host_os "${osrel}" )
SET ( abs_top_builddir "${CMAKE_BINARY_DIR}" )
SET ( CC_VERSION "${CMAKE_C_COMPILER}" )
SET ( CFLAGS "${CMAKE_C_FLAGS} ${CFLAGS}" )
SET ( CPPFLAGS "${CMAKE_CPP_FLAGS} ${CPPFLAGS}" )
SET ( LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_LINKER_FLAGS} ${LDFLAGS}" )
is_disabled ( BUILD_SHARED_LIBRARY enable_static )
is_enabled ( BUILD_SHARED_LIBRARY enable_shared )
# Remove libnetcdf from NC_LIBS.
STRING ( REPLACE "-lnetcdf " "" TMP_NC_LIBS "${NC_LIBS}" )
SET ( LIBS "${TMP_NC_LIBS}" )
is_enabled ( ENABLE_V2_API HAS_NC2 )
is_enabled ( ENABLE_NETCDF_4 HAS_NC4 )
is_enabled ( ENABLE_HDF4 HAS_HDF4 )
is_enabled ( ENABLE_NETCDF_4 HAS_HDF5 )
is_enabled ( STATUS_PNETCDF HAS_PNETCDF )
is_enabled ( STATUS_PARALLEL HAS_PARALLEL )
is_enabled ( USE_DAP HAS_DAP )
is_enabled ( USE_DISKLESS HAS_DISKLESS )
is_enabled ( USE_MMAP HAS_MMAP )
is_enabled ( JNA HAS_JNA )
# Generate file from template.
2014-06-03 04:03:42 +08:00
CONFIGURE_FILE ( "${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b n e t c d f . s e t t i n g s "
@ O N L Y
)
# Read in settings file, print out.
# Avoid using system-specific calls so that this
# might also work on Windows.
FILE ( READ "${CMAKE_CURRENT_BINARY_DIR}/libnetcdf.settings"
L I B N E T C D F _ S E T T I N G S )
MESSAGE ( ${ LIBNETCDF_SETTINGS } )
# Install libnetcdf.settings file into same location
# as the libraries.
INSTALL ( FILES "${netCDF_BINARY_DIR}/libnetcdf.settings"
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ B I N D I R } "
C O M P O N E N T l i b r a r i e s )
#####
# End libnetcdf.settings section.
#####
2012-10-03 04:56:46 +08:00
# CPack inclusion must come last.
INCLUDE ( CPack )