diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2020-04-20 21:03:08 (GMT) |
---|---|---|
committer | Larry Knox <lrknox@hdfgroup.org> | 2020-04-21 00:32:48 (GMT) |
commit | 49a76869aa9ad1c4325106de201294dafcd199b5 (patch) | |
tree | 84ca058b94e972c16acb77e5501ef1d48e3fadc2 /config/cmake | |
parent | 0c59431279767f33c64478581d5d11bcfe087e30 (diff) | |
download | hdf5-49a76869aa9ad1c4325106de201294dafcd199b5.zip hdf5-49a76869aa9ad1c4325106de201294dafcd199b5.tar.gz hdf5-49a76869aa9ad1c4325106de201294dafcd199b5.tar.bz2 |
Don't add general warnings flags for unsupported old versions of gcc and
g++ (older than gcc/g++ 4.2).
Correct gnu-cxxflags to determine warnings flags to be added based on
C++ compiler version instead of C compiler version.
Diffstat (limited to 'config/cmake')
-rw-r--r-- | config/cmake/HDFCXXCompilerFlags.cmake | 19 | ||||
-rw-r--r-- | config/cmake/HDFCompilerFlags.cmake | 19 |
2 files changed, 23 insertions, 15 deletions
diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 6aa8784..721fca4 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -103,8 +103,10 @@ if (NOT MSVC) 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) - # autotools always add the C flags with the CXX flags + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) + # autotools always add the C flags with the CXX flags, except for + # with older versions that are no longer supported ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") endif () @@ -141,16 +143,17 @@ if (NOT MSVC) endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # Append warning flags that only gcc 4.3+ knows about - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${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_CXX_COMPILER_VERSION VERSION_LESS 5.0) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") endif () + # Append warning flags that only gcc 4.3+ knows about + # autotools always add the C flags with the CXX flags + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) + ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + endif() # Append more extra warning flags that only gcc 4.4+ know about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) @@ -172,7 +175,7 @@ if (NOT MSVC) endif () # Append more extra warning flags that only gcc 4.6 and less know about - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") endif () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 72141c0..a40b525 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -111,8 +111,11 @@ if (NOT MSVC) 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") + # Add general CFlags except for older versions that are no longer supported + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) + 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") + endif () # gcc automatically inlines based on the optimization level # this is just a failsafe list (APPEND H5_CFLAGS0 "-finline-functions") @@ -149,14 +152,16 @@ if (NOT MSVC) 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) + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last") endif () + # Append warning flags that only gcc 4.3+ knows about + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) + ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + endif () + # Append more extra warning flags that only gcc 4.4+ know about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) @@ -174,7 +179,7 @@ if (NOT MSVC) endif () # Append more extra warning flags that only gcc 4.6 and less know about - if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2) ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6") endif () |