TRILAB-192 restrict extensive warnings to libraries

This commit is contained in:
Allen Byrne 2020-03-24 16:45:12 -05:00
parent 77bac54352
commit 1505fa1498
8 changed files with 142 additions and 146 deletions

View File

@ -90,6 +90,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_CPP_LIB_TARGET}
PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
)
target_compile_definitions(${HDF5_CPP_LIB_TARGET}
PRIVATE $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings
)
@ -107,6 +110,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_CPP_LIBSH_TARGET}
PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
)
target_compile_definitions(${HDF5_CPP_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
PRIVATE $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings

View File

@ -23,7 +23,7 @@ macro (ADD_H5_FLAGS h5_flag_var infile)
string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}")
#message (STATUS "str_flag=${str_flag}")
if (str_flag)
set (${h5_flag_var} "${${h5_flag_var}} ${str_flag}")
list (APPEND ${h5_flag_var} "${str_flag}")
endif ()
endforeach ()
endif ()
@ -97,13 +97,17 @@ if (HDF5_DISABLE_COMPILER_WARNINGS)
endif ()
endif ()
#-----------------------------------------------------------------------------
# HDF5 library compile options
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# CDash is configured to only allow 3000 warnings, so
# break into groups (from the config/gnu-flags file)
#-----------------------------------------------------------------------------
if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=%none -DBSD_COMP")
list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP")
else ()
# General flags
#
@ -115,28 +119,24 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
# 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.
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
ADD_H5_FLAGS (CMAKE_C_FLAGS_GENERAL "${HDF5_SOURCE_DIR}/config/intel-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} -Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wreturn-type -Wstrict-prototypes -Wuninitialized")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunknown-pragmas -Wunused-function -Wunused-variable")
ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings-general")
message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}")
list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith")
list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized")
list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable")
# this is just a failsafe
set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
list (APPEND H5_CFLAGS0 "-finline-functions")
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0)
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Wsign-compare -Wtrigraphs -Wwrite-strings")
list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow")
list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings")
endif()
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
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}")
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}")
ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general")
message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}")
ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general")
# gcc automatically inlines based on the optimization level
# this is just a failsafe
set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
message (STATUS "H5_CFLAGS0=${H5_CFLAGS0}")
list (APPEND H5_CFLAGS0 "-finline-functions")
endif ()
endif ()
@ -148,155 +148,125 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
if (HDF5_ENABLE_DEV_WARNINGS)
message (STATUS "....HDF5 developer group warnings are enabled")
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Wreorder -Wport -Wstrict-aliasing")
list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general")
set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_DEV_GENERAL}")
ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general")
endif ()
else ()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general")
set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_NO_DEV_GENERAL}")
ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general")
endif ()
endif ()
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}")
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)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last")
endif ()
# Append more extra warning flags that only gcc 4.4+ know about
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6")
if (HDF5_ENABLE_DEV_WARNINGS)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6")
else ()
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-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)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7")
if (HDF5_ENABLE_DEV_WARNINGS)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7")
else ()
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8")
if (HDF5_ENABLE_DEV_WARNINGS)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8")
else ()
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-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)
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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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.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}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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)
ADD_H5_FLAGS (CMAKE_C_FLAGS_6 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6")
set (H5_CFLAGS1 "${H5_CFLAGS1} ${CMAKE_C_FLAGS_6}")
ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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)
ADD_H5_FLAGS (CMAKE_C_FLAGS_7 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7")
set (H5_CFLAGS2 "${H5_CFLAGS2} ${CMAKE_C_FLAGS_7}")
ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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}")
ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-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}")
# ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-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)
ADD_H5_FLAGS (CMAKE_C_FLAGS_8 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8")
set (H5_CFLAGS3 "${H5_CFLAGS3} ${CMAKE_C_FLAGS_8}")
ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/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}")
ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-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}")
ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-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)
ADD_H5_FLAGS (CMAKE_C_FLAGS_9 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9")
set (H5_CFLAGS4 "${H5_CFLAGS4} ${CMAKE_C_FLAGS_9}")
ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9")
endif ()
elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Minform=inform")
list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform")
endif ()
#-----------------------------------------------------------------------------
@ -308,22 +278,22 @@ if (HDF5_ENABLE_ALL_WARNINGS)
if (MSVC)
if (HDF5_ENABLE_DEV_WARNINGS)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /wd4668")
list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /wd4668")
list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall /wd4668")
endif ()
else ()
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
list (APPEND HDF5_CMAKE_C_FLAGS "/W3")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3")
endif ()
endif ()
else ()
if (CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}")
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4})
endif ()
endif ()
endif ()
@ -335,15 +305,15 @@ 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")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
list (APPEND HDF5_CMAKE_C_FLAGS "/W1")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W1")
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)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0}")
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0})
endif ()
endif ()
endif ()
@ -355,14 +325,14 @@ 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")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
list (APPEND HDF5_CMAKE_C_FLAGS "/W2")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2")
endif ()
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS1}")
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1})
endif ()
endif ()
@ -373,14 +343,14 @@ 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")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
list (APPEND HDF5_CMAKE_C_FLAGS "/W3")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3")
endif ()
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS2}")
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2})
endif ()
endif ()
@ -391,14 +361,14 @@ 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")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
list (APPEND HDF5_CMAKE_C_FLAGS "/W4")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4")
endif ()
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS3}")
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3})
endif ()
endif ()
@ -409,7 +379,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)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS4}")
list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4})
endif ()
endif ()
@ -481,9 +451,9 @@ MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS)
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF)
if (HDF5_ENABLE_PROFILING)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROFILE_CFLAGS}")
list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}")
if(CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROFILE_CXXFLAGS}")
list (APPEND HDF5_CMAKE_CXX_FLAGS "${PROFILE_CXXFLAGS}")
endif ()
endif ()
MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING)
@ -494,9 +464,9 @@ MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING)
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF)
if (HDF5_ENABLE_OPTIMIZATION)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPTIMIZE_CFLAGS}")
list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}")
if(CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZE_CXXFLAGS}")
list (APPEND HDF5_CMAKE_CXX_FLAGS "${OPTIMIZE_CXXFLAGS}")
endif ()
endif ()
MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION)

