Skip to content

Commit

Permalink
Merge pull request #356 from Unidata/cmake-parallel
Browse files Browse the repository at this point in the history
Cmake parallel fix
  • Loading branch information
WardF authored Jan 30, 2017
2 parents 1c41581 + 209c31d commit 594f50a
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 252 deletions.
117 changes: 101 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/"
# auto-configure style checks, other CMake modules.
INCLUDE(${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
Expand Down Expand Up @@ -333,24 +334,15 @@ OPTION (ENABLE_V2_API "Build netCDF Version 2." ON)
SET(BUILD_V2 ${ENABLE_V2_API})
IF(NOT ENABLE_V2_API)
SET(NO_NETCDF_2 ON)
ENDIF()
ELSE(NOT ENABLE_V2_API)
SET(USE_NETCDF_2 TRUE)
ENDIF(NOT ENABLE_V2_API)

# Option to build utilities
OPTION(BUILD_UTILITIES "Build ncgen, ncgen3, ncdump." ON)

# Option to use MMAP
OPTION(ENABLE_MMAP "Use MMAP." OFF)
IF(ENABLE_MMAP)
CHECK_FUNCTION_EXISTS(mremap HAVE_MREMAP)
IF(NOT HAVE_MREMAP)
MESSAGE(WARNING "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()
OPTION(ENABLE_MMAP "Use MMAP." ON)

# Option to use examples.
OPTION(ENABLE_EXAMPLES "Build Examples" ON)
Expand Down Expand Up @@ -653,6 +645,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF()

IF(HDF5_IS_PARALLEL_MPIO)
SET(HAVE_H5PGET_FAPL_MPIO TRUE)
SET(USE_PARALLEL_MPIO ON)
ENDIF()

Expand All @@ -667,6 +660,9 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(HDF5_C_LIBRARY hdf5)
ENDIF(NOT MSVC)

# Make sure the user has built the library with zlib support.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_deflate "" HAVE_H5PSET_DEFLATE)

#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5P_SZIP "" USE_SZIP)
IF(USE_SZIP)
Expand All @@ -680,8 +676,15 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF()

CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5free_memory "" HDF5_HAS_H5FREE)
IF(HDF5_HAS_H5FREE)
SET(HAVE_H5FREE_MEMORY TRUE)
ENDIF(HDF5_HAS_H5FREE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_libver_bounds "" HDF5_HAS_LIBVER_BOUNDS)

IF(HDF5_HAS_LIBVER_BOUNDS)
SET(HAVE_H5PSET_LIBVER_BOUNDS TRUE)
ENDIF(HDF5_HAS_LIBVER_BOUNDS)

IF(HDF5_PARALLEL)
SET(HDF5_CC h5pcc)
ELSE()
Expand Down Expand Up @@ -719,6 +722,14 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(USE_ZLIB ON)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})

FIND_PATH(HAVE_HDF5_H hdf5.h)
IF(NOT HAVE_HDF5_H)
MESSAGE(FATAL_ERROR "Compiling a test with hdf5 failed. Either hdf5.h cannot be found, or the log messages should be checked for another reason.")
ELSE(NOT HAVE_HDF5_H)
INCLUDE_DIRECTORIES(${HAVE_HDF5_H})
ENDIF(NOT HAVE_HDF5_H)


ENDIF(USE_HDF5 OR ENABLE_NETCDF_4)


Expand Down Expand Up @@ -1115,7 +1126,7 @@ 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("locale.h" HAVE_LOCALE_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)
Expand All @@ -1129,27 +1140,85 @@ 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/mman.h" HAVE_SYS_MMAN_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)
CHECK_INCLUDE_FILE("BaseTsd.h" HAVE_BASETSD_H)
CHECK_INCLUDE_FILE("stddef.h" HAVE_STDDEF_H)
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)

CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME)

IF(NOT HAVE_STDLIB_H)
SET(NO_STDLIB_H TRUE)
ENDIF(NOT HAVE_STDLIB_H)

IF(NOT HAVE_SYS_TYPES_H)
SET(NO_SYS_TYPES_H TRUE)
ENDIF(NOT HAVE_SYS_TYPES_H)


