Make changes to CMake CompilerFlags.cmake files so extra flags are

loaded for non-GNU compilers.
This commit is contained in:
Larry Knox 2020-06-10 14:25:10 -05:00
parent 32c353ed43
commit 77efb340a1
4 changed files with 35 additions and 60 deletions

View File

@ -1,3 +1,4 @@
-Wformat-nonliteral
-Wmissing-noreturn
-Wsometimes-uninitialized
-Wswitch-enum

View File

@ -4,20 +4,16 @@
#
-Werror=bad-function-cast
-Werror=implicit-function-declaration
#-Werror=incompatible-pointer-types
-Werror=incompatible-pointer-types
-Werror=missing-declarations
-Werror=packed
-Werror=shadow
#-Werror=sometimes-uninitialized
-Werror=switch
#
#-Werror=discarded-qualifiers
# NOTE: Following files are not compatible with incompatible-pointer-types as errors
# src/H5Dchunk.c,src/H5Dint.c,src/H5Gint.c,src/H5HFcache.c,src/H5I.c,src/H5T.c
-Wno-error=incompatible-pointer-types-discards-qualifiers
#
# Note: For macos 10.12, etc
# H5Dint.c,H5Dchunk.c,H5Gint.c
# -Wincompatible-pointer-types-discards-qualifiers
# # H5Dvirtual.c,H5SL.c
# -Wsometimes-uninitialized
#
# NOTE: File Driver files are not compatible with these warnings as errors
# H5FDdirect.c,H5FDmpio.c,H5FDros3.c,

View File

@ -40,7 +40,7 @@ if (HDF5_DISABLE_COMPILER_WARNINGS)
# warning level is given, so remove it.
if (MSVC)
set (HDF5_WARNINGS_BLOCKED 1)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (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 ()
@ -51,7 +51,7 @@ if (HDF5_DISABLE_COMPILER_WARNINGS)
# Most compilers use -w to suppress warnings.
if (NOT HDF5_WARNINGS_BLOCKED)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
endif ()
endif ()
@ -65,7 +65,7 @@ endif ()
# CDash is configured to only allow 3000 warnings, so
# break into groups (from the config/gnu-flags file)
#-----------------------------------------------------------------------------
if (NOT MSVC)
if (NOT MSVC AND NOT MINGW)
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP")
else ()
@ -194,7 +194,9 @@ if (NOT MSVC)
endif ()
endif ()
else ()
if (NOT MINGW)
list (APPEND HDF5_CMAKE_CXX_FLAGS "/EHsc")
endif ()
endif ()
#-----------------------------------------------------------------------------
@ -204,21 +206,19 @@ 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)
if (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)
if (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 ()
if (CMAKE_CXX_COMPILER_LOADED)
list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS0} ${H5_CXXFLAGS1} ${H5_CXXFLAGS2} ${H5_CXXFLAGS3} ${H5_CXXFLAGS4})
endif ()
endif ()
endif ()
@ -229,15 +229,13 @@ endif ()
if (HDF5_ENABLE_GROUPZERO_WARNINGS)
message (STATUS "....Group Zero warnings are enabled")
if (MSVC)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (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_CXXFLAGS0})
endif ()
if (CMAKE_CXX_COMPILER_LOADED)
list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS0})
endif ()
endif ()
endif ()
@ -248,15 +246,13 @@ endif ()
if (HDF5_ENABLE_GROUPONE_WARNINGS)
message (STATUS "....Group One warnings are enabled")
if (MSVC)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (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_CXXFLAGS1})
endif ()
if (CMAKE_CXX_COMPILER_LOADED)
list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS1})
endif ()
endif ()
endif ()
@ -267,15 +263,13 @@ endif ()
if (HDF5_ENABLE_GROUPTWO_WARNINGS)
message (STATUS "....Group Two warnings are enabled")
if (MSVC)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (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_CXXFLAGS2})
endif ()
if (CMAKE_CXX_COMPILER_LOADED)
list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS2})
endif ()
endif ()
endif ()
@ -286,15 +280,13 @@ endif ()
if (HDF5_ENABLE_GROUPTHREE_WARNINGS)
message (STATUS "....Group Three warnings are enabled")
if (MSVC)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (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_CXXFLAGS3})
endif ()
if (CMAKE_CXX_COMPILER_LOADED)
list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS3})
endif ()
endif ()
endif ()
@ -305,10 +297,8 @@ endif ()
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_CXXFLAGS4})
endif ()
if (CMAKE_CXX_COMPILER_LOADED)
list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS4})
endif ()
endif ()
endif ()

View File

@ -68,7 +68,7 @@ endif ()
# CDash is configured to only allow 3000 warnings, so
# break into groups (from the config/gnu-flags file)
#-----------------------------------------------------------------------------
if (NOT MSVC)
if (NOT MSVC AND NOT MINGW)
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP")
else ()
@ -209,9 +209,7 @@ if (HDF5_ENABLE_ALL_WARNINGS)
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 ()
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4})
endif ()
endif ()
@ -225,9 +223,7 @@ if (HDF5_ENABLE_GROUPZERO_WARNINGS)
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 ()
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0})
endif ()
endif ()
@ -241,9 +237,7 @@ if (HDF5_ENABLE_GROUPONE_WARNINGS)
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 ()
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1})
endif ()
endif ()
@ -257,9 +251,7 @@ if (HDF5_ENABLE_GROUPTWO_WARNINGS)
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 ()
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2})
endif ()
endif ()
@ -273,9 +265,7 @@ if (HDF5_ENABLE_GROUPTHREE_WARNINGS)
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 ()
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3})
endif ()
endif ()
@ -286,9 +276,7 @@ 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 ()
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4})
endif ()
endif ()