From b7227657f2bad367a82e12b8a8895e0f260ed952 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 3 Apr 2020 08:50:40 -0500 Subject: Add missing header include --- tools/libtest/h5tools_test_utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 2f9958b..8956bb5 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -16,6 +16,7 @@ * Jacob Smith 2017-11-10 */ +#include "h5tools.h" #include "h5tools_utils.h" #include "h5test.h" -- cgit v0.12 From 7a41367a130a615f06e5c35154abbdc621c7c6b7 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 3 Apr 2020 12:57:56 -0500 Subject: Update release note for CMake warnings --- release_docs/RELEASE.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index ff1d99b..d30a0d6 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -70,6 +70,8 @@ New Features that are chosen by the CMake option:HDF5_ENABLE_DEV_WARNINGS or the configure option:--enable-developer-warnings. + In addition, CMake no longer applies these warnings for tests and examples. + (ADB - 2020/03/24, TRILAB-192) - Added test script for file size compare -- cgit v0.12 From 57f5d00a43421e4d2847d55560e4015f28cf162f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 5 Apr 2020 10:50:08 -0500 Subject: TRILAB-192 add c++ and fortran warnings build systems one file --- CMakeLists.txt | 1 + MANIFEST | 11 + c++/src/CMakeLists.txt | 8 +- c++/test/CMakeLists.txt | 1 + config/cmake/HDFCompilerFlags.cmake | 37 +- config/cmake/HDFFortranCompilerFlags.cmake | 131 +++++ config/gnu-cxxflags | 885 ++++++----------------------- config/gnu-fflags | 50 +- config/gnu-flags | 52 +- config/gnu-warnings/cxx-general | 19 + config/gnu-warnings/gfort-4.4 | 2 + config/gnu-warnings/gfort-4.5 | 1 + config/gnu-warnings/gfort-4.7 | 2 + config/gnu-warnings/gfort-4.8 | 5 + config/gnu-warnings/gfort-5 | 1 + config/gnu-warnings/gfort-6 | 1 + config/gnu-warnings/gfort-8 | 1 + config/gnu-warnings/gfort-general | 12 + config/intel-ifort-general | 1 + config/intel-warnings-general | 8 - fortran/src/CMakeLists.txt | 6 +- fortran/test/CMakeLists.txt | 117 ++-- fortran/testpar/CMakeLists.txt | 6 +- hl/c++/src/CMakeLists.txt | 12 +- hl/c++/test/CMakeLists.txt | 1 + hl/fortran/examples/CMakeLists.txt | 15 +- hl/fortran/src/CMakeLists.txt | 37 +- hl/fortran/test/CMakeLists.txt | 15 +- hl/src/CMakeLists.txt | 12 +- hl/test/CMakeLists.txt | 4 + hl/tools/gif2h5/CMakeLists.txt | 4 + hl/tools/h5watch/CMakeLists.txt | 5 + java/src/jni/CMakeLists.txt | 4 +- src/CMakeLists.txt | 8 +- test/CMakeLists.txt | 18 +- testpar/CMakeLists.txt | 2 + tools/lib/CMakeLists.txt | 8 +- tools/libtest/CMakeLists.txt | 1 + tools/src/h5diff/CMakeLists.txt | 2 + 39 files changed, 581 insertions(+), 925 deletions(-) create mode 100644 config/cmake/HDFFortranCompilerFlags.cmake create mode 100644 config/gnu-warnings/cxx-general create mode 100644 config/gnu-warnings/gfort-4.4 create mode 100644 config/gnu-warnings/gfort-4.5 create mode 100644 config/gnu-warnings/gfort-4.7 create mode 100644 config/gnu-warnings/gfort-4.8 create mode 100644 config/gnu-warnings/gfort-5 create mode 100644 config/gnu-warnings/gfort-6 create mode 100644 config/gnu-warnings/gfort-8 create mode 100644 config/gnu-warnings/gfort-general create mode 100644 config/intel-ifort-general diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bad805..a82b896 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -961,6 +961,7 @@ set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) name ## _") if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/fortran") option (HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF) if (HDF5_BUILD_FORTRAN) + include (${HDF_RESOURCES_DIR}/HDFFortranCompilerFlags.cmake) include (${HDF_RESOURCES_EXT_DIR}/HDFUseFortran.cmake) message (STATUS "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") diff --git a/MANIFEST b/MANIFEST index 7078128..ddb6df2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -164,6 +164,7 @@ ./config/gnu-warnings/7 ./config/gnu-warnings/8 ./config/gnu-warnings/9 +./config/gnu-warnings/cxx-general ./config/gnu-warnings/developer-4.5 ./config/gnu-warnings/developer-4.6 ./config/gnu-warnings/developer-4.7 @@ -175,12 +176,21 @@ ./config/gnu-warnings/error-8 ./config/gnu-warnings/error-general ./config/gnu-warnings/general +./config/gnu-warnings/gfort-general +./config/gnu-warnings/gfort-4.4 +./config/gnu-warnings/gfort-4.5 +./config/gnu-warnings/gfort-4.7 +./config/gnu-warnings/gfort-4.8 +./config/gnu-warnings/gfort-5 +./config/gnu-warnings/gfort-6 +./config/gnu-warnings/gfort-8 ./config/gnu-warnings/no-developer-4.5 ./config/gnu-warnings/no-developer-4.6 ./config/gnu-warnings/no-developer-4.7 ./config/gnu-warnings/no-developer-4.8 ./config/gnu-warnings/no-developer-8 ./config/gnu-warnings/no-developer-general +./config/intel-ifort-general ./config/intel-warnings-general ./config/site-specific/BlankForm @@ -3392,6 +3402,7 @@ ./config/cmake/hdf5-config.cmake.in ./config/cmake/hdf5-config-version.cmake.in ./config/cmake/HDFCompilerFlags.cmake +./config/cmake/HDFFortranCompilerFlags.cmake ./config/cmake/HDF5_Process_Flex_Files.cmake ./config/cmake/HDF5Macros.cmake ./config/cmake/HDF5UseFortran.cmake diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index fa15c9e..058f457 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -90,9 +90,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_CPP_LIB_TARGET} - PRIVATE "${HDF5_CMAKE_CXX_FLAGS}" - ) + target_compile_options(${HDF5_CPP_LIB_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(${HDF5_CPP_LIB_TARGET} PRIVATE $<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings ) @@ -110,9 +108,7 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_CPP_LIBSH_TARGET} - PRIVATE "${HDF5_CMAKE_CXX_FLAGS}" - ) + target_compile_options(${HDF5_CPP_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(${HDF5_CPP_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index 29534a7..ca2295e 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -39,6 +39,7 @@ configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @O add_executable (cpp_testhdf5 ${CPP_TEST_SOURCES} ) target_include_directories (cpp_testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +target_compile_options(cpp_testhdf5 PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(cpp_testhdf5 PRIVATE $<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings ) diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 03c6936..79e2bd2 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -133,6 +133,9 @@ if (NOT MSVC) elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") + endif () ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") # gcc automatically inlines based on the optimization level # this is just a failsafe @@ -302,6 +305,9 @@ if (HDF5_ENABLE_ALL_WARNINGS) else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) + endif () endif () endif () endif () @@ -322,6 +328,9 @@ if (HDF5_ENABLE_GROUPZERO_WARNINGS) else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS0}) + endif () endif () endif () endif () @@ -340,7 +349,12 @@ if (HDF5_ENABLE_GROUPONE_WARNINGS) list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2") endif () else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS1}) + endif () + endif () endif () endif () @@ -358,7 +372,12 @@ if (HDF5_ENABLE_GROUPTWO_WARNINGS) list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") endif () else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS2}) + endif () + endif () endif () endif () @@ -376,7 +395,12 @@ if (HDF5_ENABLE_GROUPTHREE_WARNINGS) list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4") endif () else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS3}) + endif () + endif () endif () endif () @@ -387,7 +411,12 @@ option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) if (HDF5_ENABLE_GROUPFOUR_WARNINGS) message (STATUS "....Group Four warnings are enabled") if (NOT MSVC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS4}) + endif () + endif () endif () endif () diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake new file mode 100644 index 0000000..8d59cd0 --- /dev/null +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -0,0 +1,131 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +macro (ADD_H5_FFLAGS h5_fflag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_fflag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_fflag_var=${${h5_fflag_var}}") +endmacro () + +message (STATUS "Warnings Configuration: default: ${CMAKE_Fortran_FLAGS}") + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) +if (HDF5_DISABLE_COMPILER_WARNINGS) + message (STATUS "....Compiler warnings are suppressed") + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /W0") + endif () + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif () + # Borland uses -w- to suppress warnings. + if (BORLAND) + set (HDF5_WARNINGS_BLOCKED 1) + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w-") + endif () + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w") + endif () +endif () + +#----------------------------------------------------------------------------- +# HDF5 library compile options +#----------------------------------------------------------------------------- + +# General flags +if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-ifort-general") + list (APPEND CMAKE_Fortran_FLAGS "-stand f08 -free -implicitnone") +elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") + list (APPEND CMAKE_Fortran_FLAGS "-ffree-form -std=f2008 -fimplicit-none") +elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") + list (APPEND CMAKE_Fortran_FLAGS "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03") +endif () +message (STATUS "CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}") + +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + # Append warning flags that only gcc 4.4+ knows about + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.4") +endif () + +# Append more extra warning flags that only gcc 4.5+ know about +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.5) + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.5") +endif () + +# Append more extra warning flags that only gcc 4.6+ know about +#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) +# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.6") +#endif () + +# Append more extra warning flags that only gcc 4.7+ know about +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.7") +endif () + +# Append more extra warning flags that only gcc 4.8+ know about +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") +endif () + +# Append more extra warning flags that only gcc 4.9+ know about +#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) +# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") +#endif () + +# Append more extra warning flags that only gcc 5.1+ know about +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") +endif () + +# Append more extra warning flags that only gcc 6.x+ know about +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") +endif () + +# Append more extra warning flags that only gcc 7.x+ know about +#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) +# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") +#endif () + +# Append more extra warning flags that only gcc 8.x+ know about +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) + ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") +endif () + +# Append more extra warning flags that only gcc 9.x+ know about +#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) +# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") +#endif () + diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index f8a6d8c..9ae38f6 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- shell-script -*- # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -17,19 +17,51 @@ # if the compiler is not GNU; otherwise `cxx_flags_set' is set to `yes' # +# +# For now, do not promote any warnings to errors. +# +PROMOTE_ERRORS_DFLT=no + +# +# This filter rewrites -Werror= as -W, in that way demoting warnings +# promoted to errors back to warnings, if PROMOTE_ERRORS is no. +# +demote_errors() +{ + if [ ${PROMOTE_ERRORS:-${PROMOTE_ERRORS_DFLT}} = no ]; then + sed 's,-Werror=,-W,g' + else + cat + fi +} + +# +# Prepend `$srcdir/config/gnu-warnings/` to the filename suffix(es) given as +# subroutine argument(s), remove comments starting with # and ending +# at EOL, replace spans of whitespace (including newlines) with spaces, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_gnu_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + done) + IFS=' ' echo "$*" +} + # Get the compiler version in a way that works for g++ # unless a compiler version is already known # # cxx_vendor: The compiler name: g++ # cxx_version: Version number: 2.91.60, 2.7.2.1 # -if test X = "X$cxx_flags_set"; then +if test "X-" = "X-$cxx_flags_set"; then # PathScale compiler spits out gcc version string too. Need to # filter it out. # icc beginning with version 12 includes a "gcc version compatiblilty" - # string, causing the gcc H5_CFLAGS to be erroneously added. The line + # string, causing the gcc H5_CXXFLAGS to be erroneously added. The line # "grep -v 'icc version'" causes the discarding of any output - # containing 'icc version'. The cc_version for icc is correctly determined + # containing 'icc version'. The cxx_version for icc is correctly determined # and flags added in the intel-flags script. cxx_version="`$CXX $CXXFLAGS $H5_CXXFLAGS -v 2>&1 | grep -v 'PathScale' |\ grep -v '^icc.*version' |\ @@ -37,13 +69,13 @@ if test X = "X$cxx_flags_set"; then cxx_vendor=`echo $cxx_version |sed 's/\([a-z]*\).*/\1/'` cxx_version=`echo $cxx_version |sed 's/[-a-z]//g'` if test X = "X$cxx_vendor" -a X != "X$cxx_version"; then - cxx_vendor=g++ + cxx_vendor=g++ fi if test "-" != "$cxx_vendor-$cxx_version"; then - echo "compiler '$CXX' is GNU $cxx_vendor-$cxx_version" + echo "compiler '$CXX' is GNU $cxx_vendor-$cxx_version" fi - # Some version numbers + # Get the compiler version numbers cxx_vers_major=`echo $cxx_version | cut -f1 -d.` cxx_vers_minor=`echo $cxx_version | cut -f2 -d.` cxx_vers_patch=`echo $cxx_version | cut -f3 -d.` @@ -53,10 +85,12 @@ if test X = "X$cxx_flags_set"; then cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` fi -# Common g++ flags for various situations -case "$cxx_vendor-$cxx_version" in - g++*) - # Architecture-specific flags +if test "X-g++" = "X-$cxx_vendor"; then + + ############################### + # Architecture-specific flags # + ############################### + arch= case "$host_os-$host_cpu" in # FreeBSD sets the information from "uname -m" to the general machine @@ -84,742 +118,197 @@ case "$cxx_vendor-$cxx_version" in ;; esac - # Host-specific flags - case "`hostname`" in - sleipnir.ncsa.uiuc.edu) - arch="$arch -pipe" - ;; - esac - - # General (copied from H5_CFLAGS) - H5_CXXFLAGS="$H5_CXXFLAGS $arch -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wredundant-decls -Winline" - # C++-specific - H5_CXXFLAGS="$H5_CXXFLAGS -Wsign-promo -Woverloaded-virtual -Wold-style-cast -Weffc++ -Wreorder -Wnon-virtual-dtor -Wctor-dtor-privacy -Wabi" + H5_CXXFLAGS="$H5_CXXFLAGS $arch + + ############## + # Production # + ############## - # Production # NDEBUG is handled explicitly by the configure script - case "$cxx_vendor-$cxx_version" in - g++-[34].*) + if test $cxx_vers_major -le 4; then PROD_CXXFLAGS= - ;; - g++-[56].*) + else PROD_CXXFLAGS="-fstdarg-opt" - ;; - *) - PROD_CXXFLAGS="-finline-functions" - ;; - esac + fi + + ######### + # Debug # + ######### - # Debug # NDEBUG is handled explicitly by the configure script - # -g is hanled by the symbols flags - case "$cxx_vendor-$cxx_version" in - g++-[56].*) - DEBUG_CXXFLAGS="-ftrapv -fno-common" - ;; - *) + # -g is handled by the symbols flags + if test $cxx_vers_major -le 4; then DEBUG_CXXFLAGS= - ;; - esac + else + DEBUG_CXXFLAGS="-ftrapv -fno-common" + fi + + ########### + # Symbols # + ########### - # Symbols NO_SYMBOLS_CXXFLAGS="-s" SYMBOLS_CXXFLAGS="-g" - # Profile + ############# + # Profiling # + ############# + PROFILE_CXXFLAGS="-pg" - # Optimization - case "$cxx_vendor-$cxx_version" in - g++-[34].*) + ################ + # Optimization # + ################ + + if test $cxx_vers_major -le 4; then HIGH_OPT_CXXFLAGS="-O3" DEBUG_OPT_CXXFLAGS= - ;; - g++-[56].*) + else HIGH_OPT_CXXFLAGS="-O3" DEBUG_OPT_CXXFLAGS="-Og" - ;; - *) - HIGH_OPT_CXXFLAGS="-O" - DEBUG_OPT_CXXFLAGS= - ;; - esac + fi NO_OPT_CXXFLAGS="-O0" - # Flags are set - cxx_flags_set=yes - ;; -esac - -# Version-specific g++ flags -# -# Please follow the pattern below by adding new versions at the top, copying -# the information from the previous version and adding modifications to that. -case "$cxx_vendor-$cxx_version" in - -# Closer to the g++ 5.2 release, we should check for additional flags to -# include and break it out into it's own section, like the other versions -# below. -QAK - g++-[56]*) + ############ + # Warnings # + ############ - # Append warning flags from gcc-3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" +# First load the C warnings then add CXX warnings (if needed) - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" + ########### + # General # + ########### - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments general)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-general)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-general)" + #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-cxx-general)" - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" + ###################### + # Developer warnings # + ###################### - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" + NO_DEVELOPER_WARNING_CXXFLAGS=$(load_gnu_arguments no-developer-general) + DEVELOPER_WARNING_CXXFLAGS=$(load_gnu_arguments developer-general) - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" + ####################### + # gcc 4 special cases # + ####################### - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" - - # Append more extra warning flags that only gcc 4.8+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsuggest-attribute=format" + # GCC 4.2 through 4.6 + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.6)" + fi - # Append more extra warning flags that only gcc 4.9+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdate-time -Wopenmp-simd" + # GCC 4.2 through 4.3 + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.3)" + fi - # (There was no release of gcc 5.0) + # GCC 4.5 through 4.6 + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5-4.6)" + fi - # Append more extra warning flags that only gcc 5.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Warray-bounds=2" - ;; + # GCC 4.2 through 4.4 + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -a $cc_vers_major -eq 4 -a $cc_vers_minor -le 4; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.4)" + fi - g++-4.9*) - # Append warning flags + # GCC 4.2 through the end of GCC 4 series + if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.last)" + fi - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" + ############################# + # Version-specific warnings # + ############################# - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" + # gcc >= 4.3 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.3)" + fi - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" + # gcc >= 4.4 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.4)" + fi - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" + # gcc >= 4.5 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.5)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.5)" + fi - # Append warning flags from gcc 3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" + # gcc >= 4.6 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 6; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.6)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.6)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.6)" + fi - # Append warning flags from gcc 3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" + # gcc >= 4.7 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.7)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.7)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.7)" + fi - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" + # gcc >= 4.8 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.8)" + fi - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" + # gcc >= 4.9 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.9)" + fi - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" + # gcc >= 5 + if test $cc_vers_major -ge 5; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 5)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-5)" + fi - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" + # gcc >= 6 + if test $cc_vers_major -ge 6; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 6)" + fi - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" + # gcc >= 7 + if test $cc_vers_major -ge 7; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 7)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-7)" + fi - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" + # gcc 8 + if test $cc_vers_major -ge 8; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 8)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-8)" + fi - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" + # gcc 9 + if test $cc_vers_major -ge 9; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)" + fi - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" + ################# + # Flags are set # + ################# + cxx_flags_set=yes +fi - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" +# Version-specific g++ flags - # Append more extra warning flags that only gcc 4.8+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsuggest-attribute=format" # Append more extra warning flags that only gcc 4.9+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdate-time -Wopenmp-simd" - ;; - - g++-4.8*) - # Append warning flags - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" - - # Append more extra warning flags that only gcc 4.8+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsuggest-attribute=format" - ;; - - g++-4.7*) - # Append warning flags - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" - ;; - - g++-4.6*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ knows about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-aliasing -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - ;; - - g++-4.5*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc4.0+ knows about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-aliasing -Wstrict-overflow=5" - ;; - - g++-4.4*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - ;; - - g++-4.3*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations -Wvolatile-register-var" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wvla" - ;; - - g++-4.2*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations -Wvolatile-register-var" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - ;; - - g++-4.1.*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations -Wvolatile-register-var" - ;; - - g++-4.0*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - ;; - - g++-3.4*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append more extra warning flags that only gcc3.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - ;; - - g++-3.3*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append more extra warning flags that only gcc3.3+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - ;; - - g++-3.2*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append more extra warning flags that only gcc3.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - ;; - - g++-3*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append some extra warning flags that only gcc3+ know about - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - ;; -esac + -Wopenmp-simd" # Clear cxx info if no flags set if test "X$cxx_flags_set" = "X"; then diff --git a/config/gnu-fflags b/config/gnu-fflags index 185a4c6..2859158 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -17,6 +17,20 @@ # if the compiler is not GNU; otherwise `f9x_flags_set' is set to `yes' # +# +# Prepend `$srcdir/config/gnu-warnings/` to the filename suffix(es) given as +# subroutine argument(s), remove comments starting with # and ending +# at EOL, replace spans of whitespace (including newlines) with spaces, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_gnu_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + done) + IFS=' ' echo "$*" +} + # Get the compiler version in a way that works for GNU fortran # gfortran unless a compiler version is already known # @@ -95,8 +109,8 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # Symbols # ########### - SYMBOLS_FCFLAGS="-g" NO_SYMBOLS_FCFLAGS="-s" + SYMBOLS_FCFLAGS="-g" ############# # Profiling # @@ -125,8 +139,7 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # General # ########### - H5_FCFLAGS="$H5_FCFLAGS -pedantic -Wall -Wextra -Wunderflow -Wimplicit-interface -Wsurprising" - H5_FCFLAGS="$H5_FCFLAGS -Waliasing -Wcharacter-truncation" + H5_FCFLAGS="$H5_CFLAGS $(load_gnu_arguments gfort-general)" ############################# # Version-specific warnings # @@ -134,48 +147,45 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # gfortran 4.3 (nothing new) - # gfortran 4.4 + # gfortran >= 4.4 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 4; then - H5_FCFLAGS="$H5_FCFLAGS -Warray-temporaries -Wintrinsics-std" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.4)" fi - # gfortran 4.5 + # gfortran >= 4.5 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 5; then - H5_FCFLAGS="$H5_FCFLAGS -Wimplicit-procedure" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.5)" fi # gfortran 4.6 (nothing new) - # gfortran 4.7 + # gfortran >= 4.7 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 7; then - H5_FCFLAGS="$H5_FCFLAGS -Wreal-q-constant -Wfunction-elimination" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.7)" fi - # gfortran 4.8 + # gfortran >= 4.8 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 8; then - H5_FCFLAGS="$H5_FCFLAGS -Wrealloc-lhs -Wrealloc-lhs-all" - # Turn off warnings for passing non-ANSI types to BIND(). - # We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. - H5_FCFLAGS="$H5_FCFLAGS -Wno-c-binding-type" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.8)" fi # gfortran 4.9 (nothing new) - # gfortran 5 + # gfortran >= 5 if test $f9x_vers_major -ge 5; then - H5_FCFLAGS="$H5_FCFLAGS -Wuse-without-only" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-5)" fi - # gfortran 6 + # gfortran >= 6 if test $f9x_vers_major -ge 6; then - H5_FCFLAGS="$H5_FCFLAGS -Winteger-division" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-6)" fi # gfortran 7 (nothing new) - # gfortran 8 + # gfortran >= 8 if test $f9x_vers_major -ge 8; then - H5_FCFLAGS="$H5_FCFLAGS -Wfrontend-loop-interchange" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-8)" fi # gfortran 9 (nothing new) diff --git a/config/gnu-flags b/config/gnu-flags index ca0e1b4..c2904fe 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -36,12 +36,12 @@ demote_errors() } # -# Prepend `$srcdir/config/gnu-` to the filename suffix(es) given as +# Prepend `$srcdir/config/gnu-warnings/` to the filename suffix(es) given as # subroutine argument(s), remove comments starting with # and ending # at EOL, replace spans of whitespace (including newlines) with spaces, # and re-emit the file(s) thus filtered on the standard output stream. # -load_gcc_arguments() +load_gnu_arguments() { set -- $(for arg; do sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors @@ -49,7 +49,6 @@ load_gcc_arguments() IFS=' ' echo "$*" } - # Get the compiler version in a way that works for gcc # unless a compiler version is already known # @@ -189,15 +188,15 @@ if test "X-gcc" = "X-$cc_vendor"; then # General # ########### - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments general)" - H5_ECFLAGS="$H5_ECFLAGS $(load_gcc_arguments error-general)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments general)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)" ###################### # Developer warnings # ###################### - NO_DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments no-developer-general) - DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments developer-general) + NO_DEVELOPER_WARNING_CFLAGS=$(load_gnu_arguments no-developer-general) + DEVELOPER_WARNING_CFLAGS=$(load_gnu_arguments developer-general) ####################### # gcc 4 special cases # @@ -205,27 +204,27 @@ if test "X-gcc" = "X-$cc_vendor"; then # GCC 4.2 through 4.6 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.6)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.2-4.6)" fi # GCC 4.2 through 4.3 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.3)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.2-4.3)" fi # GCC 4.5 through 4.6 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.5-4.6)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.5-4.6)" fi # GCC 4.2 through 4.4 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -a $cc_vers_major -eq 4 -a $cc_vers_minor -le 4; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.4)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.2-4.4)" fi # GCC 4.2 through the end of GCC 4 series if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.last)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.2-4.last)" fi ############################# @@ -234,75 +233,75 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc >= 4.3 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.3)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.3)" fi # gcc >= 4.4 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.4)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.4)" fi # gcc >= 4.5 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.5)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.5)" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.5)" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.5)" fi # gcc >= 4.6 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 6; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.6)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.6)" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.6)" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.6)" fi # gcc >= 4.7 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.7)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.7)" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.7)" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.7)" fi # gcc >= 4.8 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.8)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.8)" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.8)" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.8)" fi # gcc >= 4.9 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.9)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 4.9)" fi # gcc >= 5 if test $cc_vers_major -ge 5; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 5)" - H5_ECFLAGS="$H5_ECFLAGS $(load_gcc_arguments error-5)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 5)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-5)" fi # gcc >= 6 if test $cc_vers_major -ge 6; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 6)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 6)" fi # gcc >= 7 if test $cc_vers_major -ge 7; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 7)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 7)" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-7)" fi # gcc 8 if test $cc_vers_major -ge 8; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 8)" - H5_ECFLAGS="$H5_ECFLAGS $(load_gcc_arguments error-8)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 8)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-8)" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-8)" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-8)" fi # gcc 9 if test $cc_vers_major -ge 9; then - H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 9)" + H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments 9)" fi ################# @@ -316,3 +315,4 @@ if test "X$cc_flags_set" = "X"; then cc_vendor= cc_version= fi + diff --git a/config/gnu-warnings/cxx-general b/config/gnu-warnings/cxx-general new file mode 100644 index 0000000..7e0655c --- /dev/null +++ b/config/gnu-warnings/cxx-general @@ -0,0 +1,19 @@ +# Note that some of the flags listed here really should be developer +# flags (listed in separate files, gnu-warnings-developer*) but we put +# them here because they are not raised by the current code and we'd like to +# know if they do start showing up. +# +# 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 from the +# environment variable at configure time. +-Wabi +-Wctor-dtor-privacy +-Weffc++ +##-Wendif-labels" +-Wnon-virtual-dtor +-Wold-style-cast +-Woverloaded-virtual +-Wreorder +-Wsign-promo +##-Wunreachable-code" +##-Wvariadic-macros - diff --git a/config/gnu-warnings/gfort-4.4 b/config/gnu-warnings/gfort-4.4 new file mode 100644 index 0000000..59fe9a2 --- /dev/null +++ b/config/gnu-warnings/gfort-4.4 @@ -0,0 +1,2 @@ +-Warray-temporaries +-Wintrinsics-std \ No newline at end of file diff --git a/config/gnu-warnings/gfort-4.5 b/config/gnu-warnings/gfort-4.5 new file mode 100644 index 0000000..55ae1d7 --- /dev/null +++ b/config/gnu-warnings/gfort-4.5 @@ -0,0 +1 @@ +-Wimplicit-procedure \ No newline at end of file diff --git a/config/gnu-warnings/gfort-4.7 b/config/gnu-warnings/gfort-4.7 new file mode 100644 index 0000000..a7532bb --- /dev/null +++ b/config/gnu-warnings/gfort-4.7 @@ -0,0 +1,2 @@ +-Wreal-q-constant +-Wfunction-elimination diff --git a/config/gnu-warnings/gfort-4.8 b/config/gnu-warnings/gfort-4.8 new file mode 100644 index 0000000..1fddee0 --- /dev/null +++ b/config/gnu-warnings/gfort-4.8 @@ -0,0 +1,5 @@ +-Wrealloc-lhs +-Wrealloc-lhs-all +# Turn off warnings for passing non-ANSI types to BIND(). +# We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. +-Wno-c-binding-type" diff --git a/config/gnu-warnings/gfort-5 b/config/gnu-warnings/gfort-5 new file mode 100644 index 0000000..c5d3850 --- /dev/null +++ b/config/gnu-warnings/gfort-5 @@ -0,0 +1 @@ +-Wuse-without-only diff --git a/config/gnu-warnings/gfort-6 b/config/gnu-warnings/gfort-6 new file mode 100644 index 0000000..f70466c --- /dev/null +++ b/config/gnu-warnings/gfort-6 @@ -0,0 +1 @@ +-Winteger-division diff --git a/config/gnu-warnings/gfort-8 b/config/gnu-warnings/gfort-8 new file mode 100644 index 0000000..5097365 --- /dev/null +++ b/config/gnu-warnings/gfort-8 @@ -0,0 +1 @@ +-Wfrontend-loop-interchange diff --git a/config/gnu-warnings/gfort-general b/config/gnu-warnings/gfort-general new file mode 100644 index 0000000..4028316 --- /dev/null +++ b/config/gnu-warnings/gfort-general @@ -0,0 +1,12 @@ +# Note that some of the flags listed here really should be developer +# flags (listed in separate files, gnu-warnings-developer*) but we put +# them here because they are not raised by the current code and we'd like to +# know if they do start showing up. +-Waliasing +-Wall +-Wcharacter-truncation +-Wextra +-Wimplicit-interface +-Wsurprising +-Wunderflow +-pedantic diff --git a/config/intel-ifort-general b/config/intel-ifort-general new file mode 100644 index 0000000..a9da0e5 --- /dev/null +++ b/config/intel-ifort-general @@ -0,0 +1 @@ +-warn:all diff --git a/config/intel-warnings-general b/config/intel-warnings-general index f4ed24c..d0b2e25 100644 --- a/config/intel-warnings-general +++ b/config/intel-warnings-general @@ -1,10 +1,2 @@ -# Note that some of the flags listed here really should be developer -# flags (listed in separate files, gnu-warnings-developer*) but we put -# them here because they are not raised by the current code and we'd like to -# know if they do start showing up. -# -# 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 from the -# environment variable at configure time. -Wall -Wcheck \ No newline at end of file diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index b5d1a60..4417567 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -156,6 +156,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) + target_compile_options(${HDF5_F90_C_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC) target_link_libraries (${HDF5_F90_C_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIB_TARGET}") @@ -173,9 +174,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_definitions(${HDF5_F90_C_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_F90_C_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_F90_C_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIBSH_TARGET}") diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 5657323..b458882 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -13,8 +13,7 @@ target_include_directories (H5_test_buildiface ) #if (BUILD_SHARED_LIBS) # target_compile_definitions(H5_test_buildiface -# PRIVATE -# $<$:/MT> +# PRIVATE $<$:/MT> # ) #endif () if(MSVC) @@ -49,6 +48,7 @@ if (NOT BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) + target_compile_options(${HDF5_F90_C_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIB_TARGET} STATIC) target_link_libraries (${HDF5_F90_C_TEST_LIB_TARGET} PRIVATE ${HDF5_F90_C_LIB_TARGET} @@ -65,9 +65,8 @@ else () PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_definitions(${HDF5_F90_C_TEST_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_F90_C_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_F90_C_TEST_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_F90_C_TEST_LIBSH_TARGET} PRIVATE ${HDF5_F90_C_LIBSH_TARGET} @@ -129,10 +128,8 @@ endif () if (NOT BUILD_SHARED_LIBS) add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC ${HDF5_F90_TF_SOURCES}) target_include_directories (${HDF5_F90_TEST_LIB_TARGET} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - INTERFACE - "$/include/static>" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + INTERFACE "$/include/static>" ) target_compile_definitions(${HDF5_F90_TEST_LIB_TARGET} PRIVATE @@ -162,21 +159,17 @@ if (NOT BUILD_SHARED_LIBS) else () add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED ${HDF5_F90_TF_SOURCES_SHARED}) target_include_directories (${HDF5_F90_TEST_LIBSH_TARGET} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - INTERFACE - "$/include/shared>" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + INTERFACE "$/include/shared>" ) target_compile_definitions(${HDF5_F90_TEST_LIBSH_TARGET} - PUBLIC - "H5_BUILT_AS_DYNAMIC_LIB" + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$:BUILD_HDF5_TEST_DLL;HDF5F90_WINDOWS> $<$:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} - PUBLIC - ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + PUBLIC ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ) # set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -222,8 +215,7 @@ add_executable (testhdf5_fortran tHDF5.F90 ) target_compile_options(testhdf5_fortran - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) #set_property(TARGET testhdf5_fortran APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -236,12 +228,10 @@ if(MSVC) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (testhdf5_fortran - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" ) target_link_libraries (testhdf5_fortran - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> ) set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran @@ -251,12 +241,10 @@ if (NOT BUILD_SHARED_LIBS) add_dependencies (testhdf5_fortran ${HDF5_F90_TEST_LIB_TARGET}) else () target_include_directories (testhdf5_fortran - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" ) target_link_libraries (testhdf5_fortran - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> ) set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran @@ -276,8 +264,7 @@ add_executable (testhdf5_fortran_1_8 tHDF5_1_8.F90 ) target_compile_options(testhdf5_fortran_1_8 - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) #set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -290,12 +277,10 @@ if(MSVC) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (testhdf5_fortran_1_8 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" ) target_link_libraries (testhdf5_fortran_1_8 - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> ) set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran @@ -305,12 +290,10 @@ if (NOT BUILD_SHARED_LIBS) add_dependencies (testhdf5_fortran_1_8 ${HDF5_F90_TEST_LIB_TARGET}) else () target_include_directories (testhdf5_fortran_1_8 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" ) target_link_libraries (testhdf5_fortran_1_8 - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> ) set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran @@ -332,8 +315,7 @@ add_executable (fortranlib_test_F03 tHDF5_F03.F90 ) target_compile_options(fortranlib_test_F03 - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) #set_property(TARGET fortranlib_test_F03 APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -346,12 +328,10 @@ if(MSVC) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (fortranlib_test_F03 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" ) target_link_libraries (fortranlib_test_F03 - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> ) set_target_properties (fortranlib_test_F03 PROPERTIES LINKER_LANGUAGE Fortran @@ -361,12 +341,10 @@ if (NOT BUILD_SHARED_LIBS) add_dependencies (fortranlib_test_F03 ${HDF5_F90_TEST_LIB_TARGET}) else () target_include_directories (fortranlib_test_F03 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" ) target_link_libraries (fortranlib_test_F03 - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> ) set_target_properties (fortranlib_test_F03 PROPERTIES LINKER_LANGUAGE Fortran @@ -379,8 +357,7 @@ endif () #-- Adding test for fflush1 add_executable (fflush1 fflush1.F90) target_compile_options(fflush1 - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) #set_property(TARGET fflush1 APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -393,12 +370,10 @@ if(MSVC) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (fflush1 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/static + PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) target_link_libraries (fflush1 - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> ) set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran @@ -408,12 +383,10 @@ if (NOT BUILD_SHARED_LIBS) add_dependencies (fflush1 ${HDF5_F90_TEST_LIB_TARGET}) else () target_include_directories (fflush1 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared ) target_link_libraries (fflush1 - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> ) set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran @@ -426,8 +399,7 @@ endif () #-- Adding test for fflush2 add_executable (fflush2 fflush2.F90) target_compile_options (fflush2 - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) #set_property(TARGET fflush2 APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -440,12 +412,10 @@ if(MSVC) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (fflush2 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/static + PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) target_link_libraries (fflush2 - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> ) set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran @@ -455,12 +425,10 @@ if (NOT BUILD_SHARED_LIBS) add_dependencies (fflush2 ${HDF5_F90_TEST_LIB_TARGET}) else () target_include_directories (fflush2 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared ) target_link_libraries (fflush2 - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> ) set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran @@ -473,8 +441,7 @@ endif () #-- Adding test for vol_connector add_executable (vol_connector vol_connector.F90) target_compile_options(vol_connector - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) #set_property(TARGET vol_connector APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -487,12 +454,10 @@ if(MSVC) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (vol_connector - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/static + PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) target_link_libraries (vol_connector - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> ) set_target_properties (vol_connector PROPERTIES LINKER_LANGUAGE Fortran @@ -502,12 +467,10 @@ if (NOT BUILD_SHARED_LIBS) add_dependencies (vol_connector ${HDF5_F90_TEST_LIB_TARGET}) else () target_include_directories (vol_connector - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared ) target_link_libraries (vol_connector - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> + PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> ) set_target_properties (vol_connector PROPERTIES LINKER_LANGUAGE Fortran diff --git a/fortran/testpar/CMakeLists.txt b/fortran/testpar/CMakeLists.txt index 5c80fd6..740d30e 100644 --- a/fortran/testpar/CMakeLists.txt +++ b/fortran/testpar/CMakeLists.txt @@ -22,12 +22,10 @@ add_executable (parallel_test mdset.f90 ) target_include_directories (parallel_test - PRIVATE - ${TESTPAR_INCLUDES} + PRIVATE ${TESTPAR_INCLUDES} ) target_compile_options(parallel_test - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) if (NOT BUILD_SHARED_LIBS) target_link_libraries (parallel_test diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index 01c8126..fbabc86 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -14,9 +14,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_HL_CPP_LIB_TARGET} - PRIVATE "${HDF5_CMAKE_CXX_FLAGS}" - ) + target_compile_options(${HDF5_HL_CPP_LIB_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIB_TARGET} STATIC) target_link_libraries (${HDF5_HL_CPP_LIB_TARGET} PUBLIC ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIB_TARGET}") @@ -31,12 +29,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_HL_CPP_LIBSH_TARGET} - PRIVATE "${HDF5_CMAKE_CXX_FLAGS}" - ) - target_compile_definitions(${HDF5_HL_CPP_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_HL_CPP_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") + target_compile_definitions(${HDF5_HL_CPP_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_HL_CPP_LIBSH_TARGET} PUBLIC ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIBSH_TARGET}") diff --git a/hl/c++/test/CMakeLists.txt b/hl/c++/test/CMakeLists.txt index 9bf32ef..5c224a8 100644 --- a/hl/c++/test/CMakeLists.txt +++ b/hl/c++/test/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_HL_CPP_TEST CXX) add_executable (hl_ptableTest ${HDF5_HL_CPP_TEST_SOURCE_DIR}/ptableTest.cpp) +target_compile_options(hl_ptableTest PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_include_directories (hl_ptableTest PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_ptableTest STATIC) diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index 265d8db..684b02a 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -9,8 +9,7 @@ set (examples foreach (example ${examples}) add_executable (hl_f90_ex_${example} ${HDF5_HL_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) target_compile_options(hl_f90_ex_${example} - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) # set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -23,12 +22,10 @@ foreach (example ${examples}) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (hl_f90_ex_${example} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" ) target_link_libraries (hl_f90_ex_${example} - PRIVATE - ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} ) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran @@ -37,12 +34,10 @@ foreach (example ${examples}) ) else () target_include_directories (hl_f90_ex_${example} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" ) target_link_libraries (hl_f90_ex_${example} - PRIVATE - ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index d4979ba..fa8f442 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -62,6 +62,8 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) + target_compile_options(${HDF5_HL_F90_C_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_HL_F90_C_LIB_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} STATIC) target_link_libraries (${HDF5_HL_F90_C_LIB_TARGET} PUBLIC ${HDF5_F90_C_LIB_TARGET} ${HDF5_HL_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIB_TARGET}") @@ -78,9 +80,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_definitions(${HDF5_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_HL_F90_C_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_HL_F90_C_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_HL_F90_C_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_HL_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIBSH_TARGET}") @@ -161,20 +162,15 @@ endif () if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SOURCES}) target_include_directories (${HDF5_HL_F90_LIB_TARGET} - PRIVATE - "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$/include/static>" + PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;$<$:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$/include/static>" ) target_compile_definitions(${HDF5_HL_F90_LIB_TARGET} - PUBLIC - $<$:HDF5F90_WINDOWS> - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PUBLIC $<$:HDF5F90_WINDOWS> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_HL_F90_LIB_TARGET} - PUBLIC - ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET} + PUBLIC ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ) # set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -198,23 +194,18 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES_SHARED}) target_include_directories (${HDF5_HL_F90_LIBSH_TARGET} - PRIVATE - "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$/include/shared>" + PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;$<$:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$/include/shared>" ) target_compile_definitions(${HDF5_HL_F90_LIBSH_TARGET} - PUBLIC - "H5_BUILT_AS_DYNAMIC_LIB" + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$:BUILD_HDF5_HL_DLL;HDF5F90_WINDOWS> $<$:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_HL_F90_LIBSH_TARGET} - PUBLIC - ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} - PRIVATE - ${LINK_Fortran_LIBS} + PUBLIC ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} + PRIVATE ${LINK_Fortran_LIBS} ) # set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> diff --git a/hl/fortran/test/CMakeLists.txt b/hl/fortran/test/CMakeLists.txt index 269cefb..6b6ddf1 100644 --- a/hl/fortran/test/CMakeLists.txt +++ b/hl/fortran/test/CMakeLists.txt @@ -14,8 +14,7 @@ set (H5_TESTS macro (ADD_H5_FORTRAN_EXE file) add_executable (hl_f90_${file} ${file}.F90) target_compile_options(hl_f90_${file} - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> + PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) # set_property(TARGET hl_f90_${file} APPEND PROPERTY # LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> @@ -28,12 +27,10 @@ macro (ADD_H5_FORTRAN_EXE file) endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (hl_f90_${file} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" ) target_link_libraries (hl_f90_${file} - PRIVATE - ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} + PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ) set_target_properties (hl_f90_${file} PROPERTIES LINKER_LANGUAGE Fortran @@ -42,12 +39,10 @@ macro (ADD_H5_FORTRAN_EXE file) ) else () target_include_directories (hl_f90_${file} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" ) target_link_libraries (hl_f90_${file} - PRIVATE - ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} + PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ) set_target_properties (hl_f90_${file} PROPERTIES LINKER_LANGUAGE Fortran diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index 7975a1a..c4ddf19 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -38,9 +38,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_HL_LIB_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" - ) + target_compile_options(${HDF5_HL_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_HL_LIB_TARGET} STATIC) target_link_libraries (${HDF5_HL_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_HL_LIB_TARGET} ${HDF5_HL_LIB_NAME} STATIC 0) @@ -55,12 +53,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_HL_LIBSH_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" - ) - target_compile_definitions(${HDF5_HL_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_HL_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_HL_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_HL_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_HL_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_HL_LIBSH_TARGET} ${HDF5_HL_LIB_NAME} SHARED "HL") diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index 43fc312..b7eac09 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -19,6 +19,7 @@ configure_file (${HDF5_HL_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ON # -------------------------------------------------------------------- macro (HL_ADD_EXE hl_name) add_executable (hl_${hl_name} ${hl_name}.c) + target_compile_options(hl_${hl_name} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_${hl_name} STATIC) @@ -49,6 +50,7 @@ HL_ADD_EXE (test_h5do_compat) # test_packet has two source files add_executable (hl_test_packet test_packet.c test_packet_vlen.c) + target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_test_packet STATIC) @@ -73,6 +75,7 @@ set_target_properties (hl_test_packet PROPERTIES FOLDER test/hl) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (hl_gen_test_ds gen_test_ds.c) + target_compile_options(hl_gen_test_ds PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_gen_test_ds PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (hl_gen_test_ds STATIC) target_link_libraries (hl_gen_test_ds PRIVATE @@ -83,6 +86,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen) add_executable (hl_gen_test_ld gen_test_ld.c) + target_compile_options(hl_gen_test_ld PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_gen_test_ld PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (hl_gen_test_ld STATIC) target_link_libraries (hl_gen_test_ld PRIVATE diff --git a/hl/tools/gif2h5/CMakeLists.txt b/hl/tools/gif2h5/CMakeLists.txt index cc2ba68..0b895a3 100644 --- a/hl/tools/gif2h5/CMakeLists.txt +++ b/hl/tools/gif2h5/CMakeLists.txt @@ -16,6 +16,7 @@ set (GIF2H5_SOURCES #-- Add gif2hdf5 program if (NOT ONLY_SHARED_LIBS) add_executable (gif2h5 ${GIF2H5_SOURCES}) + target_compile_options(gif2h5 PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (gif2h5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (gif2h5 STATIC) target_link_libraries (gif2h5 PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) @@ -28,6 +29,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (gif2h5-shared ${GIF2H5_SOURCES}) + target_compile_options(gif2h5-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (gif2h5-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (gif2h5-shared SHARED) target_link_libraries (gif2h5-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET}) @@ -45,6 +47,7 @@ set (hdf2gif_SOURCES ) if (NOT ONLY_SHARED_LIBS) add_executable (h52gif ${hdf2gif_SOURCES}) + target_compile_options(h52gif PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h52gif PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h52gif STATIC) target_link_libraries (h52gif PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) @@ -57,6 +60,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (h52gif-shared ${hdf2gif_SOURCES}) + target_compile_options(h52gif-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h52gif-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h52gif-shared SHARED) target_link_libraries (h52gif-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} PRIVATE ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET}) diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt index 9329c97..c5ad976 100644 --- a/hl/tools/h5watch/CMakeLists.txt +++ b/hl/tools/h5watch/CMakeLists.txt @@ -11,6 +11,7 @@ set (H5WATCH_SOURCES #-- Add h5watch program if (NOT ONLY_SHARED_LIBS) add_executable (h5watch ${H5WATCH_SOURCES}) + target_compile_options(h5watch PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h5watch PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5watch STATIC) target_link_libraries (h5watch PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) @@ -19,6 +20,7 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) add_executable (h5watch-shared ${H5WATCH_SOURCES}) + target_compile_options(h5watch-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h5watch-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5watch-shared SHARED) target_link_libraries (h5watch-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET}) @@ -32,6 +34,7 @@ if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/swmr_check_compat_vfd.c ) add_executable (hl_swmr_check_compat_vfd ${hl_swmr_check_compat_vfd_SOURCES}) + target_compile_options(hl_swmr_check_compat_vfd PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_swmr_check_compat_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd STATIC) @@ -47,6 +50,7 @@ if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/extend_dset.c ) add_executable (extend_dset ${extend_dset_SOURCES}) + target_compile_options(extend_dset PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (extend_dset PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (extend_dset STATIC) @@ -58,6 +62,7 @@ if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) set_target_properties (extend_dset PROPERTIES FOLDER tools/hl) add_executable (h5watchgentest ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watchgentest.c) + target_compile_options(h5watchgentest PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h5watchgentest PRIVATE "${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5watchgentest STATIC) diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt index dc9b223..3f71122 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -79,9 +79,7 @@ add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JA target_include_directories (${HDF5_JAVA_JNI_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_JAVA_JNI_SOURCE_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" ) -target_compile_options(${HDF5_JAVA_JNI_LIB_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" -) +target_compile_options(${HDF5_JAVA_JNI_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED) target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f7d73a..3682caa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1137,9 +1137,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_LIB_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" - ) + target_compile_options(${HDF5_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_compile_definitions(${HDF5_LIB_TARGET} PUBLIC ${HDF_EXTRA_C_FLAGS} @@ -1176,9 +1174,7 @@ if (BUILD_SHARED_LIBS) PUBLIC "$<$:${HDFS_INCLUDE_DIR}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_LIBSH_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" - ) + target_compile_options(${HDF5_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_compile_definitions(${HDF5_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7929e2c..2568761 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,6 +32,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) + target_compile_options(${HDF5_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_TEST_LIB_TARGET} STATIC) target_link_libraries (${HDF5_TEST_LIB_TARGET} PUBLIC ${LINK_LIBS} ${HDF5_LIB_TARGET} @@ -50,9 +51,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_TEST_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_TEST_LIBSH_TARGET} PUBLIC ${LINK_LIBS} ${HDF5_LIBSH_TARGET} @@ -293,7 +293,9 @@ set (H5_TESTS macro (ADD_H5_EXE file) add_executable (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) + target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (${file} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (${file} STATIC) target_link_libraries (${file} PRIVATE ${HDF5_TEST_LIB_TARGET}) @@ -325,6 +327,7 @@ endforeach () ######### Also special handling of link libs ############# #-- Adding test for chunk_info add_executable (chunk_info ${HDF5_TEST_SOURCE_DIR}/chunk_info.c) +target_compile_options(chunk_info PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (chunk_info PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (chunk_info STATIC) @@ -337,6 +340,7 @@ set_target_properties (chunk_info PROPERTIES FOLDER test) #-- Adding test for direct_chunk add_executable (direct_chunk ${HDF5_TEST_SOURCE_DIR}/direct_chunk.c) +target_compile_options(direct_chunk PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (direct_chunk PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (direct_chunk STATIC) @@ -351,6 +355,7 @@ set_target_properties (direct_chunk PROPERTIES FOLDER test) ######### Special handling for multiple sources ############# #-- Adding test for testhdf5 add_executable (testhdf5 ${testhdf5_SOURCES}) +target_compile_options(testhdf5 PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (testhdf5 STATIC) @@ -363,6 +368,7 @@ set_target_properties (testhdf5 PROPERTIES FOLDER test) #-- Adding test for cache_image add_executable (cache_image ${cache_image_SOURCES}) +target_compile_options(cache_image PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (cache_image PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (cache_image STATIC) @@ -375,6 +381,7 @@ set_target_properties (cache_image PROPERTIES FOLDER test) #-- Adding test for ttsafe add_executable (ttsafe ${ttsafe_SOURCES}) +target_compile_options(ttsafe PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (ttsafe PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (ttsafe STATIC) @@ -393,6 +400,7 @@ set_target_properties (ttsafe PROPERTIES FOLDER test) ######### Special handling for extra link lib of threads ############# #-- Adding test for thread_id add_executable (thread_id ${HDF5_TEST_SOURCE_DIR}/thread_id.c) +target_compile_options(thread_id PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (thread_id PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (thread_id STATIC) @@ -476,6 +484,7 @@ endforeach () # This has to be copied to the test directory for execve() to find it # and it can't be renamed (i.e., no -shared). add_executable (accum_swmr_reader ${HDF5_TEST_SOURCE_DIR}/accum_swmr_reader.c) +target_compile_options(accum_swmr_reader PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (accum_swmr_reader PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (accum_swmr_reader STATIC) @@ -511,6 +520,7 @@ endif () ############################################################################## set (use_append_chunk_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_chunk.c ${HDF5_TEST_SOURCE_DIR}/use_common.c) add_executable (use_append_chunk ${use_append_chunk_SOURCES}) +target_compile_options(use_append_chunk PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (use_append_chunk PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (use_append_chunk STATIC) @@ -523,6 +533,7 @@ set_target_properties (use_append_chunk PROPERTIES FOLDER test) set (use_append_mchunks_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_mchunks.c ${HDF5_TEST_SOURCE_DIR}/use_common.c) add_executable (use_append_mchunks ${use_append_mchunks_SOURCES}) +target_compile_options(use_append_mchunks PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (use_append_mchunks PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (use_append_mchunks STATIC) @@ -535,6 +546,7 @@ set_target_properties (use_append_mchunks PROPERTIES FOLDER test) set (use_disable_mdc_flushes_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_disable_mdc_flushes.c) add_executable (use_disable_mdc_flushes ${use_disable_mdc_flushes_SOURCES}) +target_compile_options(use_disable_mdc_flushes PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (use_disable_mdc_flushes PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (use_disable_mdc_flushes STATIC) diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt index d88e27f..a9f45d5 100644 --- a/testpar/CMakeLists.txt +++ b/testpar/CMakeLists.txt @@ -22,6 +22,7 @@ set (testphdf5_SOURCES #-- Adding test for testhdf5 add_executable (testphdf5 ${testphdf5_SOURCES}) +target_compile_options(testphdf5 PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (testphdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" ) @@ -40,6 +41,7 @@ set_target_properties (testphdf5 PROPERTIES FOLDER test/par) MACRO (ADD_H5P_EXE file) add_executable (${file} ${HDF5_TEST_PAR_SOURCE_DIR}/${file}.c) + target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (${file} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" ) diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt index 306c033..ff9ca43 100644 --- a/tools/lib/CMakeLists.txt +++ b/tools/lib/CMakeLists.txt @@ -38,9 +38,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_TOOLS_LIB_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" - ) + target_compile_options(${HDF5_TOOLS_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") #target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5_TOOLS_DEBUG) #target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5DIFF_DEBUG) TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} STATIC) @@ -60,9 +58,7 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) - target_compile_options(${HDF5_TOOLS_LIBSH_TARGET} - PRIVATE "${HDF5_CMAKE_C_FLAGS}" - ) + target_compile_options(${HDF5_TOOLS_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_compile_definitions(${HDF5_TOOLS_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" #PRIVATE H5_TOOLS_DEBUG diff --git a/tools/libtest/CMakeLists.txt b/tools/libtest/CMakeLists.txt index 7246e66..3e0f671 100644 --- a/tools/libtest/CMakeLists.txt +++ b/tools/libtest/CMakeLists.txt @@ -5,6 +5,7 @@ project (HDF5_TOOLS_LIBTEST C) # Add the h5tools_utils test executables #----------------------------------------------------------------------------- add_executable (h5tools_test_utils ${HDF5_TOOLS_LIBTEST_SOURCE_DIR}/h5tools_test_utils.c) +target_compile_options(h5tools_test_utils PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories(h5tools_test_utils PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5tools_test_utils STATIC) diff --git a/tools/src/h5diff/CMakeLists.txt b/tools/src/h5diff/CMakeLists.txt index eec7246..4087ab4 100644 --- a/tools/src/h5diff/CMakeLists.txt +++ b/tools/src/h5diff/CMakeLists.txt @@ -42,6 +42,7 @@ if (H5_HAVE_PARALLEL) ${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/ph5diff_main.c ) target_include_directories (ph5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(ph5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (ph5diff STATIC) target_link_libraries (ph5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$:${MPI_C_LIBRARIES}>") set_target_properties (ph5diff PROPERTIES FOLDER tools) @@ -54,6 +55,7 @@ if (H5_HAVE_PARALLEL) ${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/ph5diff_main.c ) target_include_directories (ph5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(ph5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (ph5diff-shared SHARED) target_link_libraries (ph5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$:${MPI_C_LIBRARIES}>") set_target_properties (ph5diff-shared PROPERTIES FOLDER tools) -- cgit v0.12 From 2c2627e7f66ae9a7c333ad250101f97ae65178ab Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 5 Apr 2020 13:38:04 -0500 Subject: Flag construction must be after compiler detection --- CMakeLists.txt | 3 +- MANIFEST | 1 + config/cmake/HDFCXXCompilerFlags.cmake | 324 +++++++++++++++++++++++++++++ config/cmake/HDFCompilerFlags.cmake | 68 ------ config/cmake/HDFFortranCompilerFlags.cmake | 37 ++-- fortran/examples/CMakeLists.txt | 103 +++++---- fortran/src/CMakeLists.txt | 64 ++---- fortran/test/CMakeLists.txt | 195 ++++++----------- fortran/testpar/CMakeLists.txt | 12 +- hl/fortran/examples/CMakeLists.txt | 28 +-- hl/fortran/src/CMakeLists.txt | 30 +-- hl/fortran/test/CMakeLists.txt | 28 +-- 12 files changed, 507 insertions(+), 386 deletions(-) create mode 100644 config/cmake/HDFCXXCompilerFlags.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a82b896..b63d579 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -961,10 +961,10 @@ set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) name ## _") if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/fortran") option (HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF) if (HDF5_BUILD_FORTRAN) - include (${HDF_RESOURCES_DIR}/HDFFortranCompilerFlags.cmake) include (${HDF_RESOURCES_EXT_DIR}/HDFUseFortran.cmake) message (STATUS "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") + include (${HDF_RESOURCES_DIR}/HDFFortranCompilerFlags.cmake) include (${HDF_RESOURCES_DIR}/HDF5UseFortran.cmake) set (LINK_Fortran_LIBS ${LINK_LIBS}) @@ -1006,6 +1006,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") endif () include (${HDF_RESOURCES_EXT_DIR}/HDFUseCXX.cmake) + include (${HDF_RESOURCES_DIR}/HDFCXXCompilerFlags.cmake) if (CMAKE_NO_STD_NAMESPACE) set (H5_NO_STD 1) diff --git a/MANIFEST b/MANIFEST index ddb6df2..70e61ed 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3402,6 +3402,7 @@ ./config/cmake/hdf5-config.cmake.in ./config/cmake/hdf5-config-version.cmake.in ./config/cmake/HDFCompilerFlags.cmake +./config/cmake/HDFCXXCompilerFlags.cmake ./config/cmake/HDFFortranCompilerFlags.cmake ./config/cmake/HDF5_Process_Flex_Files.cmake ./config/cmake/HDF5Macros.cmake diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake new file mode 100644 index 0000000..504a171 --- /dev/null +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -0,0 +1,324 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS OFF) + +macro (ADD_H5_FLAGS h5_flag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_flag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_flag_var=${${h5_flag_var}}") +endmacro () + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") +message (STATUS "Warnings Configuration: CXX default: ${CMAKE_CXX_FLAGS}") +#----------------------------------------------------------------------------- +# Compiler specific flags : Shouldn't there be compiler tests for these +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}") + if (${HDF_CFG_NAME} MATCHES "Debug") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common") + endif () + else () + 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 () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +if (HDF5_DISABLE_COMPILER_WARNINGS) + message (STATUS "....Compiler warnings are suppressed") + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0") + endif () + endif () + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif () + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# HDF5 library compile options +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# CDash is configured to only allow 3000 warnings, so +# break into groups (from the config/gnu-flags file) +#----------------------------------------------------------------------------- +if (NOT MSVC) + if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP") + else () + # General flags + # + # Note that some of the flags listed here really should be developer + # flags (listed in a separate variable, below) but we put them here + # because they are not raised by the current code and we'd like to + # know if they do start showing up. + # + # 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. + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings-general") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) + list (APPEND H5_CXXFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") + list (APPEND H5_CXXFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") + endif() + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") + endif () + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_CXX_FLAGS "-Minform=inform") + endif () + message (STATUS "CMAKE_CXX_FLAGS_GENERAL=${HDF5_CMAKE_CXX_FLAGS}") + endif () + + #----------------------------------------------------------------------------- + # Option to allow the user to enable developer warnings + # Developer warnings (suggestions from gcc, not code problems) + #----------------------------------------------------------------------------- + #if (HDF5_ENABLE_DEV_WARNINGS) + # message (STATUS "....HDF5 developer group warnings are enabled") + # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + # list (APPEND H5_CXXFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + # endif () + #else () + # if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + # endif () + #endif () + + + #if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # # Append warning flags that only gcc 4.3+ knows about + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + + # # Append more extra warning flags that only gcc 4.4+ know about + # if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4") + # endif () + #endif () + + # Append more extra warning flags that only gcc 4.5+ know about + #if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.5) + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") + # if (HDF5_ENABLE_DEV_WARNINGS) + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") + # else () + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") + # endif () + #endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable all warnings +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_ALL_WARNINGS) + message (STATUS "....All Warnings are enabled") + if (MSVC) + if (HDF5_ENABLE_DEV_WARNINGS) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall /wd4668") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") + endif () + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS0} ${H5_CXXFLAGS1} ${H5_CXXFLAGS2} ${H5_CXXFLAGS3} ${H5_CXXFLAGS4}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPZERO_WARNINGS) + message (STATUS "....Group Zero warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W1") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS0}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPONE_WARNINGS) + message (STATUS "....Group One warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS1}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPTWO_WARNINGS) + message (STATUS "....Group Two warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS2}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPTHREE_WARNINGS) + message (STATUS "....Group Three warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS3}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPFOUR_WARNINGS) + message (STATUS "....Group Four warnings are enabled") + if (NOT MSVC) + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS4}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# This is in here to help some of the GCC based IDES like Eclipse +# and code blocks parse the compiler errors and warnings better. +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-symbols +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_SYMBOLS MATCHES "YES") + if(CMAKE_CXX_COMPILER_LOADED) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") + endif () + endif () +elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") + if(CMAKE_CXX_COMPILER_LOADED) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-profiling +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_PROFILING) + if(CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS "${PROFILE_CXXFLAGS}") + endif () +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-optimization +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_OPTIMIZATION) + if(CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS "${OPTIMIZE_CXXFLAGS}") + endif () +endif () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 79e2bd2..1e5f775 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -133,9 +133,6 @@ if (NOT MSVC) elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") - endif () ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") # gcc automatically inlines based on the optimization level # this is just a failsafe @@ -290,24 +287,13 @@ if (HDF5_ENABLE_ALL_WARNINGS) if (HDF5_ENABLE_DEV_WARNINGS) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall /wd4668") - endif () else () string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") - endif () endif () else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) - endif () endif () endif () endif () @@ -321,16 +307,9 @@ if (HDF5_ENABLE_GROUPZERO_WARNINGS) if (MSVC) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") list (APPEND HDF5_CMAKE_C_FLAGS "/W1") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W1") - endif () else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS0}) - endif () endif () endif () endif () @@ -344,16 +323,9 @@ if (HDF5_ENABLE_GROUPONE_WARNINGS) if (MSVC) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") list (APPEND HDF5_CMAKE_C_FLAGS "/W2") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2") - endif () else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS1}) - endif () endif () endif () endif () @@ -367,16 +339,9 @@ if (HDF5_ENABLE_GROUPTWO_WARNINGS) if (MSVC) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") - endif () else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS2}) - endif () endif () endif () endif () @@ -390,16 +355,9 @@ if (HDF5_ENABLE_GROUPTHREE_WARNINGS) if (MSVC) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") list (APPEND HDF5_CMAKE_C_FLAGS "/W4") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4") - endif () else () if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS3}) - endif () endif () endif () endif () @@ -413,9 +371,6 @@ if (HDF5_ENABLE_GROUPFOUR_WARNINGS) if (NOT MSVC) if (CMAKE_COMPILER_IS_GNUCC) list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS4}) - endif () endif () endif () endif () @@ -427,9 +382,6 @@ endif () if (CMAKE_COMPILER_IS_GNUCC) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") endif () -if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") -endif () #----------------------------------------------------------------------------- # Option for --enable-asserts @@ -459,26 +411,12 @@ if (HDF5_ENABLE_SYMBOLS MATCHES "YES") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer") endif () - if(CMAKE_CXX_COMPILER_LOADED) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") - endif () - endif () elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") if (CMAKE_C_COMPILER_ID STREQUAL "Intel") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") endif () - if(CMAKE_CXX_COMPILER_LOADED) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") - endif () - endif () endif () MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) @@ -489,9 +427,6 @@ MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF) if (HDF5_ENABLE_PROFILING) list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}") - if(CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS "${PROFILE_CXXFLAGS}") - endif () endif () MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) @@ -502,8 +437,5 @@ MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF) if (HDF5_ENABLE_OPTIMIZATION) list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}") - if(CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS "${OPTIMIZE_CXXFLAGS}") - endif () endif () MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 8d59cd0..64afb2a 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -28,12 +28,11 @@ macro (ADD_H5_FFLAGS h5_fflag_var infile) #message (STATUS "h5_fflag_var=${${h5_fflag_var}}") endmacro () -message (STATUS "Warnings Configuration: default: ${CMAKE_Fortran_FLAGS}") +message (STATUS "Warnings Configuration: default Fortran: ${CMAKE_Fortran_FLAGS}") #----------------------------------------------------------------------------- # Option to allow the user to disable compiler warnings #----------------------------------------------------------------------------- -option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) if (HDF5_DISABLE_COMPILER_WARNINGS) message (STATUS "....Compiler warnings are suppressed") # MSVC uses /w to suppress warnings. It also complains if another @@ -64,68 +63,68 @@ endif () # General flags if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-ifort-general") - list (APPEND CMAKE_Fortran_FLAGS "-stand f08 -free -implicitnone") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-ifort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand f08 -free -implicitnone") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") - list (APPEND CMAKE_Fortran_FLAGS "-ffree-form -std=f2008 -fimplicit-none") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form -std=f2008 -fimplicit-none") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") - list (APPEND CMAKE_Fortran_FLAGS "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03") endif () -message (STATUS "CMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}") +message (STATUS "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") # Append warning flags that only gcc 4.4+ knows about - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.4") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.4") endif () # Append more extra warning flags that only gcc 4.5+ know about if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.5) - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.5") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.5") endif () # Append more extra warning flags that only gcc 4.6+ know about #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) -# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.6") +# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.6") #endif () # Append more extra warning flags that only gcc 4.7+ know about if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.7") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.7") endif () # Append more extra warning flags that only gcc 4.8+ know about if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") endif () # Append more extra warning flags that only gcc 4.9+ know about #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) -# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") +# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") #endif () # Append more extra warning flags that only gcc 5.1+ know about if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") endif () # Append more extra warning flags that only gcc 6.x+ know about if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") endif () # Append more extra warning flags that only gcc 7.x+ know about #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) -# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") +# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") #endif () # Append more extra warning flags that only gcc 8.x+ know about if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) - ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") endif () # Append more extra warning flags that only gcc 9.x+ know about #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) -# ADD_H5_FLAGS (CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") +# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") #endif () diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index aa702ff..02a71c3 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -35,28 +35,22 @@ set (F2003_examples foreach (example ${examples}) add_executable (f90_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - target_compile_options(f90_ex_${example} - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> - ) -# set_property(TARGET f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) + target_compile_options(f90_ex_${example} PRIVATE $<$:${WIN_COMPILE_FLAGS}>) +# set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET f90_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (f90_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (f90_ex_${example} - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/static" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/static" ) + target_link_libraries (f90_ex_${example} PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran @@ -65,12 +59,13 @@ foreach (example ${examples}) else () target_include_directories (f90_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (f90_ex_${example} - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/shared" ) + target_link_libraries (f90_ex_${example} PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran @@ -81,28 +76,22 @@ endforeach () foreach (example ${F2003_examples}) add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - target_compile_options(f03_ex_${example} - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> - ) -# set_property(TARGET f03_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET f03_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) + target_compile_options(f03_ex_${example} PRIVATE $<$:${WIN_COMPILE_FLAGS}>) +# set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET f03_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT ONLY_SHARED_LIBS) target_include_directories (f03_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (f03_ex_${example} - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/static" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/static" ) + target_link_libraries (f03_ex_${example} PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (f03_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran03 @@ -111,12 +100,13 @@ foreach (example ${F2003_examples}) else () target_include_directories (f03_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (f03_ex_${example} - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/shared" ) + target_link_libraries (f03_ex_${example} PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (f03_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran03 @@ -127,27 +117,26 @@ endforeach () if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) - target_compile_options(f90_ex_ph5example - PRIVATE - $<$:${WIN_COMPILE_FLAGS}> - ) -# set_property(TARGET f90_ex_ph5example APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET f90_ex_ph5example APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) + target_compile_options(f90_ex_ph5example PRIVATE $<$:${WIN_COMPILE_FLAGS}>) +# set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET f90_ex_ph5example PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT ONLY_SHARED_LIBS) target_include_directories (f90_ex_ph5example PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$:${MPI_Fortran_INCLUDE_DIRS}>" + "${CMAKE_Fortran_MODULE_DIRECTORY}/static" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/static" + "$<$:${MPI_Fortran_INCLUDE_DIRS}>" ) target_link_libraries (f90_ex_ph5example PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + ${HDF5_F90_LIB_TARGET} + ${HDF5_LIB_TARGET} $<$:${MPI_Fortran_LIBRARIES}> ) set_target_properties (f90_ex_ph5example PROPERTIES @@ -158,11 +147,17 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) else () target_include_directories (f90_ex_ph5example PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$:${MPI_Fortran_INCLUDE_DIRS}>" + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/shared" + "$<$:${MPI_Fortran_INCLUDE_DIRS}>" ) target_link_libraries (f90_ex_ph5example PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} $<$:${MPI_Fortran_LIBRARIES}> ) set_target_properties (f90_ex_ph5example PROPERTIES diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 4417567..bf2fd84 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -40,22 +40,14 @@ set (Fortran_COMPILER_ID CMAKE_Fortran_COMPILER_ID) #----------------------------------------------------------------------------- add_executable (H5_buildiface ${HDF5_F90_SRC_SOURCE_DIR}/H5_buildiface.F90) -target_include_directories (H5_buildiface - PRIVATE - "${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}" -) +target_include_directories (H5_buildiface PRIVATE "${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}") #if (BUILD_SHARED_LIBS) -# target_compile_definitions(H5_buildiface -# PRIVATE -# $<$:/MT> -# ) +# target_compile_definitions(H5_buildiface PRIVATE $<$:/MT>) #endif () if(MSVC) set_property(TARGET H5_buildiface PROPERTY COMPILE_FLAGS "/MT") endif() -#set_property(TARGET H5_buildiface APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) +#set_property(TARGET H5_buildiface APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) if(MSVC) set_property(TARGET H5_buildiface PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE") endif() @@ -288,29 +280,23 @@ endif () if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SOURCES}) target_include_directories (${HDF5_F90_LIB_TARGET} - PRIVATE - "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$/include/static>" + PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};$<$:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$/include/static>" ) + target_compile_options(${HDF5_F90_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_LIB_TARGET} PRIVATE $<$:HDF5F90_WINDOWS> $<$:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_F90_LIB_TARGET} - PUBLIC - ${HDF5_F90_C_LIB_TARGET} + PUBLIC ${HDF5_F90_C_LIB_TARGET} PRIVATE ${LINK_Fortran_LIBS} $<$:${MPI_Fortran_LIBRARIES}> ) -# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) +# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET ${HDF5_F90_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() @@ -328,36 +314,24 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED}) target_include_directories (${HDF5_F90_LIBSH_TARGET} - PRIVATE - "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$/include/shared>" + PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$/include/shared>" ) + target_compile_options(${HDF5_F90_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_LIBSH_TARGET} - PUBLIC - "H5_BUILT_AS_DYNAMIC_LIB" + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$:BUILD_HDF5_DLL;HDF5F90_WINDOWS> $<$:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_F90_LIBSH_TARGET} - PUBLIC - ${HDF5_F90_C_LIBSH_TARGET} - PRIVATE - ${LINK_Fortran_LIBS} $<$:${MPI_Fortran_LIBRARIES}> + PUBLIC ${HDF5_F90_C_LIBSH_TARGET} + PRIVATE ${LINK_Fortran_LIBS} $<$:${MPI_Fortran_LIBRARIES}> ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-DLL"> -# ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def"> -# ) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-DLL">) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def">) if(MSVC) set_property(TARGET ${HDF5_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} /DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") endif() diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index b458882..c135f15 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -131,21 +131,15 @@ if (NOT BUILD_SHARED_LIBS) PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" INTERFACE "$/include/static>" ) + target_compile_options(${HDF5_F90_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_TEST_LIB_TARGET} PRIVATE $<$:HDF5F90_WINDOWS> $<$:${WIN_COMPILE_FLAGS}> ) - target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} - PUBLIC - ${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} - ) -# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) + target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} PUBLIC ${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) +# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() @@ -162,6 +156,7 @@ else () PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" INTERFACE "$/include/shared>" ) + target_compile_options(${HDF5_F90_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_TEST_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE @@ -171,15 +166,9 @@ else () target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ) -# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) -# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-DLL"> -# ) +# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) +# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-DLL">) if(MSVC) set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} -DLL") endif() @@ -215,24 +204,18 @@ add_executable (testhdf5_fortran tHDF5.F90 ) target_compile_options(testhdf5_fortran - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET testhdf5_fortran APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET testhdf5_fortran APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET testhdf5_fortran APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET testhdf5_fortran APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET testhdf5_fortran PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (testhdf5_fortran - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (testhdf5_fortran - PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static") + target_link_libraries (testhdf5_fortran PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib>) set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -240,12 +223,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (testhdf5_fortran ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (testhdf5_fortran - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (testhdf5_fortran - PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared") + target_link_libraries (testhdf5_fortran PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib>) set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -264,24 +243,18 @@ add_executable (testhdf5_fortran_1_8 tHDF5_1_8.F90 ) target_compile_options(testhdf5_fortran_1_8 - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET testhdf5_fortran_1_8 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (testhdf5_fortran_1_8 - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (testhdf5_fortran_1_8 - PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran_1_8 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static") + target_link_libraries (testhdf5_fortran_1_8 PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib>) set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -289,12 +262,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (testhdf5_fortran_1_8 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (testhdf5_fortran_1_8 - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (testhdf5_fortran_1_8 - PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran_1_8 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared") + target_link_libraries (testhdf5_fortran_1_8 PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib>) set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -315,24 +284,18 @@ add_executable (fortranlib_test_F03 tHDF5_F03.F90 ) target_compile_options(fortranlib_test_F03 - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET fortranlib_test_F03 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (fortranlib_test_F03 - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (fortranlib_test_F03 - PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (fortranlib_test_F03 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static") + target_link_libraries (fortranlib_test_F03 PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib>) set_target_properties (fortranlib_test_F03 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -340,12 +303,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (fortranlib_test_F03 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (fortranlib_test_F03 - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (fortranlib_test_F03 - PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (fortranlib_test_F03 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared") + target_link_libraries (fortranlib_test_F03 PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib>) set_target_properties (fortranlib_test_F03 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -357,24 +316,18 @@ endif () #-- Adding test for fflush1 add_executable (fflush1 fflush1.F90) target_compile_options(fflush1 - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET fflush1 APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET fflush1 APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET fflush1 APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET fflush1 APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET fflush1 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (fflush1 - PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static - ) - target_link_libraries (fflush1 - PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (fflush1 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + target_link_libraries (fflush1 PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib>) set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -382,12 +335,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (fflush1 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (fflush1 - PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared - ) - target_link_libraries (fflush1 - PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (fflush1 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + target_link_libraries (fflush1 PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib>) set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -399,24 +348,18 @@ endif () #-- Adding test for fflush2 add_executable (fflush2 fflush2.F90) target_compile_options (fflush2 - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET fflush2 APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET fflush2 APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET fflush2 APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET fflush2 APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET fflush2 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (fflush2 - PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static - ) - target_link_libraries (fflush2 - PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (fflush2 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + target_link_libraries (fflush2 PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib>) set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -424,12 +367,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (fflush2 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (fflush2 - PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared - ) - target_link_libraries (fflush2 - PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (fflush2 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + target_link_libraries (fflush2 PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib>) set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -441,24 +380,18 @@ endif () #-- Adding test for vol_connector add_executable (vol_connector vol_connector.F90) target_compile_options(vol_connector - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET vol_connector APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET vol_connector APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET vol_connector APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET vol_connector APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET vol_connector PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (vol_connector - PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static - ) - target_link_libraries (vol_connector - PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (vol_connector PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + target_link_libraries (vol_connector PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$:ws2_32.lib>) set_target_properties (vol_connector PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -466,12 +399,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (vol_connector ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (vol_connector - PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared - ) - target_link_libraries (vol_connector - PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib> - ) + target_include_directories (vol_connector PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + target_link_libraries (vol_connector PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$:ws2_32.lib>) set_target_properties (vol_connector PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran diff --git a/fortran/testpar/CMakeLists.txt b/fortran/testpar/CMakeLists.txt index 740d30e..12489528 100644 --- a/fortran/testpar/CMakeLists.txt +++ b/fortran/testpar/CMakeLists.txt @@ -25,7 +25,9 @@ target_include_directories (parallel_test PRIVATE ${TESTPAR_INCLUDES} ) target_compile_options(parallel_test - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) if (NOT BUILD_SHARED_LIBS) target_link_libraries (parallel_test @@ -51,12 +53,8 @@ else () ) endif () -#set_property(TARGET parallel_test APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET parallel_test APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET parallel_test APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET parallel_test APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET parallel_test PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index 684b02a..e310baa 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -9,36 +9,26 @@ set (examples foreach (example ${examples}) add_executable (hl_f90_ex_${example} ${HDF5_HL_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) target_compile_options(hl_f90_ex_${example} - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) +# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET hl_f90_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (hl_f90_ex_${example} - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_ex_${example} - PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} - ) + target_include_directories (hl_f90_ex_${example} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_ex_${example} PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/hl/fortran Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) else () - target_include_directories (hl_f90_ex_${example} - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_ex_${example} - PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} - ) + target_include_directories (hl_f90_ex_${example} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_ex_${example} PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/hl/fortran diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index fa8f442..6a8a7d3 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -165,19 +165,14 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;$<$:${MPI_Fortran_INCLUDE_DIRS}>" INTERFACE "$/include/static>" ) + target_compile_options(${HDF5_HL_F90_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_HL_F90_LIB_TARGET} PUBLIC $<$:HDF5F90_WINDOWS> PRIVATE $<$:${WIN_COMPILE_FLAGS}> ) - target_link_libraries (${HDF5_HL_F90_LIB_TARGET} - PUBLIC ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET} - ) -# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) + target_link_libraries (${HDF5_HL_F90_LIB_TARGET} PUBLIC ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) +# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() @@ -197,6 +192,7 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;$<$:${MPI_Fortran_INCLUDE_DIRS}>" INTERFACE "$/include/shared>" ) + target_compile_options(${HDF5_HL_F90_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_HL_F90_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE @@ -207,18 +203,10 @@ if (BUILD_SHARED_LIBS) PUBLIC ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} PRIVATE ${LINK_Fortran_LIBS} ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-DLL"> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$:"-DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def"> -# ) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-DLL">) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def">) if(MSVC) set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} -DLL -DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def") endif() diff --git a/hl/fortran/test/CMakeLists.txt b/hl/fortran/test/CMakeLists.txt index 6b6ddf1..e2872ac 100644 --- a/hl/fortran/test/CMakeLists.txt +++ b/hl/fortran/test/CMakeLists.txt @@ -14,36 +14,26 @@ set (H5_TESTS macro (ADD_H5_FORTRAN_EXE file) add_executable (hl_f90_${file} ${file}.F90) target_compile_options(hl_f90_${file} - PRIVATE $<$:${WIN_COMPILE_FLAGS}> + PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" + $<$:${WIN_COMPILE_FLAGS}> ) -# set_property(TARGET hl_f90_${file} APPEND PROPERTY -# LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET hl_f90_${file} APPEND PROPERTY -# LINK_FLAGS $<$:${WIN_LINK_FLAGS}> -# ) +# set_property(TARGET hl_f90_${file} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET hl_f90_${file} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET hl_f90_${file} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (hl_f90_${file} - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_${file} - PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} - ) + target_include_directories (hl_f90_${file} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_${file} PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET}) set_target_properties (hl_f90_${file} PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/hl/fortran Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) else () - target_include_directories (hl_f90_${file} - PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_${file} - PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} - ) + target_include_directories (hl_f90_${file} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_${file} PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET}) set_target_properties (hl_f90_${file} PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/hl/fortran -- cgit v0.12 From 29ad4fcec93a16d454cceddf71aadad6372ca1a3 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 5 Apr 2020 15:56:52 -0500 Subject: Correct whitespace in flags, force list mode --- config/cmake/HDFFortranCompilerFlags.cmake | 6 +++--- config/gnu-warnings/cxx-general | 20 ++++++++++---------- config/gnu-warnings/gfort-4.5 | 2 +- config/gnu-warnings/gfort-4.8 | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 64afb2a..6b14dbd 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -64,12 +64,12 @@ endif () # General flags if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-ifort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand f08 -free -implicitnone") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand" "-free") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form -std=f2008 -fimplicit-none") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-std=f2008" "-fimplicit-none") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform" "-Mdclchk" "-Mstandard" "-Mallocatable=03") endif () message (STATUS "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") diff --git a/config/gnu-warnings/cxx-general b/config/gnu-warnings/cxx-general index 7e0655c..ee7ee22 100644 --- a/config/gnu-warnings/cxx-general +++ b/config/gnu-warnings/cxx-general @@ -7,13 +7,13 @@ # warnings that are emitted. If you need it, add it from the # environment variable at configure time. -Wabi --Wctor-dtor-privacy --Weffc++ -##-Wendif-labels" --Wnon-virtual-dtor --Wold-style-cast --Woverloaded-virtual --Wreorder --Wsign-promo -##-Wunreachable-code" -##-Wvariadic-macros - +-Wctor-dtor-privacy +-Weffc++ +##-Wendif-labels +-Wnon-virtual-dtor +-Wold-style-cast +-Woverloaded-virtual +-Wreorder +-Wsign-promo +##-Wunreachable-code +##-Wvariadic-macros diff --git a/config/gnu-warnings/gfort-4.5 b/config/gnu-warnings/gfort-4.5 index 55ae1d7..4490d4e 100644 --- a/config/gnu-warnings/gfort-4.5 +++ b/config/gnu-warnings/gfort-4.5 @@ -1 +1 @@ --Wimplicit-procedure \ No newline at end of file +-Wimplicit-procedure diff --git a/config/gnu-warnings/gfort-4.8 b/config/gnu-warnings/gfort-4.8 index 1fddee0..1b96a51 100644 --- a/config/gnu-warnings/gfort-4.8 +++ b/config/gnu-warnings/gfort-4.8 @@ -2,4 +2,4 @@ -Wrealloc-lhs-all # Turn off warnings for passing non-ANSI types to BIND(). # We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. --Wno-c-binding-type" +-Wno-c-binding-type -- cgit v0.12 From 2e85f81126b1399e1214765e09e1a34fd63dcb65 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sun, 5 Apr 2020 16:38:25 -0500 Subject: Remove overzealous additions --- hl/fortran/examples/CMakeLists.txt | 3 +-- hl/fortran/src/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index e310baa..e6411c1 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -10,8 +10,7 @@ foreach (example ${examples}) add_executable (hl_f90_ex_${example} ${HDF5_HL_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) target_compile_options(hl_f90_ex_${example} PRIVATE - "${HDF5_CMAKE_Fortran_FLAGS}" - $<$:${WIN_COMPILE_FLAGS}> + $<$:${WIN_COMPILE_FLAGS}> ) # set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) # set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 6a8a7d3..71b9380 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -63,7 +63,6 @@ if (NOT ONLY_SHARED_LIBS) INTERFACE "$/include>" ) target_compile_options(${HDF5_HL_F90_C_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") - target_compile_definitions(${HDF5_HL_F90_C_LIB_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} STATIC) target_link_libraries (${HDF5_HL_F90_C_LIB_TARGET} PUBLIC ${HDF5_F90_C_LIB_TARGET} ${HDF5_HL_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIB_TARGET}") -- cgit v0.12 From d0a936ab622ad17d055df8d92922300c12345296 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 06:54:27 -0500 Subject: Corrected note --- release_docs/RELEASE.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index d30a0d6..a857afb 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -57,8 +57,8 @@ New Features - Both build systems use same set of warnings flags - GNU C warnings flags were moved to files in a config sub-folder - named gnu-warnings. Flags that only are available for a specific + GNU C, C++ and gfortran warnings flags were moved to files in a confi + sub-folder named gnu-warnings. Flags that only are available for a specific version of the compiler are in files named with that version. Clang C warnings flags were moved to files in a config sub-folder named clang-warnings. @@ -70,7 +70,7 @@ New Features that are chosen by the CMake option:HDF5_ENABLE_DEV_WARNINGS or the configure option:--enable-developer-warnings. - In addition, CMake no longer applies these warnings for tests and examples. + In addition, CMake no longer applies these warnings for examples. (ADB - 2020/03/24, TRILAB-192) -- cgit v0.12 From 0d701b9ff8988bff5f67261e508e980aaac62f9b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 09:35:43 -0500 Subject: Move intel warnings to subfolder, update autotools files --- MANIFEST | 4 +- config/HDFCompilerFlags.cmake | 420 +++++++++++++++++++++++++++ config/cmake/HDFCXXCompilerFlags.cmake | 2 +- config/cmake/HDFCompilerFlags.cmake | 441 ----------------------------- config/cmake/HDFFortranCompilerFlags.cmake | 125 ++++---- config/intel-fflags | 26 +- config/intel-flags | 32 ++- config/intel-ifort-general | 1 - config/intel-warnings-general | 2 - config/intel-warnings/general | 2 + config/intel-warnings/ifort-general | 1 + release_docs/RELEASE.txt | 4 +- 12 files changed, 539 insertions(+), 521 deletions(-) create mode 100644 config/HDFCompilerFlags.cmake delete mode 100644 config/cmake/HDFCompilerFlags.cmake delete mode 100644 config/intel-ifort-general delete mode 100644 config/intel-warnings-general create mode 100644 config/intel-warnings/general create mode 100644 config/intel-warnings/ifort-general diff --git a/MANIFEST b/MANIFEST index 70e61ed..b1be241 100644 --- a/MANIFEST +++ b/MANIFEST @@ -190,8 +190,8 @@ ./config/gnu-warnings/no-developer-4.8 ./config/gnu-warnings/no-developer-8 ./config/gnu-warnings/no-developer-general -./config/intel-ifort-general -./config/intel-warnings-general +./config/intel-warnings/ifort-general +./config/intel-warnings/general ./config/site-specific/BlankForm diff --git a/config/HDFCompilerFlags.cmake b/config/HDFCompilerFlags.cmake new file mode 100644 index 0000000..b255e22 --- /dev/null +++ b/config/HDFCompilerFlags.cmake @@ -0,0 +1,420 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED TRUE) + +macro (ADD_H5_FLAGS h5_flag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_flag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_flag_var=${${h5_flag_var}}") +endmacro () + +set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") +set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") +message (STATUS "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}") +#----------------------------------------------------------------------------- +# Compiler specific flags : Shouldn't there be compiler tests for these +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") + if (${HDF_CFG_NAME} MATCHES "Debug") + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") + endif () + else () + 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 () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) +if (HDF5_DISABLE_COMPILER_WARNINGS) + message (STATUS "....Compiler warnings are suppressed") + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0") + endif () + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif () + # Borland uses -w- to suppress warnings. + if (BORLAND) + set (HDF5_WARNINGS_BLOCKED 1) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") + endif () + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") + endif () +endif () + +#----------------------------------------------------------------------------- +# HDF5 library compile options +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# CDash is configured to only allow 3000 warnings, so +# break into groups (from the config/gnu-flags file) +#----------------------------------------------------------------------------- +if (NOT MSVC) + if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP") + else () + # General flags + # + # Note that some of the flags listed here really should be developer + # flags (listed in a separate variable, below) but we put them here + # because they are not raised by the current code and we'd like to + # know if they do start showing up. + # + # 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. + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") + list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith") + list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized") + list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable") + # this is just a failsafe + list (APPEND H5_CFLAGS0 "-finline-functions") + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) + list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") + list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") + endif() + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") + # gcc automatically inlines based on the optimization level + # this is just a failsafe + list (APPEND H5_CFLAGS0 "-finline-functions") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") + endif () + message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") + endif () + + #----------------------------------------------------------------------------- + # Option to allow the user to enable developer warnings + # Developer warnings (suggestions from gcc, not code problems) + #----------------------------------------------------------------------------- + option (HDF5_ENABLE_DEV_WARNINGS "Enable HDF5 developer group warnings" OFF) + if (HDF5_ENABLE_DEV_WARNINGS) + message (STATUS "....HDF5 developer group warnings are enabled") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + endif () + else () + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + endif () + endif () + + + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + # Append warning flags that only gcc 4.3+ knows about + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + # + # Technically, variable-length arrays are part of the C99 standard, but + # we should approach them a bit cautiously... Only needed for gcc 4.X + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") + endif () + + # Append more extra warning flags that only gcc 4.4+ know about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4") + endif () + endif () + + # Append more extra warning flags that only gcc 4.5+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") + endif () + endif () + + # Append more extra warning flags that only gcc 4.6 and less know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") + endif () + + # Append more extra warning flags that only gcc 4.5-4.6 know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5-4.6") + endif () + + # Append more extra warning flags that only gcc 4.6+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.6") + endif () + endif () + + # Append more extra warning flags that only gcc 4.7+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.7") + endif () + endif () + + # Append more extra warning flags that only gcc 4.8+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") + endif () + endif () + + # Append more extra warning flags that only gcc 4.9+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") + endif () + + # Append more extra warning flags that only gcc 5.1+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") + endif () + + # Append more extra warning flags that only gcc 6.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") + endif () + + # Append more extra warning flags that only gcc 7.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) + ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") + #else () + # ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") + endif () + endif () + + # Append more extra warning flags that only gcc 8.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) + ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") + else () + ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") + endif () + endif () + + # Append more extra warning flags that only gcc 9.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) + ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable all warnings +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) +if (HDF5_ENABLE_ALL_WARNINGS) + message (STATUS "....All Warnings are enabled") + if (MSVC) + if (HDF5_ENABLE_DEV_WARNINGS) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") + else () + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W3") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) +if (HDF5_ENABLE_GROUPZERO_WARNINGS) + message (STATUS "....Group Zero warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W1") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) +if (HDF5_ENABLE_GROUPONE_WARNINGS) + message (STATUS "....Group One warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W2") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) +if (HDF5_ENABLE_GROUPTWO_WARNINGS) + message (STATUS "....Group Two warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W3") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) +if (HDF5_ENABLE_GROUPTHREE_WARNINGS) + message (STATUS "....Group Three warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W4") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) +if (HDF5_ENABLE_GROUPFOUR_WARNINGS) + message (STATUS "....Group Four warnings are enabled") + if (NOT MSVC) + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# This is in here to help some of the GCC based IDES like Eclipse +# and code blocks parse the compiler errors and warnings better. +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-asserts +# By default, CMake adds NDEBUG to CMAKE_${lang}_FLAGS for Release build types +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +#option (HDF5_ENABLE_ASSERTS "Determines whether NDEBUG is defined to control assertions." OFF) +set (HDF5_ENABLE_ASSERTS "OFF" CACHE STRING "Determines whether NDEBUG is defined to control assertions (OFF NO YES)") +set_property (CACHE HDF5_ENABLE_ASSERTS PROPERTY STRINGS OFF NO YES) +if (HDF5_ENABLE_ASSERTS MATCHES "YES") + add_compile_options ("-UNDEBUG") +elseif (HDF5_ENABLE_ASSERTS MATCHES "NO") + add_compile_options ("-DNDEBUG") +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_ASSERTS) + +#----------------------------------------------------------------------------- +# Option for --enable-symbols +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +#option (HDF5_ENABLE_SYMBOLS "Add debug symbols to the library independent of the build mode and optimization level." OFF) +set (HDF5_ENABLE_SYMBOLS "OFF" CACHE STRING "Add debug symbols to the library independent of the build mode and optimization level (OFF NO YES)") +set_property (CACHE HDF5_ENABLE_SYMBOLS PROPERTY STRINGS OFF NO YES) +if (HDF5_ENABLE_SYMBOLS MATCHES "YES") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer") + endif () +elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") + endif () +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) + +#----------------------------------------------------------------------------- +# Option for --enable-profiling +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF) +if (HDF5_ENABLE_PROFILING) + list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}") +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) + +#----------------------------------------------------------------------------- +# Option for --enable-optimization +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF) +if (HDF5_ENABLE_OPTIMIZATION) + list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}") +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION) diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 504a171..d828c10 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -97,7 +97,7 @@ if (NOT MSVC) # 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. if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings-general") + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) list (APPEND H5_CXXFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") list (APPEND H5_CXXFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake deleted file mode 100644 index 1e5f775..0000000 --- a/config/cmake/HDFCompilerFlags.cmake +++ /dev/null @@ -1,441 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_STANDARD_REQUIRED TRUE) - -macro (ADD_H5_FLAGS h5_flag_var infile) - file (STRINGS ${infile} TEST_FLAG_STREAM) - #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") - list (LENGTH TEST_FLAG_STREAM len_flag) - if (len_flag GREATER 0) - math (EXPR _FP_LEN "${len_flag} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET TEST_FLAG_STREAM ${line} str_flag) - string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") - #message (STATUS "str_flag=${str_flag}") - if (str_flag) - list (APPEND ${h5_flag_var} "${str_flag}") - endif () - endforeach () - endif () - #message (STATUS "h5_flag_var=${${h5_flag_var}}") -endmacro () - -set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") -set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") -message (STATUS "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}") -#----------------------------------------------------------------------------- -# Compiler specific flags : Shouldn't there be compiler tests for these -#----------------------------------------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") - if (${HDF_CFG_NAME} MATCHES "Debug") - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") - endif () - else () - 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 () -endif () -if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}") - if (${HDF_CFG_NAME} MATCHES "Debug") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common") - endif () - else () - 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 () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to disable compiler warnings -#----------------------------------------------------------------------------- -option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) -if (HDF5_DISABLE_COMPILER_WARNINGS) - message (STATUS "....Compiler warnings are suppressed") - # MSVC uses /w to suppress warnings. It also complains if another - # warning level is given, so remove it. - if (MSVC) - set (HDF5_WARNINGS_BLOCKED 1) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0") - endif () - endif () - if (WIN32) - add_definitions (-D_CRT_SECURE_NO_WARNINGS) - endif () - # Borland uses -w- to suppress warnings. - if (BORLAND) - set (HDF5_WARNINGS_BLOCKED 1) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") - endif () - - # Most compilers use -w to suppress warnings. - if (NOT HDF5_WARNINGS_BLOCKED) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# HDF5 library compile options -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- -if (NOT MSVC) - if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP") - else () - # General flags - # - # Note that some of the flags listed here really should be developer - # flags (listed in a separate variable, below) but we put them here - # because they are not raised by the current code and we'd like to - # know if they do start showing up. - # - # 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. - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings-general") - message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") - list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith") - list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized") - list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable") - # this is just a failsafe - list (APPEND H5_CFLAGS0 "-finline-functions") - if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) - list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") - list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") - endif() - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") - message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") - # gcc automatically inlines based on the optimization level - # this is just a failsafe - list (APPEND H5_CFLAGS0 "-finline-functions") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") - message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") - list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") - endif () - endif () - - #----------------------------------------------------------------------------- - # Option to allow the user to enable developer warnings - # Developer warnings (suggestions from gcc, not code problems) - #----------------------------------------------------------------------------- - option (HDF5_ENABLE_DEV_WARNINGS "Enable HDF5 developer group warnings" OFF) - if (HDF5_ENABLE_DEV_WARNINGS) - message (STATUS "....HDF5 developer group warnings are enabled") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") - endif () - else () - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") - endif () - endif () - - - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - # Append warning flags that only gcc 4.3+ knows about - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... Only needed for gcc 4.X - if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") - endif () - - # Append more extra warning flags that only gcc 4.4+ know about - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4") - endif () - endif () - - # Append more extra warning flags that only gcc 4.5+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") - endif () - endif () - - # Append more extra warning flags that only gcc 4.6 and less know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") - endif () - - # Append more extra warning flags that only gcc 4.5-4.6 know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5-4.6") - endif () - - # Append more extra warning flags that only gcc 4.6+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.6") - endif () - endif () - - # Append more extra warning flags that only gcc 4.7+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.7") - endif () - endif () - - # Append more extra warning flags that only gcc 4.8+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") - endif () - endif () - - # Append more extra warning flags that only gcc 4.9+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") - endif () - - # Append more extra warning flags that only gcc 5.1+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") - endif () - - # Append more extra warning flags that only gcc 6.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") - endif () - - # Append more extra warning flags that only gcc 7.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) - ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") - #else () - # ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") - endif () - endif () - - # Append more extra warning flags that only gcc 8.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") - else () - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") - endif () - endif () - - # Append more extra warning flags that only gcc 9.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) - ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable all warnings -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) -if (HDF5_ENABLE_ALL_WARNINGS) - message (STATUS "....All Warnings are enabled") - if (MSVC) - if (HDF5_ENABLE_DEV_WARNINGS) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") - else () - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - endif () - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) -if (HDF5_ENABLE_GROUPZERO_WARNINGS) - message (STATUS "....Group Zero warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W1") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) -if (HDF5_ENABLE_GROUPONE_WARNINGS) - message (STATUS "....Group One warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W2") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) -if (HDF5_ENABLE_GROUPTWO_WARNINGS) - message (STATUS "....Group Two warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) -if (HDF5_ENABLE_GROUPTHREE_WARNINGS) - message (STATUS "....Group Three warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W4") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) -if (HDF5_ENABLE_GROUPFOUR_WARNINGS) - message (STATUS "....Group Four warnings are enabled") - if (NOT MSVC) - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# This is in here to help some of the GCC based IDES like Eclipse -# and code blocks parse the compiler errors and warnings better. -#----------------------------------------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") -endif () - -#----------------------------------------------------------------------------- -# Option for --enable-asserts -# By default, CMake adds NDEBUG to CMAKE_${lang}_FLAGS for Release build types -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -#option (HDF5_ENABLE_ASSERTS "Determines whether NDEBUG is defined to control assertions." OFF) -set (HDF5_ENABLE_ASSERTS "OFF" CACHE STRING "Determines whether NDEBUG is defined to control assertions (OFF NO YES)") -set_property (CACHE HDF5_ENABLE_ASSERTS PROPERTY STRINGS OFF NO YES) -if (HDF5_ENABLE_ASSERTS MATCHES "YES") - add_compile_options ("-UNDEBUG") -elseif (HDF5_ENABLE_ASSERTS MATCHES "NO") - add_compile_options ("-DNDEBUG") -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_ASSERTS) - -#----------------------------------------------------------------------------- -# Option for --enable-symbols -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -#option (HDF5_ENABLE_SYMBOLS "Add debug symbols to the library independent of the build mode and optimization level." OFF) -set (HDF5_ENABLE_SYMBOLS "OFF" CACHE STRING "Add debug symbols to the library independent of the build mode and optimization level (OFF NO YES)") -set_property (CACHE HDF5_ENABLE_SYMBOLS PROPERTY STRINGS OFF NO YES) -if (HDF5_ENABLE_SYMBOLS MATCHES "YES") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer") - endif () -elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") - endif () -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) - -#----------------------------------------------------------------------------- -# Option for --enable-profiling -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF) -if (HDF5_ENABLE_PROFILING) - list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}") -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) - -#----------------------------------------------------------------------------- -# Option for --enable-optimization -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF) -if (HDF5_ENABLE_OPTIMIZATION) - list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}") -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 6b14dbd..4d63c95 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -39,8 +39,9 @@ if (HDF5_DISABLE_COMPILER_WARNINGS) # warning level is given, so remove it. if (MSVC) set (HDF5_WARNINGS_BLOCKED 1) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /W0") + if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /warn:none") + endif () endif () if (WIN32) add_definitions (-D_CRT_SECURE_NO_WARNINGS) @@ -61,70 +62,80 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -# General flags -if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-ifort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand" "-free") -elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-std=f2008" "-fimplicit-none") -elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform" "-Mdclchk" "-Mstandard" "-Mallocatable=03") -endif () -message (STATUS "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") +#----------------------------------------------------------------------------- +# CDash is configured to only allow 3000 warnings, so +# break into groups (from the config/gnu-flags file) +#----------------------------------------------------------------------------- +if (NOT MSVC) + # General flags + if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/ifort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand:f08" "-free") + elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-std=f2008" "-fimplicit-none") + elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform" "-Mdclchk" "-Mstandard" "-Mallocatable=03") + endif () + message (STATUS "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - # Append warning flags that only gcc 4.4+ knows about - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.4") -endif () + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + # Append warning flags that only gcc 4.4+ knows about + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.4") + endif () -# Append more extra warning flags that only gcc 4.5+ know about -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.5) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.5") -endif () + # Append more extra warning flags that only gcc 4.5+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.5) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.5") + endif () -# Append more extra warning flags that only gcc 4.6+ know about -#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) -# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.6") -#endif () + # Append more extra warning flags that only gcc 4.6+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.6") + #endif () -# Append more extra warning flags that only gcc 4.7+ know about -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.7") -endif () + # Append more extra warning flags that only gcc 4.7+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.7") + endif () -# Append more extra warning flags that only gcc 4.8+ know about -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") -endif () + # Append more extra warning flags that only gcc 4.8+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") + endif () -# Append more extra warning flags that only gcc 4.9+ know about -#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) -# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") -#endif () + # Append more extra warning flags that only gcc 4.9+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") + #endif () -# Append more extra warning flags that only gcc 5.1+ know about -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") -endif () + # Append more extra warning flags that only gcc 5.1+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") + endif () -# Append more extra warning flags that only gcc 6.x+ know about -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") -endif () + # Append more extra warning flags that only gcc 6.x+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") + endif () -# Append more extra warning flags that only gcc 7.x+ know about -#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) -# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") -#endif () + # Append more extra warning flags that only gcc 7.x+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") + #endif () -# Append more extra warning flags that only gcc 8.x+ know about -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) - ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") -endif () + # Append more extra warning flags that only gcc 8.x+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") + endif () -# Append more extra warning flags that only gcc 9.x+ know about -#if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) -# ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") -#endif () + # Append more extra warning flags that only gcc 9.x+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") + #endif () +else () + if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + #ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f08" "/free") +endif () diff --git a/config/intel-fflags b/config/intel-fflags index 8b1110e..c620ef7 100644 --- a/config/intel-fflags +++ b/config/intel-fflags @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- shell-script -*- # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -17,6 +17,20 @@ # if the compiler is not Intel; otherwise `f9x_flags_set' is set to `yes' # +# +# Prepend `$srcdir/config/intel-warnings/` to the filename suffix(es) given as +# subroutine argument(s), remove comments starting with # and ending +# at EOL, replace spans of whitespace (including newlines) with spaces, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_intel_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/intel-warnings/${arg} + done) + IFS=' ' echo "$*" +} + # Get the compiler version in a way that works for ifort # ifort unless a compiler version is already known # @@ -44,8 +58,8 @@ fi # Common Intel flags for various situations if test "X-ifort" = "X-$f9x_vendor"; then - # Insert section about version specific problems from gnu-flags here, if - # necessary. + # Insert section about version specific problems from compiler flags here, + # if necessary. arch= # Architecture-specific flags @@ -68,7 +82,7 @@ if test "X-ifort" = "X-$f9x_vendor"; then FC_BASENAME=ifort F9XSUFFIXFLAG="" FSEARCH_DIRS="" - H5_FCFLAGS="$H5_FCFLAGS" + H5_FCFLAGS="$H5_FCFLAGS $(load_intel_arguments ifort-general)" # Production PROD_FCFLAGS= @@ -89,7 +103,9 @@ if test "X-ifort" = "X-$f9x_vendor"; then DEBUG_OPT_FCFLAGS= NO_OPT_FCFLAGS= - # Flags are set + ################# + # Flags are set # + ################# f9x_flags_set=yes fi diff --git a/config/intel-flags b/config/intel-flags index 6b4e406..100e68a 100644 --- a/config/intel-flags +++ b/config/intel-flags @@ -18,7 +18,7 @@ # # -# Prepend `$srcdir/config/intel-` to the filename suffix(es) given as +# Prepend `$srcdir/config/intel-warnings/` to the filename suffix(es) given as # subroutine argument(s), remove comments starting with # and ending # at EOL, replace spans of whitespace (including newlines) with spaces, # and re-emit the file(s) thus filtered on the standard output stream. @@ -26,7 +26,7 @@ load_intel_arguments() { set -- $(for arg; do - sed 's,#.*$,,' $srcdir/config/intel-${arg} + sed 's,#.*$,,' $srcdir/config/intel-warnings/${arg} done) IFS=' ' echo "$*" } @@ -81,7 +81,6 @@ if test "X-icc" = "X-$cc_vendor"; then # General # Default to C99 standard. H5_CFLAGS="$H5_CFLAGS $arch -std=c99" - H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments warnings-general)" # Production PROD_CFLAGS= @@ -103,16 +102,20 @@ if test "X-icc" = "X-$cc_vendor"; then DEBUG_OPT_CFLAGS="-O0" NO_OPT_CFLAGS="-O0" - # Flags are set - cc_flags_set=yes + ############ + # Warnings # + ############ -fi + ########### + # General # + ########### + + H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments general)" + + ############################# + # Version-specific warnings # + ############################# -# Version specific ICC flags -# -# Please follow the pattern below by adding new versions at the top, copying -# the information from the previous version and adding modifications to that. -# The default at the bottom will apply if no earlier version matches. case "$cc_vendor-$cc_version" in icc-1[5-6]*) H5_CFLAGS="$H5_CFLAGS -Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wformat-security -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith -Wreturn-type -Wshadow -Wstrict-prototypes -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-variable -Wwrite-strings" @@ -128,6 +131,13 @@ case "$cc_vendor-$cc_version" in ;; esac + ################# + # Flags are set # + ################# + cc_flags_set=yes + +fi + # Clear cc info if no flags set if test "X-$cc_flags_set" = "X-"; then cc_vendor= diff --git a/config/intel-ifort-general b/config/intel-ifort-general deleted file mode 100644 index a9da0e5..0000000 --- a/config/intel-ifort-general +++ /dev/null @@ -1 +0,0 @@ --warn:all diff --git a/config/intel-warnings-general b/config/intel-warnings-general deleted file mode 100644 index d0b2e25..0000000 --- a/config/intel-warnings-general +++ /dev/null @@ -1,2 +0,0 @@ --Wall --Wcheck \ No newline at end of file diff --git a/config/intel-warnings/general b/config/intel-warnings/general new file mode 100644 index 0000000..d0b2e25 --- /dev/null +++ b/config/intel-warnings/general @@ -0,0 +1,2 @@ +-Wall +-Wcheck \ No newline at end of file diff --git a/config/intel-warnings/ifort-general b/config/intel-warnings/ifort-general new file mode 100644 index 0000000..a9da0e5 --- /dev/null +++ b/config/intel-warnings/ifort-general @@ -0,0 +1 @@ +-warn:all diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a857afb..1f1ad60 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -57,11 +57,13 @@ New Features - Both build systems use same set of warnings flags - GNU C, C++ and gfortran warnings flags were moved to files in a confi + GNU C, C++ and gfortran warnings flags were moved to files in a config sub-folder named gnu-warnings. Flags that only are available for a specific version of the compiler are in files named with that version. Clang C warnings flags were moved to files in a config sub-folder named clang-warnings. + Intel C, Fortran warnings flags were moved to files in a config sub-folder + named intel-warnings. There are flags in named "error-xxx" files with warnings that may be promoted to errors. Some source files may still need fixes. -- cgit v0.12 From f8d8a96eb73abbdd5ef0ce7a87c72b4a49e2fa8e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 09:38:43 -0500 Subject: Correct improper file move --- config/HDFCompilerFlags.cmake | 420 ------------------------------------ config/cmake/HDFCompilerFlags.cmake | 420 ++++++++++++++++++++++++++++++++++++ 2 files changed, 420 insertions(+), 420 deletions(-) delete mode 100644 config/HDFCompilerFlags.cmake create mode 100644 config/cmake/HDFCompilerFlags.cmake diff --git a/config/HDFCompilerFlags.cmake b/config/HDFCompilerFlags.cmake deleted file mode 100644 index b255e22..0000000 --- a/config/HDFCompilerFlags.cmake +++ /dev/null @@ -1,420 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_STANDARD_REQUIRED TRUE) - -macro (ADD_H5_FLAGS h5_flag_var infile) - file (STRINGS ${infile} TEST_FLAG_STREAM) - #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") - list (LENGTH TEST_FLAG_STREAM len_flag) - if (len_flag GREATER 0) - math (EXPR _FP_LEN "${len_flag} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET TEST_FLAG_STREAM ${line} str_flag) - string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") - #message (STATUS "str_flag=${str_flag}") - if (str_flag) - list (APPEND ${h5_flag_var} "${str_flag}") - endif () - endforeach () - endif () - #message (STATUS "h5_flag_var=${${h5_flag_var}}") -endmacro () - -set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") -set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") -message (STATUS "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}") -#----------------------------------------------------------------------------- -# Compiler specific flags : Shouldn't there be compiler tests for these -#----------------------------------------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") - if (${HDF_CFG_NAME} MATCHES "Debug") - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") - endif () - else () - 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 () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to disable compiler warnings -#----------------------------------------------------------------------------- -option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) -if (HDF5_DISABLE_COMPILER_WARNINGS) - message (STATUS "....Compiler warnings are suppressed") - # MSVC uses /w to suppress warnings. It also complains if another - # warning level is given, so remove it. - if (MSVC) - set (HDF5_WARNINGS_BLOCKED 1) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0") - endif () - if (WIN32) - add_definitions (-D_CRT_SECURE_NO_WARNINGS) - endif () - # Borland uses -w- to suppress warnings. - if (BORLAND) - set (HDF5_WARNINGS_BLOCKED 1) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") - endif () - - # Most compilers use -w to suppress warnings. - if (NOT HDF5_WARNINGS_BLOCKED) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") - endif () -endif () - -#----------------------------------------------------------------------------- -# HDF5 library compile options -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- -if (NOT MSVC) - if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP") - else () - # General flags - # - # Note that some of the flags listed here really should be developer - # flags (listed in a separate variable, below) but we put them here - # because they are not raised by the current code and we'd like to - # know if they do start showing up. - # - # 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. - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") - list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith") - list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized") - list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable") - # this is just a failsafe - list (APPEND H5_CFLAGS0 "-finline-functions") - if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) - list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") - list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") - endif() - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") - # gcc automatically inlines based on the optimization level - # this is just a failsafe - list (APPEND H5_CFLAGS0 "-finline-functions") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") - list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") - endif () - message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") - endif () - - #----------------------------------------------------------------------------- - # Option to allow the user to enable developer warnings - # Developer warnings (suggestions from gcc, not code problems) - #----------------------------------------------------------------------------- - option (HDF5_ENABLE_DEV_WARNINGS "Enable HDF5 developer group warnings" OFF) - if (HDF5_ENABLE_DEV_WARNINGS) - message (STATUS "....HDF5 developer group warnings are enabled") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") - endif () - else () - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") - endif () - endif () - - - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - # Append warning flags that only gcc 4.3+ knows about - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... Only needed for gcc 4.X - if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") - endif () - - # Append more extra warning flags that only gcc 4.4+ know about - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4") - endif () - endif () - - # Append more extra warning flags that only gcc 4.5+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") - endif () - endif () - - # Append more extra warning flags that only gcc 4.6 and less know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") - endif () - - # Append more extra warning flags that only gcc 4.5-4.6 know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5-4.6") - endif () - - # Append more extra warning flags that only gcc 4.6+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.6") - endif () - endif () - - # Append more extra warning flags that only gcc 4.7+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.7") - endif () - endif () - - # Append more extra warning flags that only gcc 4.8+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") - else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") - endif () - endif () - - # Append more extra warning flags that only gcc 4.9+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") - endif () - - # Append more extra warning flags that only gcc 5.1+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") - endif () - - # Append more extra warning flags that only gcc 6.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") - endif () - - # Append more extra warning flags that only gcc 7.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) - ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") - #else () - # ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") - endif () - endif () - - # Append more extra warning flags that only gcc 8.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") - if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") - else () - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") - endif () - endif () - - # Append more extra warning flags that only gcc 9.x+ know about - if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) - ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable all warnings -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) -if (HDF5_ENABLE_ALL_WARNINGS) - message (STATUS "....All Warnings are enabled") - if (MSVC) - if (HDF5_ENABLE_DEV_WARNINGS) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") - else () - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - endif () - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) -if (HDF5_ENABLE_GROUPZERO_WARNINGS) - message (STATUS "....Group Zero warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W1") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) -if (HDF5_ENABLE_GROUPONE_WARNINGS) - message (STATUS "....Group One warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W2") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) -if (HDF5_ENABLE_GROUPTWO_WARNINGS) - message (STATUS "....Group Two warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) -if (HDF5_ENABLE_GROUPTHREE_WARNINGS) - message (STATUS "....Group Three warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W4") - else () - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) -if (HDF5_ENABLE_GROUPFOUR_WARNINGS) - message (STATUS "....Group Four warnings are enabled") - if (NOT MSVC) - if (CMAKE_COMPILER_IS_GNUCC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# This is in here to help some of the GCC based IDES like Eclipse -# and code blocks parse the compiler errors and warnings better. -#----------------------------------------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") -endif () - -#----------------------------------------------------------------------------- -# Option for --enable-asserts -# By default, CMake adds NDEBUG to CMAKE_${lang}_FLAGS for Release build types -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -#option (HDF5_ENABLE_ASSERTS "Determines whether NDEBUG is defined to control assertions." OFF) -set (HDF5_ENABLE_ASSERTS "OFF" CACHE STRING "Determines whether NDEBUG is defined to control assertions (OFF NO YES)") -set_property (CACHE HDF5_ENABLE_ASSERTS PROPERTY STRINGS OFF NO YES) -if (HDF5_ENABLE_ASSERTS MATCHES "YES") - add_compile_options ("-UNDEBUG") -elseif (HDF5_ENABLE_ASSERTS MATCHES "NO") - add_compile_options ("-DNDEBUG") -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_ASSERTS) - -#----------------------------------------------------------------------------- -# Option for --enable-symbols -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -#option (HDF5_ENABLE_SYMBOLS "Add debug symbols to the library independent of the build mode and optimization level." OFF) -set (HDF5_ENABLE_SYMBOLS "OFF" CACHE STRING "Add debug symbols to the library independent of the build mode and optimization level (OFF NO YES)") -set_property (CACHE HDF5_ENABLE_SYMBOLS PROPERTY STRINGS OFF NO YES) -if (HDF5_ENABLE_SYMBOLS MATCHES "YES") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer") - endif () -elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") - if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") - elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") - endif () -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) - -#----------------------------------------------------------------------------- -# Option for --enable-profiling -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF) -if (HDF5_ENABLE_PROFILING) - list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}") -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) - -#----------------------------------------------------------------------------- -# Option for --enable-optimization -# This option will force/override the default setting for all configurations -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF) -if (HDF5_ENABLE_OPTIMIZATION) - list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}") -endif () -MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION) diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake new file mode 100644 index 0000000..b255e22 --- /dev/null +++ b/config/cmake/HDFCompilerFlags.cmake @@ -0,0 +1,420 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED TRUE) + +macro (ADD_H5_FLAGS h5_flag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_flag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_flag_var=${${h5_flag_var}}") +endmacro () + +set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") +set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") +message (STATUS "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}") +#----------------------------------------------------------------------------- +# Compiler specific flags : Shouldn't there be compiler tests for these +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") + if (${HDF_CFG_NAME} MATCHES "Debug") + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") + endif () + else () + 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 () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) +if (HDF5_DISABLE_COMPILER_WARNINGS) + message (STATUS "....Compiler warnings are suppressed") + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0") + endif () + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif () + # Borland uses -w- to suppress warnings. + if (BORLAND) + set (HDF5_WARNINGS_BLOCKED 1) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") + endif () + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") + endif () +endif () + +#----------------------------------------------------------------------------- +# HDF5 library compile options +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# CDash is configured to only allow 3000 warnings, so +# break into groups (from the config/gnu-flags file) +#----------------------------------------------------------------------------- +if (NOT MSVC) + if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP") + else () + # General flags + # + # Note that some of the flags listed here really should be developer + # flags (listed in a separate variable, below) but we put them here + # because they are not raised by the current code and we'd like to + # know if they do start showing up. + # + # 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. + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") + list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith") + list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized") + list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable") + # this is just a failsafe + list (APPEND H5_CFLAGS0 "-finline-functions") + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) + list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") + list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") + endif() + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") + # gcc automatically inlines based on the optimization level + # this is just a failsafe + list (APPEND H5_CFLAGS0 "-finline-functions") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") + endif () + message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") + endif () + + #----------------------------------------------------------------------------- + # Option to allow the user to enable developer warnings + # Developer warnings (suggestions from gcc, not code problems) + #----------------------------------------------------------------------------- + option (HDF5_ENABLE_DEV_WARNINGS "Enable HDF5 developer group warnings" OFF) + if (HDF5_ENABLE_DEV_WARNINGS) + message (STATUS "....HDF5 developer group warnings are enabled") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + endif () + else () + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + endif () + endif () + + + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + # Append warning flags that only gcc 4.3+ knows about + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + # + # Technically, variable-length arrays are part of the C99 standard, but + # we should approach them a bit cautiously... Only needed for gcc 4.X + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") + endif () + + # Append more extra warning flags that only gcc 4.4+ know about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4") + endif () + endif () + + # Append more extra warning flags that only gcc 4.5+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") + endif () + endif () + + # Append more extra warning flags that only gcc 4.6 and less know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") + endif () + + # Append more extra warning flags that only gcc 4.5-4.6 know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5-4.6") + endif () + + # Append more extra warning flags that only gcc 4.6+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.6") + endif () + endif () + + # Append more extra warning flags that only gcc 4.7+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.7") + endif () + endif () + + # Append more extra warning flags that only gcc 4.8+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") + else () + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") + endif () + endif () + + # Append more extra warning flags that only gcc 4.9+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") + endif () + + # Append more extra warning flags that only gcc 5.1+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") + endif () + + # Append more extra warning flags that only gcc 6.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") + endif () + + # Append more extra warning flags that only gcc 7.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) + ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") + #else () + # ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") + endif () + endif () + + # Append more extra warning flags that only gcc 8.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) + ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") + else () + ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") + endif () + endif () + + # Append more extra warning flags that only gcc 9.x+ know about + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) + ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable all warnings +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) +if (HDF5_ENABLE_ALL_WARNINGS) + message (STATUS "....All Warnings are enabled") + if (MSVC) + if (HDF5_ENABLE_DEV_WARNINGS) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") + else () + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W3") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) +if (HDF5_ENABLE_GROUPZERO_WARNINGS) + message (STATUS "....Group Zero warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W1") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) +if (HDF5_ENABLE_GROUPONE_WARNINGS) + message (STATUS "....Group One warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W2") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) +if (HDF5_ENABLE_GROUPTWO_WARNINGS) + message (STATUS "....Group Two warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W3") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) +if (HDF5_ENABLE_GROUPTHREE_WARNINGS) + message (STATUS "....Group Three warnings are enabled") + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W4") + else () + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) +if (HDF5_ENABLE_GROUPFOUR_WARNINGS) + message (STATUS "....Group Four warnings are enabled") + if (NOT MSVC) + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# This is in here to help some of the GCC based IDES like Eclipse +# and code blocks parse the compiler errors and warnings better. +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-asserts +# By default, CMake adds NDEBUG to CMAKE_${lang}_FLAGS for Release build types +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +#option (HDF5_ENABLE_ASSERTS "Determines whether NDEBUG is defined to control assertions." OFF) +set (HDF5_ENABLE_ASSERTS "OFF" CACHE STRING "Determines whether NDEBUG is defined to control assertions (OFF NO YES)") +set_property (CACHE HDF5_ENABLE_ASSERTS PROPERTY STRINGS OFF NO YES) +if (HDF5_ENABLE_ASSERTS MATCHES "YES") + add_compile_options ("-UNDEBUG") +elseif (HDF5_ENABLE_ASSERTS MATCHES "NO") + add_compile_options ("-DNDEBUG") +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_ASSERTS) + +#----------------------------------------------------------------------------- +# Option for --enable-symbols +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +#option (HDF5_ENABLE_SYMBOLS "Add debug symbols to the library independent of the build mode and optimization level." OFF) +set (HDF5_ENABLE_SYMBOLS "OFF" CACHE STRING "Add debug symbols to the library independent of the build mode and optimization level (OFF NO YES)") +set_property (CACHE HDF5_ENABLE_SYMBOLS PROPERTY STRINGS OFF NO YES) +if (HDF5_ENABLE_SYMBOLS MATCHES "YES") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer") + endif () +elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") + if (CMAKE_C_COMPILER_ID STREQUAL "Intel") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") + elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") + endif () +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) + +#----------------------------------------------------------------------------- +# Option for --enable-profiling +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF) +if (HDF5_ENABLE_PROFILING) + list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}") +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) + +#----------------------------------------------------------------------------- +# Option for --enable-optimization +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF) +if (HDF5_ENABLE_OPTIMIZATION) + list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}") +endif () +MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION) -- cgit v0.12 From 3247291b1e9e8eb4261c8be7d0b6a3bc17870320 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 09:40:22 -0500 Subject: Fix missing endif --- config/cmake/HDFFortranCompilerFlags.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 4d63c95..a18d830 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -137,5 +137,6 @@ else () if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") #ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f08" "/free") + endif () endif () -- cgit v0.12 From a3c57c730cd5109eec34fd63fa560ba6437e3441 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 10:34:16 -0500 Subject: Update intel flags --- config/cmake/HDFFortranCompilerFlags.cmake | 4 ++-- config/gnu-warnings/gfort-general | 1 + config/intel-fflags | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index a18d830..f31eba5 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -70,7 +70,7 @@ if (NOT MSVC) # General flags if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/ifort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand:f08" "-free") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand:f03" "-free") elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-std=f2008" "-fimplicit-none") @@ -136,7 +136,7 @@ if (NOT MSVC) else () if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") #ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f08" "/free") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f03" "/free") endif () endif () diff --git a/config/gnu-warnings/gfort-general b/config/gnu-warnings/gfort-general index 4028316..86b09b1 100644 --- a/config/gnu-warnings/gfort-general +++ b/config/gnu-warnings/gfort-general @@ -9,4 +9,5 @@ -Wimplicit-interface -Wsurprising -Wunderflow +-Wuse-without-only -pedantic diff --git a/config/intel-fflags b/config/intel-fflags index c620ef7..ed7ee52 100644 --- a/config/intel-fflags +++ b/config/intel-fflags @@ -82,6 +82,7 @@ if test "X-ifort" = "X-$f9x_vendor"; then FC_BASENAME=ifort F9XSUFFIXFLAG="" FSEARCH_DIRS="" + H5_FCFLAGS="$H5_FCFLAGS -stand:f03 -free" H5_FCFLAGS="$H5_FCFLAGS $(load_intel_arguments ifort-general)" # Production -- cgit v0.12 From b4dcee96cefac0835986853854c60ff3501f637e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 12:17:43 -0500 Subject: Minor updates and fix settings for fortran flags --- config/cmake/libhdf5.settings.cmake.in | 2 +- fortran/test/CMakeLists.txt | 4 +--- hl/test/CMakeLists.txt | 2 +- test/CMakeLists.txt | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 292eaca..e9a8395 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -46,7 +46,7 @@ Languages: Fortran: @HDF5_BUILD_FORTRAN@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran Compiler: @CMAKE_Fortran_COMPILER@ @CMAKE_Fortran_COMPILER_VERSION@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran Flags: @CMAKE_Fortran_FLAGS@ -@BUILD_FORTRAN_CONDITIONAL_TRUE@ H5 Fortran Flags: @H5_FCFLAGS@ +@BUILD_FORTRAN_CONDITIONAL_TRUE@ H5 Fortran Flags: @HDF5_CMAKE_Fortran_FLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ AM Fortran Flags: @AM_FCFLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Shared Fortran Library: @H5_ENABLE_SHARED_LIB@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Static Fortran Library: @H5_ENABLE_STATIC_LIB@ diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index c135f15..ff7001b 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -163,9 +163,7 @@ else () $<$:BUILD_HDF5_TEST_DLL;HDF5F90_WINDOWS> $<$:${WIN_COMPILE_FLAGS}> ) - target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} - PUBLIC ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} - ) + target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) # set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-SUBSYSTEM:CONSOLE">) # set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:${WIN_LINK_FLAGS}>) # set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$:"-DLL">) diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index b7eac09..6349bb3 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -50,7 +50,7 @@ HL_ADD_EXE (test_h5do_compat) # test_packet has two source files add_executable (hl_test_packet test_packet.c test_packet_vlen.c) - target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}") +target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_test_packet STATIC) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2568761..7a0b2dd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -293,7 +293,6 @@ set (H5_TESTS macro (ADD_H5_EXE file) add_executable (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) - target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (${file} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") if (NOT BUILD_SHARED_LIBS) -- cgit v0.12 From 09ec1166d75bcddc57d261fb2b0a9e01769e80b0 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 14:29:33 -0500 Subject: Reduce window fortran standard to f90 --- config/cmake/HDFFortranCompilerFlags.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index f31eba5..0a3dbf5 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -136,7 +136,7 @@ if (NOT MSVC) else () if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") #ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f03" "/free") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f90" "/free") endif () endif () -- cgit v0.12 From 279ea4f2a25ad8df1d9a677b4df71280a485ca08 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 15:19:28 -0500 Subject: Update printf pointer syntax and revert fortran to f2003 --- config/cmake/HDFFortranCompilerFlags.cmake | 2 +- src/H5trace.c | 212 ++++++++++++++--------------- 2 files changed, 107 insertions(+), 107 deletions(-) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 0a3dbf5..f31eba5 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -136,7 +136,7 @@ if (NOT MSVC) else () if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") #ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") - list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f90" "/free") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f03" "/free") endif () endif () diff --git a/src/H5trace.c b/src/H5trace.c index 03d9e7c..f9f96e2 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -249,7 +249,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -263,7 +263,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -282,7 +282,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -298,7 +298,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -336,7 +336,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -362,7 +362,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -396,7 +396,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'F': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -430,7 +430,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -460,7 +460,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -498,7 +498,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -544,7 +544,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -586,7 +586,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -633,7 +633,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -663,7 +663,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -697,7 +697,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -723,7 +723,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -759,7 +759,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -778,7 +778,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -804,21 +804,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); - HDfprintf(out, "0x%lx", (unsigned long)error); + HDfprintf(out, "0x%p", error); } /* end else */ break; case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -849,7 +849,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -883,7 +883,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -917,7 +917,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -952,7 +952,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1003,7 +1003,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1029,7 +1029,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1038,7 +1038,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1088,7 +1088,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1136,14 +1136,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); - HDfprintf(out, "0x%lx", (unsigned long)statbuf); + HDfprintf(out, "0x%p", statbuf); } break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1157,7 +1157,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hsize_t *p = (hsize_t *)vp; @@ -1191,7 +1191,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hssize_t *p = (hssize_t *)vp; @@ -1221,7 +1221,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1417,7 +1417,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1451,7 +1451,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1489,7 +1489,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { int *p = (int*)vp; @@ -1513,7 +1513,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1603,7 +1603,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned *p = (unsigned*)vp; @@ -1633,7 +1633,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1651,7 +1651,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1697,7 +1697,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1713,7 +1713,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1729,7 +1729,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1788,7 +1788,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1804,7 +1804,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1852,7 +1852,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1879,7 +1879,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1893,7 +1893,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1907,7 +1907,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'r': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1921,7 +1921,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1975,7 +1975,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2009,7 +2009,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2067,7 +2067,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2115,7 +2115,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2131,7 +2131,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2178,7 +2178,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2208,7 +2208,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2238,7 +2238,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2272,7 +2272,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2314,7 +2314,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2352,7 +2352,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2386,7 +2386,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2456,7 +2456,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2512,7 +2512,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2533,7 +2533,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long *p = (unsigned long *)vp; @@ -2557,7 +2557,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long long *p = (unsigned long long *)vp; @@ -2589,7 +2589,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2625,7 +2625,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'A': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2643,7 +2643,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2673,7 +2673,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'B': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2703,7 +2703,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'C': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2720,7 +2720,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2756,7 +2756,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2783,7 +2783,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2807,7 +2807,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2831,7 +2831,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'g': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2873,7 +2873,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2912,7 +2912,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2936,7 +2936,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'j': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2960,7 +2960,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2987,7 +2987,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3014,7 +3014,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3038,7 +3038,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3065,7 +3065,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3095,7 +3095,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3131,7 +3131,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'r': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3158,7 +3158,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3181,7 +3181,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'S': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3238,7 +3238,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3286,7 +3286,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3304,7 +3304,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3409,7 +3409,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'w': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3435,7 +3435,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3453,7 +3453,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'y': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3489,7 +3489,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3513,14 +3513,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { void **p = (void**)vp; HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) { if(p[i]) - HDfprintf(out, "%s0x%lx", (i ? ", " : ""), (unsigned long)(p[i])); + HDfprintf(out, "%s0x%p", (i ? ", " : ""), p[i]); else HDfprintf(out, "%sNULL", (i ? ", " : "")); } /* end for */ @@ -3534,7 +3534,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) vp = HDva_arg (ap, void *); if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end else */ @@ -3543,7 +3543,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { size_t *p = (size_t *)vp; @@ -3569,7 +3569,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3599,21 +3599,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); - HDfprintf(out, "0x%lx", (unsigned long)filter); + HDfprintf(out, "0x%p", filter); } /* end else */ break; case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3632,7 +3632,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3649,7 +3649,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { ssize_t *p = (ssize_t *)vp; -- cgit v0.12 From e31bb02d3813ba6ce4a0225315a5d8d71ade8431 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Apr 2020 16:12:43 -0500 Subject: Remove flag from gfort-general in gfort-5, add /EHsc to Win C++ --- config/cmake/HDFCXXCompilerFlags.cmake | 2 ++ config/gnu-warnings/gfort-general | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index d828c10..bf22886 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -155,6 +155,8 @@ if (NOT MSVC) # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") # endif () #endif () +else () + list (APPEND HDF5_CMAKE_CXX_FLAGS "/EHsc") endif () #----------------------------------------------------------------------------- diff --git a/config/gnu-warnings/gfort-general b/config/gnu-warnings/gfort-general index 86b09b1..4028316 100644 --- a/config/gnu-warnings/gfort-general +++ b/config/gnu-warnings/gfort-general @@ -9,5 +9,4 @@ -Wimplicit-interface -Wsurprising -Wunderflow --Wuse-without-only -pedantic -- cgit v0.12 From f362e14add76bc137c8f9bb8542a697e48900b91 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 7 Apr 2020 07:37:49 -0500 Subject: Hide Frortran directive warnings --- config/cmake/CTestCustom.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index 7f71e8d..725e382 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -18,23 +18,18 @@ set (CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 50000) set (CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} -# "H5detect.c.[0-9]+.[ \t]*:[ \t]*warning C4090:" -# "H5detect.c.[0-9]+.[ \t]*:[ \t]*warning:[ \t]*passing argument" -# "H5detect.c[0-9 \t:]*warning:[ \t]*passing argument" "note.*expected.*void.*but argument is of type.*volatile" -# "H5Tconv.c[0-9 \t:]*warning:[ \t]*comparison is always false due to limited range of data type" -# "H5Ztrans.c.[0-9]+.[ \t]*:[ \t]*warning C4244" "src.ZLIB.*:[ \t]*warning" "warning LNK4197:.*ZLIB-prefix" "src.SZIP.*:[ \t]*warning" # "POSIX name for this item is deprecated" "disabling jobserver mode" "config.cmake.xlatefile.c" -# "warning.*implicit declaration of function" "warning.*unknown pragma" "warning.*unrecognized .pragma" # "note: expanded from macro" -# "fpp:[ \t]*warning:[ \t]*cannot remove H5_DEBUG_API - not a predefined macro" + # HDDFFV-11074 + "This directive is not standard" ) set (CTEST_CUSTOM_MEMCHECK_IGNORE -- cgit v0.12