summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2020-04-20 21:03:08 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2020-04-21 00:36:40 (GMT)
commit1862abdd0512d4f2505b3807fedd20f6ccedb31f (patch)
tree252e33a442cc755a1d1c719f1e62044d741f6794
parent6524e17885b939554beb63d7b9df10259ef4d1e5 (diff)
downloadhdf5-1862abdd0512d4f2505b3807fedd20f6ccedb31f.zip
hdf5-1862abdd0512d4f2505b3807fedd20f6ccedb31f.tar.gz
hdf5-1862abdd0512d4f2505b3807fedd20f6ccedb31f.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.
-rw-r--r--config/cmake/HDFCXXCompilerFlags.cmake19
-rw-r--r--config/cmake/HDFCompilerFlags.cmake19
-rw-r--r--config/gnu-cxxflags50
-rw-r--r--config/gnu-flags6
4 files changed, 53 insertions, 41 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 ()
diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags
index e177aef..b3b082d 100644
--- a/config/gnu-cxxflags
+++ b/config/gnu-cxxflags
@@ -79,9 +79,9 @@ if test "X-" = "X-$cxx_flags_set"; then
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.`
- test -n "$cc_vers_major" || cxx_vers_major=0
- test -n "$cc_vers_minor" || cxx_vers_minor=0
- test -n "$cc_vers_patch" || cxx_vers_patch=0
+ test -n "$cxx_vers_major" || cxx_vers_major=0
+ test -n "$cxx_vers_minor" || cxx_vers_minor=0
+ test -n "$cxx_vers_patch" || cxx_vers_patch=0
cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch`
fi
@@ -180,10 +180,12 @@ if test "X-g++" = "X-$cxx_vendor"; then
# General #
###########
- 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)"
+ if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -gt 4; then
+ 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)"
+ fi
######################
# Developer warnings #
@@ -197,27 +199,27 @@ if test "X-g++" = "X-$cxx_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
+ if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 6; then
H5_CXXFLAGS="$H5_CXXFLAGS $(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
+ if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 3; then
H5_CXXFLAGS="$H5_CXXFLAGS $(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
+ if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 6; then
H5_CXXFLAGS="$H5_CXXFLAGS $(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
+ if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2 -a $cxx_vers_major -eq 4 -a $cxx_vers_minor -le 4; then
H5_CXXFLAGS="$H5_CXXFLAGS $(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
+ if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 2; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.last)"
fi
@@ -226,68 +228,68 @@ if test "X-g++" = "X-$cxx_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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 3; then
H5_CXXFLAGS="$H5_CXXFLAGS $(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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 4; then
H5_CXXFLAGS="$H5_CXXFLAGS $(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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 5; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5)"
DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.5)"
NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 6; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.6)"
DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.6)"
NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 7; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.7)"
DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.7)"
NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 8; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.8)"
DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.8)"
NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_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
+ if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 9; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.9)"
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-4.9)"
fi
# gcc >= 5
- if test $cc_vers_major -ge 5; then
+ if test $cxx_vers_major -ge 5; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 5)"
H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-5)"
fi
# gcc >= 6
- if test $cc_vers_major -ge 6; then
+ if test $cxx_vers_major -ge 6; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 6)"
fi
# gcc >= 7
- if test $cc_vers_major -ge 7; then
+ if test $cxx_vers_major -ge 7; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 7)"
DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-7)"
fi
# gcc 8
- if test $cc_vers_major -ge 8; then
+ if test $cxx_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_gnu_arguments developer-8)"
@@ -295,7 +297,7 @@ if test "X-g++" = "X-$cxx_vendor"; then
fi
# gcc 9
- if test $cc_vers_major -ge 9; then
+ if test $cxx_vers_major -ge 9; then
H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)"
fi
diff --git a/config/gnu-flags b/config/gnu-flags
index ad07552..dba9324 100644
--- a/config/gnu-flags
+++ b/config/gnu-flags
@@ -188,8 +188,10 @@ if test "X-gcc" = "X-$cc_vendor"; then
# General #
###########
- H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments general)"
- H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)"
+ if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -gt 4; then
+ H5_CFLAGS="$H5_CFLAGS $(load_gnu_arguments general)"
+ H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)"
+ fi
######################
# Developer warnings #