View File

@ -12,12 +12,8 @@
-Werror=redundant-decls
-Werror=switch
#-Werror=discarded-qualifiers
#
# NOTE: CMake FortranCInterface module fails to compile with
# -Werror=missing-declarations
# -Werror=missing-prototypes
-Wmissing-declarations
-Wmissing-prototypes
-Werror=missing-declarations
-Werror=missing-prototypes
#
# NOTE: File Driver files are not compatible with these warnings as errors
# H5FDdirect.c,H5FDmpio.c,H5FDros3.c,
@ -31,50 +27,47 @@
-Wunused-parameter
#
#
# NOTE: Examples files are not compatible with these warnings as errors
# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c
# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c
# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c
# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c
# h5_reference_deprec.c
# -Werror=unused-but-set-variable
-Wunused-but-set-variable
# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,
# -Werror=unused-variable
# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c
# -Werror=unused-parameter
# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
# -Werror=strict-prototypes
-Wstrict-prototypes
# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
# -Werror=old-style-definition
-Wold-style-definition
#
#
# NOTE: Tools files are not compatible with these warnings as errors
# lib/h5tools.c
# -Werror=cast-align
-Wcast-align
# lib/h5diff_array.c
# -Werror=unused-but-set-variable
-Werror=unused-but-set-variable
# lib/h5tools_utils.c
# -Werror=unused-parameter
#
#
# NOTE: Test files are not compatible with these warnings as errors
# thread_id.c,
# -Werror=unused-function
# dsets.c
# -Werror=unused-parameter
# external.c,perform/sio_engine.c
# -Werror=format(-trunaction)
-Wformat
#
#
# NOTE: JNI files are not compatible with these warnings as errors
# jni/h5pDCPLImp.c,jni/nativeData.c,jni/h5util.c,jni/h5rImp.c
# jni/h5sImp.c,jni/h5tImp.c
# -Werror=cast-align
# jni/h5util.c
# -Werror=format(-overflow)
-Wformat
#
#
# NOTE: Test files are not compatible with these warnings as errors
# thread_id.c,
# -Werror=unused-function
# dsets.c
# -Werror=unused-parameter
# external.c,perform/sio_engine.c
# -Werror=format(-truncation)
#
#
# NOTE: Examples files are not compatible with these warnings as errors
# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c
# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c
# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c
# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c
# h5_reference_deprec.c
# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
-Werror=strict-prototypes
# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
-Werror=old-style-definition
# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,
# -Werror=unused-variable
# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c
# -Werror=unused-parameter

View File

@ -14,6 +14,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_HL_CPP_LIB_TARGET}
PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
)
TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_HL_CPP_LIB_TARGET} PUBLIC ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET})
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIB_TARGET}")
@ -28,6 +31,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_HL_CPP_LIBSH_TARGET}
PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
)
target_compile_definitions(${HDF5_HL_CPP_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
)

View File

@ -38,6 +38,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_HL_LIB_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
TARGET_C_PROPERTIES (${HDF5_HL_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_HL_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET})
H5_SET_LIB_OPTIONS (${HDF5_HL_LIB_TARGET} ${HDF5_HL_LIB_NAME} STATIC 0)
@ -52,6 +55,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_HL_LIBSH_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
target_compile_definitions(${HDF5_HL_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
)

View File

@ -79,6 +79,9 @@ add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JA
target_include_directories (${HDF5_JAVA_JNI_LIB_TARGET}
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_JAVA_JNI_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
)
target_compile_options(${HDF5_JAVA_JNI_LIB_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED)
target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${HDF5_LIBSH_TARGET})
set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni)

View File

@ -1137,6 +1137,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_LIB_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
target_compile_definitions(${HDF5_LIB_TARGET}
PUBLIC
${HDF_EXTRA_C_FLAGS}
@ -1173,6 +1176,9 @@ if (BUILD_SHARED_LIBS)
PUBLIC "$<$<BOOL:${HDF5_ENABLE_HDFS}>:${HDFS_INCLUDE_DIR}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_LIBSH_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
target_compile_definitions(${HDF5_LIBSH_TARGET}
PUBLIC
"H5_BUILT_AS_DYNAMIC_LIB"

View File

@ -38,6 +38,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_TOOLS_LIB_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
#target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5_TOOLS_DEBUG)
#target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5DIFF_DEBUG)
TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} STATIC)
@ -57,6 +60,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
target_compile_options(${HDF5_TOOLS_LIBSH_TARGET}
PRIVATE "${HDF5_CMAKE_C_FLAGS}"
)
target_compile_definitions(${HDF5_TOOLS_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
#PRIVATE H5_TOOLS_DEBUG