diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2018-08-21 13:07:27 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2018-08-21 13:07:27 (GMT) |
commit | 0b87689625f9d9e29692d119d4eb323ece726abb (patch) | |
tree | 823086551dc2a7f5ec6221e91d740edc4bdb5f5d /config/cmake | |
parent | e7ac7c896dc5637e2228d5bd902e8427d09dcff1 (diff) | |
download | hdf5-0b87689625f9d9e29692d119d4eb323ece726abb.zip hdf5-0b87689625f9d9e29692d119d4eb323ece726abb.tar.gz hdf5-0b87689625f9d9e29692d119d4eb323ece726abb.tar.bz2 |
Adjust warning flags to match autotools, add configure status
Diffstat (limited to 'config/cmake')
-rw-r--r-- | config/cmake/HDFCompilerFlags.cmake | 105 |
1 files changed, 41 insertions, 64 deletions
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 214afa0..ec13272 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -9,6 +9,8 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # + +message (STATUS "Warnings Configuration:") #----------------------------------------------------------------------------- # Compiler specific flags : Shouldn't there be compiler tests for these #----------------------------------------------------------------------------- @@ -45,6 +47,7 @@ endif () #----------------------------------------------------------------------------- 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) @@ -79,79 +82,55 @@ endif () # break into groups (from the config/gnu-flags file) #----------------------------------------------------------------------------- if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) - if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - set (CMAKE_C_FLAGS_5 "${CMAKE_C_FLAGS_5} -Wcast-qual") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs") - else () + if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") set (CMAKE_C_FLAGS "${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. + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wc++-compat -Wcast-align") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings") + # gcc automatically inlines based on the optimization level + # this is just a failsafe + set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions") endif () #----------------------------------------------------------------------------- # 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) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winline -Waggregate-return") - else () - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-inline -Wno-aggregate-return") - endif () - - # Append warning flags - # Don't use the '-Wtraditional' flag, we're way past having K&R C code - # set (H5_CFLAGS "${H5_CFLAGS} -Wtraditional") - # Don't use the '-Wtraditional-conversion' flag, there's too many warnings - # from GCC's assert macro - # set (H5_CFLAGS "${H5_CFLAGS} -Wtraditional-conversion") - - # 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) - #set (H5_CFLAGS "${H5_CFLAGS} -Wfloat-equal -Wmissing-format-attribute -Wpadded") - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wfloat-equal -Wmissing-format-attribute") - - # Append warning flags from gcc-3.2* case - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wpacked -Wdisabled-optimization") - if (HDF5_ENABLE_DEV_WARNINGS) - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wmissing-noreturn") + message (STATUS "....HDF5 developer group warnings are enabled") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn") else () - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wno-missing-noreturn") + set (H5_CFLAGS0 "${H5_CFLAGS0} -Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn") endif () - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - set (H5_CFLAGS1_5 "${H5_CFLAGS1_5} -Wformat=2") - - # Append warning flags from gcc-3.3* case - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wendif-labels") - - # Append warning flags from gcc-3.4* case - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch") - - # Append more extra warning flags that only gcc4.0+ know about - set (H5_CFLAGS2 "${H5_CFLAGS2} -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 - set (H5_CFLAGS2_5 "${H5_CFLAGS2_5} -Wunsafe-loop-optimizations") - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wc++-compat") - # Append more extra warning flags that only gcc 4.2+ know about - set (H5_CFLAGS2_5 "${H5_CFLAGS2_5} -Wstrict-overflow") - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-strict-overflow") - - # Append more extra warning flags that only gcc 4.3+ know about + # Append warning flags that only gcc 4.3+ knows about # # Technically, variable-length arrays are part of the C99 standard, but # we should approach them a bit cautiously... -QAK - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wlogical-op -Wlarger-than=2048 -Wvla") + set (H5_CFLAGS1 "${H5_CFLAGS1} -Wlogical-op -Wlarger-than=2048 -Wvla") # Append more extra warning flags that only gcc 4.4+ know about - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat") + set (H5_CFLAGS1 "${H5_CFLAGS1} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat") # Append more extra warning flags that only gcc 4.5+ know about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) - set (H5_CFLAGS2_5 "${H5_CFLAGS2_5} -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants") - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wjump-misses-init -Wunsuffixed-float-constants") + set (H5_CFLAGS1 "${H5_CFLAGS1} -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants") endif () # Append more extra warning flags that only gcc 4.6+ know about @@ -164,12 +143,6 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) endif () endif () - # The "unreachable code" warning appears to be reliable now... - # (this warning was removed in gcc 4.5+) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wunreachable-code") - endif () - # Append more extra warning flags that only gcc 4.7+ know about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) set (H5_CFLAGS2 "${H5_CFLAGS2} -Wstack-usage=8192 -Wvector-operation-performance") @@ -191,11 +164,9 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) # Append more extra warning flags that only gcc 4.9+ know about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) - set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdate-time -Wopenmp-simd") + set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdate-time") endif () - # (There was no release of gcc 5.0) - # Append more extra warning flags that only gcc 5.1+ know about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1) set (H5_CFLAGS3 "${H5_CFLAGS3} -Warray-bounds=2 -Wc99-c11-compat") @@ -213,6 +184,7 @@ endif () #----------------------------------------------------------------------------- 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}") @@ -231,7 +203,7 @@ if (HDF5_ENABLE_ALL_WARNINGS) endif () else () if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic ${H5_CFLAGS1} ${H5_CFLAGS2}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2}") endif () endif () endif () @@ -241,6 +213,7 @@ endif () #----------------------------------------------------------------------------- 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]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W1") @@ -250,7 +223,7 @@ if (HDF5_ENABLE_GROUPZERO_WARNINGS) endif () else () if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0}") endif () endif () endif () @@ -260,6 +233,7 @@ endif () #----------------------------------------------------------------------------- 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]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W2") @@ -277,6 +251,7 @@ endif () #----------------------------------------------------------------------------- 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]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") @@ -294,6 +269,7 @@ endif () #----------------------------------------------------------------------------- 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]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") @@ -311,6 +287,7 @@ endif () #----------------------------------------------------------------------------- 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) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS4}") endif () |