summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-03-23 20:10:33 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-03-23 20:10:33 (GMT)
commitd9a5a49e654399c99fe6356340da62e47f6878e2 (patch)
treeb12e65fc3dc5dd5ce8521fa82833bc5d839b0a0d
parent477c96f06f891b2f6477b8f5bc8a979c5eb90074 (diff)
downloadhdf5-d9a5a49e654399c99fe6356340da62e47f6878e2.zip
hdf5-d9a5a49e654399c99fe6356340da62e47f6878e2.tar.gz
hdf5-d9a5a49e654399c99fe6356340da62e47f6878e2.tar.bz2
Update CMake compiler flags to use same set of warnings
-rw-r--r--config/cmake/HDFCompilerFlags.cmake113
1 files changed, 82 insertions, 31 deletions
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index c395193..127b710 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -131,12 +131,8 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
ADD_H5_FLAGS (CMAKE_C_FLAGS_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings/general")
message (STATUS "CMAKE_C_FLAGS_GENERAL=${CMAKE_C_FLAGS_GENERAL}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_GENERAL}")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wcast-align")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wdeclaration-after-statement -Wdisabled-optimization")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-declarations")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wswitch-default")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunused-macros -Wunsafe-loop-optimizations")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_ERROR_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general")
+ set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_ERROR_GENERAL}")
# gcc automatically inlines based on the optimization level
# this is just a failsafe
set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
@@ -167,82 +163,137 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# Append warning flags that only gcc 4.3+ knows about
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_4_3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_4_3}")
#
# Technically, variable-length arrays are part of the C99 standard, but
- # we should approach them a bit cautiously... -QAK
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wlogical-op -Wlarger-than=2560 -Wvla")
+ # 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 (CMAKE_C_FLAGS_4_LAST "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_4_LAST}")
+ endif
# Append more extra warning flags that only gcc 4.4+ know about
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat")
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_4_4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_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)
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wstrict-overflow=5 -Wjump-misses-init")
- if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunsuffixed-float-constants")
- else ()
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wno-unsuffixed-float-constants")
- endif ()
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_4_5 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_4_5}")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_4_5 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_DEV_4_5}")
+ else ()
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_4_5 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_NO_DEV_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 (CMAKE_C_FLAGS_4_2_4_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_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 (CMAKE_C_FLAGS_4_5_4_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5-4.6")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_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)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdouble-promotion -Wtrampolines")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_4_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_4_6}")
if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=const")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_4_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_DEV_4_6}")
else ()
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-suggest-attribute=const")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_4_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.6")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_NO_DEV_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)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wstack-usage=8192 -Wvector-operation-performance")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_4_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_4_7}")
if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_4_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_DEV_4_7}")
else ()
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_4_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.7")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_NO_DEV_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 (CMAKE_C_FLAGS_4_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_4_8}")
if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=format")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_4_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_DEV_4_8}")
else ()
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-suggest-attribute=format")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_4_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_NO_DEV_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)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdate-time")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_4_9 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_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.1)
- set (H5_CFLAGS3 "${H5_CFLAGS3} -Warray-bounds=2 -Wc99-c11-compat")
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_5 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_5}")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_ERROR_5 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_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)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Wnull-dereference -Wunused-const-variable -Wduplicated-cond -Whsa -Wnormalized")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6")
+ set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_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)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wimplicit-fallthrough=5 -Wrestrict")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7")
+ set (H5_CFLAGS2 "${H5_CFLAGS2} ${CMAKE_C_FLAGS_7}")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7")
+ set (H5_CFLAGS2 "${H5_CFLAGS2} ${CMAKE_C_FLAGS_DEV_7}")
+ #else ()
+ # ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7")
+ # set (H5_CFLAGS2 "${H5_CFLAGS2} ${CMAKE_C_FLAGS_NO_DEV_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)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8")
+ set (H5_CFLAGS3 "${H5_CFLAGS3} ${CMAKE_C_FLAGS_8}")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8")
+ set (H5_CFLAGS3 "${H5_CFLAGS3} ${CMAKE_C_FLAGS_DEV_8}")
+ else ()
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8")
+ set (H5_CFLAGS3 "${H5_CFLAGS3} ${CMAKE_C_FLAGS_NO_DEV_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)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Wattribute-alias=2 -Wmissing-profile")
+ ADD_H5_FLAGS (CMAKE_C_FLAGS_9 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9")
+ set (H5_CFLAGS4 "${H5_CFLAGS4} ${CMAKE_C_FLAGS_9}")
endif ()
elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Minform=inform")
@@ -272,7 +323,7 @@ if (HDF5_ENABLE_ALL_WARNINGS)
endif ()
else ()
if (CMAKE_COMPILER_IS_GNUCC)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2}")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}")
endif ()
endif ()
endif ()