# Symbol Exists
CHECK_SYMBOL_EXISTS(isfinite "math.h" HAVE_DECL_ISFINITE)
CHECK_SYMBOL_EXISTS(isnan "math.h" HAVE_DECL_ISNAN)
CHECK_SYMBOL_EXISTS(isinf "math.h" HAVE_DECL_ISINF)
CHECK_SYMBOL_EXISTS(signbit "math.h" HAVE_DECL_SIGNBIT)
CHECK_SYMBOL_EXISTS(st_blksize "sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE)
CHECK_SYMBOL_EXISTS(alloca "alloca.h" HAVE_ALLOCA)

# For historic purposes...
SET(HAVE_ST_BLKSIZE ${HAVE_STRUCT_STAT_ST_BLKSIZE})

# Type checks
CHECK_TYPE_SIZE("void*" SIZEOF_VOIDSTAR)
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("uint" SIZEOF_UINT)
IF(SIZEOF_UINT)
SET(HAVE_UINT TRUE)
ENDIF(SIZEOF_UINT)

CHECK_TYPE_SIZE("long" SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
IF(SIZEOF_LONG_LONG)
SET(HAVE_LONG_LONG_INT TRUE)
ENDIF(SIZEOF_LONG_LONG)

CHECK_TYPE_SIZE("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
IF(SIZEOF_UNSIGNED_LONG_LONG)
SET(HAVE_UNSIGNED_LONG_LONG_INT TRUE)
ENDIF(SIZEOF_UNSIGNED_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("ushort" SIZEOF_USHORT)
IF(SIZEOF_USHORT)
SET(HAVE_USHORT TRUE)
ENDIF(SIZEOF_USHORT)

CHECK_TYPE_SIZE("_Bool" SIZEOF__BOOL)
IF(SIZEOF__BOOL)
SET(HAVE__BOOL TRUE)
ENDIF(SIZEOF__BOOL)

CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
IF(SIZEOF_SIZE_T)
SET(HAVE_SIZE_T TRUE)
ENDIF(SIZEOF_SIZE_T)

CHECK_TYPE_SIZE("ssize_t" SIZEOF_SSIZE_T)
CHECK_TYPE_SIZE("ptrdiff_t" SIZEOF_PTRDIFF_T)
IF(SIZEOF_PTRDIFF_T)
SET(HAVE_PTRDIFF_T TRUE)
ENDIF(SIZEOF_PTRDIFF_T)

# __int64 is used on Windows for large file support.
CHECK_TYPE_SIZE("__int64" SIZEOF___INT_64)
CHECK_TYPE_SIZE("uchar" SIZEOF_UCHAR)
Expand Down Expand Up @@ -1186,20 +1255,36 @@ CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
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(strtoull HAVE_STRTOULL)
CHECK_FUNCTION_EXISTS(strstr HAVE_STRSTR)
CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
CHECK_FUNCTION_EXISTS(rand HAVE_RAND)
CHECK_FUNCTION_EXISTS(random HAVE_RANDOM)
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(MPI_Comm_f2c HAVE_MPI_COMM_F2C)
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
CHECK_FUNCTION_EXISTS(memcmp HAVE_MEMCMP)
CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
CHECK_FUNCTION_EXISTS(getrlimit HAVE_GETRLIMIT)
CHECK_FUNCTION_EXISTS(_filelengthi64 HAVE_FILE_LENGTH_I64)
CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
CHECK_FUNCTION_EXISTS(mremap HAVE_MREMAP)

IF(ENABLE_MMAP)
IF(NOT HAVE_MREMAP)
MESSAGE(WARNING "mremap not found: disabling MMAP support.")
SET(ENABLE_MMAP OFF)
ELSE(NOT HAVE_MREMAP)
SET(HAVE_MMAP ON)
SET(BUILD_MMAP ON)
SET(USE_MMAP ON)
ENDIF(NOT HAVE_MREMAP)
ENDIF(ENABLE_MMAP)

CHECK_FUNCTION_EXISTS(vprintf HAVE_VPRINTF)
#CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
#####
# End system inspection checks.
#####
Expand Down
Loading

0 comments on commit 594f50a

Please sign in to comment.