summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-10-04 18:04:53 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-10-04 18:04:53 (GMT)
commit36594716c34547d2fa4cfdf576193022a64557a8 (patch)
treefa8b2911bafa42e15e0d40e59d6cddf9f509e701
parentd581cbeb9e06e4670f06608eb24bd65e17cd2b14 (diff)
parent2a95ab5acbe032f58891b653f56b9db8a4938d95 (diff)
downloadhdf5-36594716c34547d2fa4cfdf576193022a64557a8.zip
hdf5-36594716c34547d2fa4cfdf576193022a64557a8.tar.gz
hdf5-36594716c34547d2fa4cfdf576193022a64557a8.tar.bz2
Merge pull request #1277 in HDFFV/hdf5 from ~BYRN/hdf5_adb:develop to develop
* commit '2a95ab5acbe032f58891b653f56b9db8a4938d95': TRILABS-21 add toolchain related info and files TRILABS-21 Add intel compiler support Fix undef for Xl compilers TRILAB-21 Intel flags
-rw-r--r--MANIFEST2
-rw-r--r--config/cmake/HDF5UseFortran.cmake78
-rw-r--r--config/cmake/HDFCompilerFlags.cmake77
-rwxr-xr-xconfig/cmake/scripts/HDF5options.cmake5
-rw-r--r--config/cmake_ext_mod/ConfigureChecks.cmake113
-rw-r--r--config/cmake_ext_mod/HDFLibMacros.cmake9
-rw-r--r--config/intel.cmake10
-rw-r--r--release_docs/INSTALL_CMake.txt28
8 files changed, 206 insertions, 116 deletions
diff --git a/MANIFEST b/MANIFEST
index 117c531..317e156 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3148,6 +3148,8 @@
./java/lib/ext/slf4j-simple-1.7.25.jar
# CMake-specific Files
+./config/intel.cmake
+
./config/cmake/cacheinit.cmake
./config/cmake/CMakeFindJavaCommon.cmake
./config/cmake/ConversionTests.c
diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake
index 1f66bad..e260f0c 100644
--- a/config/cmake/HDF5UseFortran.cmake
+++ b/config/cmake/HDF5UseFortran.cmake
@@ -31,10 +31,14 @@ endif ()
# The provided CMake Fortran macros don't provide a general compile/run function
# so this one is used.
#-----------------------------------------------------------------------------
-macro (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN)
+macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN_VAR)
#
-# if (NOT DEFINED ${RUN_RESULT_VAR})
- message (STATUS "Detecting Fortran ${FUNCTION}")
+# if (CMAKE_CROSSCOMPILING)
+# set (${OUTPUT_VAR} ${PRESET_${FUNCTION_NAME}})
+# message (STATUS "Detecting Fortran ${FUNCTION_NAME}: force ${OUTPUT_VAR}")
+# set(${RETURN_VAR} ${OUTPUT_VAR})
+# else ()
+ message (STATUS "Detecting Fortran ${FUNCTION_NAME}")
if (CMAKE_REQUIRED_LIBRARIES)
set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
@@ -43,18 +47,18 @@ macro (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN)
endif ()
file (WRITE
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90
- "${CODE}"
+ "${SOURCE_CODE}"
)
TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90
CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
- RUN_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE OUTPUT_VAR
)
- set(${RETURN} ${OUTPUT})
+ set(${RETURN_VAR} ${OUTPUT_VAR})
- #message ( "Test result1 ${RETURN} ")
+ #message ( "Test result1 ${RETURN_VAR} ")
#message ( "Test result3 ${RESULT} ")
#message ( "Test result2 ${CMAKE_MATCH_0} ")
#message ( "Test result4 ${CMAKE_MATCH_1} ")
@@ -66,34 +70,34 @@ macro (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN)
if (${COMPILE_RESULT_VAR})
if (${RUN_RESULT_VAR} MATCHES 0)
- message (STATUS "Testing Fortran ${FUNCTION} - OK")
+ message (STATUS "Testing Fortran ${FUNCTION_NAME} - OK")
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n"
- "${OUTPUT}\n\n"
+ "Determining if the Fortran ${FUNCTION_NAME} exists passed with the following output:\n"
+ "${OUTPUT_VAR}\n\n"
)
else ()
- message (STATUS "Testing Fortran ${FUNCTION} - Fail")
+ message (STATUS "Testing Fortran ${FUNCTION_NAME} - Fail")
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n"
- "${OUTPUT}\n\n")
+ "Determining if the Fortran ${FUNCTION_NAME} exists failed with the following output:\n"
+ "${OUTPUT_VAR}\n\n")
endif ()
endif ()
# endif ()
endmacro ()
# Read source line beginning at the line matching Input:"START" and ending at the line matching Input:"END"
-macro (READ_SOURCE START END RETURN)
- file (READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" CODE)
- string (REGEX MATCH "${START}[\\\t\\\n\\\r[].+]*${END}" CODE ${CODE})
- set (RETURN "${CODE}")
+macro (READ_SOURCE SOURCE_START SOURCE_END RETURN_VAR)
+ file (READ "${HDF5_SOURCE_DIR}/m4/aclocal_fc.f90" SOURCE_CODE)
+ string (REGEX MATCH "${SOURCE_START}[\\\t\\\n\\\r[].+]*${SOURCE_END}" SOURCE_CODE ${SOURCE_CODE})
+ set (RETURN_VAR "${SOURCE_CODE}")
endmacro ()
#-----------------------------------------------------------------------------
# Check to see C_LONG_DOUBLE is available
-READ_SOURCE("PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" "END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" CODE)
+READ_SOURCE("PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" "END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE" SOURCE_CODE)
CHECK_FORTRAN_FEATURE(c_long_double
- "${CODE}"
+ "${SOURCE_CODE}"
FORTRAN_HAVE_C_LONG_DOUBLE
)
@@ -105,9 +109,9 @@ endif ()
# Check to see C_LONG_DOUBLE is different from C_DOUBLE
-READ_SOURCE("MODULE type_mod" "END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE" CODE)
+READ_SOURCE("MODULE type_mod" "END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE" SOURCE_CODE)
CHECK_FORTRAN_FEATURE(c_long_double
- "${CODE}"
+ "${SOURCE_CODE}"
FORTRAN_C_LONG_DOUBLE_IS_UNIQUE
)
if (${FORTRAN_C_LONG_DOUBLE_IS_UNIQUE})
@@ -133,9 +137,9 @@ endif ()
# Determine the available KINDs for REALs and INTEGERs
#-----------------------------------------------------------------------------
-READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" CODE)
+READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE)
FORTRAN_RUN ("REAL and INTEGER KINDs"
- "${CODE}"
+ "${SOURCE_CODE}"
XX
YY
PROG_OUTPUT
@@ -372,8 +376,8 @@ ENABLE_LANGUAGE (C)
# The provided CMake C macros don't provide a general compile/run function
# so this one is used.
#-----------------------------------------------------------------------------
-macro (C_RUN FUNCTION CODE RETURN)
- message (STATUS "Detecting C ${FUNCTION}")
+macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR)
+ message (STATUS "Detecting C ${FUNCTION_NAME}")
if (CMAKE_REQUIRED_LIBRARIES)
set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
@@ -382,16 +386,16 @@ macro (C_RUN FUNCTION CODE RETURN)
endif ()
file (WRITE
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c
- ${CODE}
+ ${SOURCE_CODE}
)
TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c
CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
- RUN_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE OUTPUT_VAR
)
- set (${RETURN} ${OUTPUT})
+ set (${RETURN_VAR} ${OUTPUT_VAR})
#message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ")
#message ( "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ")
@@ -401,21 +405,21 @@ macro (C_RUN FUNCTION CODE RETURN)
if (${COMPILE_RESULT_VAR})
if (${RUN_RESULT_VAR} MATCHES 1)
- set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION}")
- message (STATUS "Testing C ${FUNCTION} - OK")
+ set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}")
+ message (STATUS "Testing C ${FUNCTION_NAME} - OK")
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if the C ${FUNCTION} exists passed with the following output:\n"
- "${OUTPUT}\n\n"
+ "Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n"
+ "${OUTPUT_VAR}\n\n"
)
else ()
- message (STATUS "Testing C ${FUNCTION} - Fail")
- set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION}")
+ message (STATUS "Testing C ${FUNCTION_NAME} - Fail")
+ set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}")
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if the C ${FUNCTION} exists failed with the following output:\n"
- "${OUTPUT}\n\n")
+ "Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n"
+ "${OUTPUT_VAR}\n\n")
endif ()
else ()
- message (FATAL_ERROR "Compilation of C ${FUNCTION} - Failed")
+ message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed")
endif ()
endmacro ()
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index ec13272..93ebc3c 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -24,7 +24,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common")
endif ()
else ()
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstdarg-opt")
endif ()
endif ()
@@ -36,7 +36,7 @@ if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common")
endif ()
else ()
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstdarg-opt")
endif ()
endif ()
@@ -94,16 +94,29 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
#
# NOTE: Don't add -Wpadded here since we can't/won't fix the (many)
# warnings that are emitted. If you need it, add it at configure time.
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wc++-compat -Wcast-align")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings")
- # gcc automatically inlines based on the optimization level
- # this is just a failsafe
- set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
+ if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcheck -Wall")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wreturn-type -Wstrict-prototypes -Wuninitialized")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunknown-pragmas -Wunused-function -Wunused-variable")
+ # this is just a failsafe
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
+ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0)
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wsign-compare -Wtrigraphs -Wwrite-strings")
+ endif()
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wc++-compat -Wcast-align")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings")
+ # gcc automatically inlines based on the optimization level
+ # this is just a failsafe
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
+ endif ()
endif ()
#-----------------------------------------------------------------------------
@@ -113,28 +126,36 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
option (HDF5_ENABLE_DEV_WARNINGS "Enable HDF5 developer group warnings" OFF)
if (HDF5_ENABLE_DEV_WARNINGS)
message (STATUS "....HDF5 developer group warnings are enabled")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn")
+ if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Wreorder -Wport -Wstrict-aliasing")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn")
+ endif ()
else ()
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn")
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} -Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn")
+ endif ()
endif ()
- # Append warning flags that only gcc 4.3+ knows about
- #
- # Technically, variable-length arrays are part of the C99 standard, but
- # we should approach them a bit cautiously... -QAK
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wlogical-op -Wlarger-than=2048 -Wvla")
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ # Append warning flags that only gcc 4.3+ knows about
+ #
+ # Technically, variable-length arrays are part of the C99 standard, but
+ # we should approach them a bit cautiously... -QAK
+ set (H5_CFLAGS1 "${H5_CFLAGS1} -Wlogical-op -Wlarger-than=2048 -Wvla")
- # Append more extra warning flags that only gcc 4.4+ know about
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat")
+ # Append more extra warning flags that only gcc 4.4+ know about
+ set (H5_CFLAGS1 "${H5_CFLAGS1} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat")
+ endif ()
# Append more extra warning flags that only gcc 4.5+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5)
set (H5_CFLAGS1 "${H5_CFLAGS1} -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants")
endif ()
# Append more extra warning flags that only gcc 4.6+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdouble-promotion -Wtrampolines")
if (HDF5_ENABLE_DEV_WARNINGS)
set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=const")
@@ -144,7 +165,7 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
endif ()
# Append more extra warning flags that only gcc 4.7+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
set (H5_CFLAGS2 "${H5_CFLAGS2} -Wstack-usage=8192 -Wvector-operation-performance")
if (HDF5_ENABLE_DEV_WARNINGS)
set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn")
@@ -154,7 +175,7 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
endif ()
# Append more extra warning flags that only gcc 4.8+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)
if (HDF5_ENABLE_DEV_WARNINGS)
set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=format")
else ()
@@ -163,17 +184,17 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
endif ()
# Append more extra warning flags that only gcc 4.9+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdate-time")
endif ()
# Append more extra warning flags that only gcc 5.1+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1)
set (H5_CFLAGS3 "${H5_CFLAGS3} -Warray-bounds=2 -Wc99-c11-compat")
endif ()
# Append more extra warning flags that only gcc 6.x+ know about
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0)
set (H5_CFLAGS4 "${H5_CFLAGS4} -Wnull-dereference -Wunused-const-variable -Wduplicated-cond -Whsa")
endif ()
diff --git a/config/cmake/scripts/HDF5options.cmake b/config/cmake/scripts/HDF5options.cmake
index 3e6aad0..80a28d3 100755
--- a/config/cmake/scripts/HDF5options.cmake
+++ b/config/cmake/scripts/HDF5options.cmake
@@ -96,3 +96,8 @@ set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING
set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_EXTLIBS:BOOL=ON")
#############################################################################################
+### use a toolchain file
+
+#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/intel.cmake")
+
+#############################################################################################
diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake
index 9be30f7..3ab47fc 100644
--- a/config/cmake_ext_mod/ConfigureChecks.cmake
+++ b/config/cmake_ext_mod/ConfigureChecks.cmake
@@ -279,36 +279,42 @@ if (NOT WINDOWS)
option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON)
if (HDF_ENABLE_LARGE_FILE)
set (msg "Performing TEST_LFS_WORKS")
- TRY_RUN (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE
- ${CMAKE_BINARY_DIR}
- ${HDF_RESOURCES_EXT_DIR}/HDFTests.c
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-DTEST_LFS_WORKS
- OUTPUT_VARIABLE OUTPUT
- )
+ if (CMAKE_CROSSCOMPILING)
+ set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg})
+ set (LARGEFILE 1)
+ set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
+ message (STATUS "${msg} with presets... yes")
+ else ()
+ TRY_RUN (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE
+ ${CMAKE_BINARY_DIR}
+ ${HDF_RESOURCES_EXT_DIR}/HDFTests.c
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-DTEST_LFS_WORKS
+ )
- # The LARGEFILE definitions were from the transition period
- # and are probably no longer needed. The FILE_OFFSET_BITS
- # check should be generalized for all POSIX systems as it
- # is in the Autotools.
- if (TEST_LFS_WORKS_COMPILE)
- if (TEST_LFS_WORKS_RUN MATCHES 0)
- set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg})
- set (LARGEFILE 1)
- set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
- message (STATUS "${msg}... yes")
+ # The LARGEFILE definitions were from the transition period
+ # and are probably no longer needed. The FILE_OFFSET_BITS
+ # check should be generalized for all POSIX systems as it
+ # is in the Autotools.
+ if (TEST_LFS_WORKS_COMPILE)
+ if (TEST_LFS_WORKS_RUN MATCHES 0)
+ set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg})
+ set (LARGEFILE 1)
+ set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE)
+ message (STATUS "${msg}... yes")
+ else ()
+ set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg})
+ message (STATUS "${msg}... no")
+ file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN}\n"
+ )
+ endif ()
else ()
set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg})
message (STATUS "${msg}... no")
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Test TEST_LFS_WORKS Run failed with the following output and exit code:\n ${OUTPUT}\n"
+ "Test TEST_LFS_WORKS Compile failed\n"
)
endif ()
- else ()
- set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg})
- message (STATUS "${msg}... no")
- file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Test TEST_LFS_WORKS Compile failed with the following output:\n ${OUTPUT}\n"
- )
endif ()
endif ()
set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_FLAGS})
@@ -641,37 +647,42 @@ endforeach ()
if (NOT ${HDF_PREFIX}_PRINTF_LL_WIDTH OR ${HDF_PREFIX}_PRINTF_LL_WIDTH MATCHES "unknown")
set (PRINT_LL_FOUND 0)
message (STATUS "Checking for appropriate format for 64 bit long:")
- set (CURRENT_TEST_DEFINITIONS "-DPRINTF_LL_WIDTH")
- if (${HDF_PREFIX}_SIZEOF_LONG_LONG)
- set (CURRENT_TEST_DEFINITIONS "${CURRENT_TEST_DEFINITIONS} -DHAVE_LONG_LONG")
- endif ()
- TRY_RUN (${HDF_PREFIX}_PRINTF_LL_TEST_RUN ${HDF_PREFIX}_PRINTF_LL_TEST_COMPILE
- ${CMAKE_BINARY_DIR}
- ${HDF_RESOURCES_EXT_DIR}/HDFTests.c
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CURRENT_TEST_DEFINITIONS}
- OUTPUT_VARIABLE OUTPUT
- )
- if (${HDF_PREFIX}_PRINTF_LL_TEST_COMPILE)
- if (${HDF_PREFIX}_PRINTF_LL_TEST_RUN MATCHES 0)
- string(REGEX REPLACE ".*PRINTF_LL_WIDTH=\\[(.*)\\].*" "\\1" ${HDF_PREFIX}_PRINTF_LL "${OUTPUT}")
- set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"${${HDF_PREFIX}_PRINTF_LL}\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll")
- set (PRINT_LL_FOUND 1)
- else ()
- message ("Width test failed with result: ${${HDF_PREFIX}_PRINTF_LL_TEST_RUN}")
- endif ()
+ if (CMAKE_CROSSCOMPILING)
+ set (${HDF_PREFIX}_PRINTF_LL_WIDTH ${PRESET_PRINTF_LL})
+ message (STATUS "Checking for appropriate format for 64 bit long: force ${${HDF_PREFIX}_PRINTF_LL_WIDTH}")
else ()
- file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
- "Test ${HDF_PREFIX}_PRINTF_LL_WIDTH failed with the following output:\n ${OUTPUT}\n"
+ set (CURRENT_TEST_DEFINITIONS "-DPRINTF_LL_WIDTH")
+ if (${HDF_PREFIX}_SIZEOF_LONG_LONG)
+ set (CURRENT_TEST_DEFINITIONS "${CURRENT_TEST_DEFINITIONS} -DHAVE_LONG_LONG")
+ endif ()
+ TRY_RUN (${HDF_PREFIX}_PRINTF_LL_TEST_RUN ${HDF_PREFIX}_PRINTF_LL_TEST_COMPILE
+ ${CMAKE_BINARY_DIR}
+ ${HDF_RESOURCES_EXT_DIR}/HDFTests.c
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CURRENT_TEST_DEFINITIONS}
+ RUN_OUTPUT_VARIABLE OUTPUT
)
- endif ()
+ if (${HDF_PREFIX}_PRINTF_LL_TEST_COMPILE)
+ if (${HDF_PREFIX}_PRINTF_LL_TEST_RUN MATCHES 0)
+ string(REGEX REPLACE ".*PRINTF_LL_WIDTH=\\[(.*)\\].*" "\\1" ${HDF_PREFIX}_PRINTF_LL "${OUTPUT}")
+ set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"${${HDF_PREFIX}_PRINTF_LL}\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll")
+ set (PRINT_LL_FOUND 1)
+ else ()
+ message ("Width test failed with result: ${${HDF_PREFIX}_PRINTF_LL_TEST_RUN}")
+ endif ()
+ else ()
+ file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+ "Test ${HDF_PREFIX}_PRINTF_LL_WIDTH failed\n"
+ )
+ endif ()
- if (PRINT_LL_FOUND)
- message (STATUS "Checking for appropriate format for 64 bit long: found ${${HDF_PREFIX}_PRINTF_LL_WIDTH}")
- else ()
- message (STATUS "Checking for appropriate format for 64 bit long: not found")
- set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"unknown\"" CACHE INTERNAL
- "Width for printf for type `long long' or `__int64', us. `ll"
- )
+ if (PRINT_LL_FOUND)
+ message (STATUS "Checking for appropriate format for 64 bit long: found ${${HDF_PREFIX}_PRINTF_LL_WIDTH}")
+ else ()
+ message (STATUS "Checking for appropriate format for 64 bit long: not found")
+ set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"unknown\"" CACHE INTERNAL
+ "Width for printf for type `long long' or `__int64', us. `ll"
+ )
+ endif ()
endif ()
endif ()
diff --git a/config/cmake_ext_mod/HDFLibMacros.cmake b/config/cmake_ext_mod/HDFLibMacros.cmake
index 54e408b..8a37af3 100644
--- a/config/cmake_ext_mod/HDFLibMacros.cmake
+++ b/config/cmake_ext_mod/HDFLibMacros.cmake
@@ -30,6 +30,7 @@ macro (EXTERNAL_JPEG_LIBRARY compress_type jpeg_pic)
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${jpeg_pic}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
elseif (${compress_type} MATCHES "GIT")
EXTERNALPROJECT_ADD (JPEG
@@ -47,6 +48,7 @@ macro (EXTERNAL_JPEG_LIBRARY compress_type jpeg_pic)
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${jpeg_pic}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
elseif (${compress_type} MATCHES "TGZ")
EXTERNALPROJECT_ADD (JPEG
@@ -64,6 +66,7 @@ macro (EXTERNAL_JPEG_LIBRARY compress_type jpeg_pic)
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${jpeg_pic}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
endif ()
externalproject_get_property (JPEG BINARY_DIR SOURCE_DIR)
@@ -121,6 +124,7 @@ macro (EXTERNAL_SZIP_LIBRARY compress_type encoding)
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS}
-DSZIP_ENABLE_ENCODING:BOOL=${encoding}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
elseif (${compress_type} MATCHES "GIT")
EXTERNALPROJECT_ADD (SZIP
@@ -139,6 +143,7 @@ macro (EXTERNAL_SZIP_LIBRARY compress_type encoding)
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS}
-DSZIP_ENABLE_ENCODING:BOOL=${encoding}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
elseif (${compress_type} MATCHES "TGZ")
EXTERNALPROJECT_ADD (SZIP
@@ -157,6 +162,7 @@ macro (EXTERNAL_SZIP_LIBRARY compress_type encoding)
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS}
-DSZIP_ENABLE_ENCODING:BOOL=${encoding}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
endif ()
externalproject_get_property (SZIP BINARY_DIR SOURCE_DIR)
@@ -213,6 +219,7 @@ macro (EXTERNAL_ZLIB_LIBRARY compress_type)
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
elseif (${compress_type} MATCHES "GIT")
EXTERNALPROJECT_ADD (ZLIB
@@ -230,6 +237,7 @@ macro (EXTERNAL_ZLIB_LIBRARY compress_type)
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
elseif (${compress_type} MATCHES "TGZ")
EXTERNALPROJECT_ADD (ZLIB
@@ -247,6 +255,7 @@ macro (EXTERNAL_ZLIB_LIBRARY compress_type)
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=${CMAKE_PDB_OUTPUT_DIRECTORY}
-DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS}
+ -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
)
endif ()
externalproject_get_property (ZLIB BINARY_DIR SOURCE_DIR)
diff --git a/config/intel.cmake b/config/intel.cmake
new file mode 100644
index 0000000..5ef9282
--- /dev/null
+++ b/config/intel.cmake
@@ -0,0 +1,10 @@
+# Uncomment the following to use cross-compiling
+#set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_COMPILER_VENDOR "intel")
+
+set(CMAKE_C_COMPILER icc)
+set(CMAKE_CXX_COMPILER icpc)
+set(CMAKE_Fortran_COMPILER ifort)
+
+# the following is used if cross-compiling
+set(PRESET_PRINTF_LL "l")
diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt
index 7352dae..edd876a 100644
--- a/release_docs/INSTALL_CMake.txt
+++ b/release_docs/INSTALL_CMake.txt
@@ -324,6 +324,34 @@ IV. Further considerations
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING=Release ..
+ 6. CMake uses a toolchain of utilities to compile, link libraries and
+ create archives, and other tasks to drive the build. The toolchain
+ utilities available are determined by the languages enabled. In normal
+ builds, CMake automatically determines the toolchain for host builds
+ based on system introspection and defaults. In cross-compiling
+ scenarios, a toolchain file may be specified with information about
+ compiler and utility paths.
+ Variables and Properties
+ Several variables relate to the language components of a toolchain which
+ are enabled. CMAKE_<LANG>_COMPILER is the full path to the compiler used
+ for <LANG>. CMAKE_<LANG>_COMPILER_ID is the identifier used by CMake for
+ the compiler and CMAKE_<LANG>_COMPILER_VERSION is the version of the compiler.
+
+ The CMAKE_<LANG>_FLAGS variables and the configuration-specific equivalents
+ contain flags that will be added to the compile command when compiling a
+ file of a particular language.
+
+ As the linker is invoked by the compiler driver, CMake needs a way to
+ determine which compiler to use to invoke the linker. This is calculated
+ by the LANGUAGE of source files in the target, and in the case of static
+ libraries, the language of the dependent libraries. The choice CMake makes
+ may be overridden with the LINKER_LANGUAGE target property.
+
+ See the CMake help for more information on using toolchain files.
+
+ To use a toolchain file with the supplied cmake scripts, see the
+ HDF5options.cmake file under the toolchain section.
+
Notes: CMake and HDF5
1. Using CMake for building and using HDF5 is under active development.