From 8d599272c3bf858a72ab6afdda26f4596bfd0da5 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 24 Jun 2015 09:50:59 -0500 Subject: [svn-r27274] HDFFV-9327: Compiler flags for non-windows. Merge from trunk --- CMakeLists.txt | 271 +++++------------------------------ MANIFEST | 9 +- config/cmake/HDFCompilerFlags.cmake | 274 ++++++++++++++++++++++++++++++++++++ 3 files changed, 311 insertions(+), 243 deletions(-) create mode 100644 config/cmake/HDFCompilerFlags.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c9feb51..9cfedf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,24 @@ PROJECT (HDF5 C CXX) # set CMAKE_INSTALL_PREFIX to the required install path. # Make install can be used to install all components for system-wide use. # +if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") + MESSAGE(FATAL_ERROR "\nERROR! ${PROJECT_NAME} DOES NOT SUPPORT IN SOURCE BUILDS!\n" + "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" + " == CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}\n" + "NEXT STEPS:\n" + "(1) Delete the CMakeCache.txt file and the CMakeFiles/ directory\n" + " under the source directory for ${PROJECT_NAME}, otherwise you\n" + " will not be able to configure ${PROJECT_NAME} correctly!\n" + " * For example, on linux machines do:\n" + " $ rm -r CMakeCache.txt CMakeFiles/\n" + "(2) Create a different directory and configure ${PROJECT_NAME} in that directory.\n" + " * For example, on linux machines do:\n" + " $ mkdir MY_BUILD\n" + " $ cd MY_BUILD\n" + " $ cmake [OPTIONS] ..\n" + ) +endif () + #----------------------------------------------------------------------------- # Instructions for use : Sub-Project Build # @@ -29,7 +47,7 @@ PROJECT (HDF5 C CXX) # dependencies to this variable so that external projects pick them up # # HDF5_EXTERNAL_LIB_PREFIX : -# If the parent project needs to install hdf libraries, but avoid +# If the parent project needs to install hdf libraries, but avoid # name conflicts with system versions, then a prefix may be added # to ensure that the correct versions configured are used. # @@ -53,8 +71,8 @@ PROJECT (HDF5 C CXX) # # Setup all necessary overrides for zlib so that HDF5 uses our # # internally compiled zlib rather than any other version # if (HDF5_ENABLE_Z_LIB_SUPPORT) -# # We must tell the main HDF5 library that it depends on our zlib -# set (HDF5_LIB_DEPENDENCIES vtkzlib) +# # We must tell the main HDF5 library that it depends on our zlib +# set (HDF5_LIB_DEPENDENCIES vtkzlib) # # Override the zlib header file # if (VTK_USE_SYSTEM_ZLIB) # set (H5_ZLIB_HEADER "zlib.h") @@ -65,7 +83,7 @@ PROJECT (HDF5 C CXX) # set (ZLIB_LIBRARIES vtkzlib) # endif (VTK_USE_SYSTEM_ZLIB) # endif (HDF5_ENABLE_Z_LIB_SUPPORT) -# +# # # Add the sub project # add_subdirectory (Utilities/hdf5-1.8) #----------------------------------------------------------------------------- @@ -246,7 +264,7 @@ endif (NOT HDF5_EXTERNALLY_CONFIGURED) #----------------------------------------------------------------------------- # Targets built within this project are exported at Install time for use -# by other projects using FindHDF5. +# by other projects using FindHDF5. #----------------------------------------------------------------------------- if (NOT HDF5_EXPORTED_TARGETS) set (HDF5_EXPORTED_TARGETS "hdf5-targets") @@ -313,7 +331,7 @@ endif (HDF5_ENABLE_COVERAGE) # option (HDF5_ENABLE_USING_DMALLOC "Indicate that dmalloc is used" OFF) # if (HDF5_ENABLE_USING_DMALLOC) # find_package (DMALLOC) -# set (H5_HAVE_DMALLOC DMALLOC_FOUND) +# set (H5_HAVE_DMALLOC DMALLOC_FOUND) # endif (HDF5_ENABLE_USING_DMALLOC) #----------------------------------------------------------------------------- @@ -321,7 +339,7 @@ endif (HDF5_ENABLE_COVERAGE) #----------------------------------------------------------------------------- option (HDF5_ENABLE_USING_MEMCHECKER "Indicate that a memory checker is used" OFF) if (HDF5_ENABLE_USING_MEMCHECKER) - set (H5_USING_MEMCHECKER 1) + set (H5_USING_MEMCHECKER 1) endif (HDF5_ENABLE_USING_MEMCHECKER) #----------------------------------------------------------------------------- @@ -329,9 +347,9 @@ endif (HDF5_ENABLE_USING_MEMCHECKER) #----------------------------------------------------------------------------- option (HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON) if (HDF5_ENABLE_DEPRECATED_SYMBOLS) - set (H5_NO_DEPRECATED_SYMBOLS 0) + set (H5_NO_DEPRECATED_SYMBOLS 0) else (HDF5_ENABLE_DEPRECATED_SYMBOLS) - set (H5_NO_DEPRECATED_SYMBOLS 1) + set (H5_NO_DEPRECATED_SYMBOLS 1) endif (HDF5_ENABLE_DEPRECATED_SYMBOLS) #----------------------------------------------------------------------------- @@ -395,24 +413,6 @@ else (CMAKE_BUILD_TYPE MATCHES Debug) endif (CMAKE_BUILD_TYPE MATCHES Debug) #----------------------------------------------------------------------------- -# Compiler specific flags : Shouldn't there be compiler tests for these -#----------------------------------------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCC) - if (CMAKE_BUILD_TYPE MATCHES Debug) - set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99 -finline-functions -fno-common") - else (CMAKE_BUILD_TYPE MATCHES Debug) - set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99 -fomit-frame-pointer -finline-functions -fno-common") - endif (CMAKE_BUILD_TYPE MATCHES Debug) -endif (CMAKE_COMPILER_IS_GNUCC) -if (CMAKE_COMPILER_IS_GNUCXX) - if (CMAKE_BUILD_TYPE MATCHES Debug) - set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS} -finline-functions -fno-common") - else (CMAKE_BUILD_TYPE MATCHES Debug) - set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS} -fomit-frame-pointer -finline-functions -fno-common") - endif (CMAKE_BUILD_TYPE MATCHES Debug) -endif (CMAKE_COMPILER_IS_GNUCXX) - -#----------------------------------------------------------------------------- # Option to embed library info into executables #----------------------------------------------------------------------------- option (HDF5_ENABLE_EMBEDDED_LIBINFO "embed library info into executables" ON) @@ -420,214 +420,7 @@ if (HDF5_ENABLE_EMBEDDED_LIBINFO) set (H5_HAVE_EMBEDDED_LIBINFO 1) endif (HDF5_ENABLE_EMBEDDED_LIBINFO) -#----------------------------------------------------------------------------- -# Option to allow the user to disable compiler warnings -#----------------------------------------------------------------------------- -option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) -if (HDF5_DISABLE_COMPILER_WARNINGS) - # MSVC uses /w to suppress warnings. It also complains if another - # warning level is given, so remove it. - if (MSVC) - set (HDF5_WARNINGS_BLOCKED 1) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w") - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w") - endif (MSVC) - if (WIN32) - add_definitions (-D_CRT_SECURE_NO_WARNINGS) - endif (WIN32) - # Borland uses -w- to suppress warnings. - if (BORLAND) - set (HDF5_WARNINGS_BLOCKED 1) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") - endif (BORLAND) - - # Most compilers use -w to suppress warnings. - if (NOT HDF5_WARNINGS_BLOCKED) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - endif (NOT HDF5_WARNINGS_BLOCKED) -endif (HDF5_DISABLE_COMPILER_WARNINGS) - -#----------------------------------------------------------------------------- -# 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 (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline") - else (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=%none -DBSD_COMP") - endif (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") - # 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} -Wmissing-noreturn -Wpacked -Wdisabled-optimization") - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - set (H5_CFLAGS1 "${H5_CFLAGS1} -Wformat=2") - - # The "unreachable code" warning appears to be reliable now... - # (this warning was removed in gcc 4.5+) - #set (H5_CFLAGS "${H5_CFLAGS} -Wunreachable-code") - - # 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_CFLAGS2 "${H5_CFLAGS2} -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_CFLAGS3 "${H5_CFLAGS3} -Wunsafe-loop-optimizations -Wc++-compat") - - # Append more extra warning flags that only gcc 4.2+ know about - set (H5_CFLAGS3 "${H5_CFLAGS3} -Wstrict-overflow") - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - set (H5_CFLAGS3 "${H5_CFLAGS3} -Wlogical-op -Wlarger-than=2048 -Wvla") - - # Append more extra warning flags that only gcc 4.4+ know about - set (H5_CFLAGS4 "${H5_CFLAGS4} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat") - - # Append more extra warning flags that only gcc 4.5+ know about - set (H5_CFLAGS4 "${H5_CFLAGS4} -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants") - - # Append more extra warning flags that only gcc 4.6+ know about - set (H5_CFLAGS5 "${H5_CFLAGS5} -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines") - - # Append more extra warning flags that only gcc 4.7+ know about - set (H5_CFLAGS5 "${H5_CFLAGS5} -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn") -endif (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable all warnings -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) -if (HDF5_ENABLE_ALL_WARNINGS) - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall") - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") - else (MSVC) - if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}") - endif (CMAKE_COMPILER_IS_GNUCC) - endif (MSVC) -endif (HDF5_ENABLE_ALL_WARNINGS) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) -if (HDF5_ENABLE_GROUPZERO_WARNINGS) - 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W1") - else (MSVC) - if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic") - endif (CMAKE_COMPILER_IS_GNUCC) - endif (MSVC) -endif (HDF5_ENABLE_GROUPZERO_WARNINGS) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) -if (HDF5_ENABLE_GROUPONE_WARNINGS) - 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2") - else (MSVC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS1}") - endif (MSVC) -endif (HDF5_ENABLE_GROUPONE_WARNINGS) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) -if (HDF5_ENABLE_GROUPTWO_WARNINGS) - 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") - else (MSVC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS2}") - endif (MSVC) -endif (HDF5_ENABLE_GROUPTWO_WARNINGS) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) -if (HDF5_ENABLE_GROUPTHREE_WARNINGS) - 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") - else (MSVC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS3}") - endif (MSVC) -endif (HDF5_ENABLE_GROUPTHREE_WARNINGS) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) -if (HDF5_ENABLE_GROUPFOUR_WARNINGS) - if (NOT MSVC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS4}") - endif (NOT MSVC) -endif (HDF5_ENABLE_GROUPFOUR_WARNINGS) - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPFIVE_WARNINGS "Enable group five warnings" OFF) -if (HDF5_ENABLE_GROUPFIVE_WARNINGS) - if (NOT MSVC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS5}") - endif (NOT MSVC) -endif (HDF5_ENABLE_GROUPFIVE_WARNINGS) - -#----------------------------------------------------------------------------- -# This is in here to help some of the GCC based IDES like Eclipse -# and code blocks parse the compiler errors and warnings better. -#----------------------------------------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCC) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") -endif (CMAKE_COMPILER_IS_GNUCC) -if (CMAKE_COMPILER_IS_GNUCXX) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") -endif (CMAKE_COMPILER_IS_GNUCXX) +include (${HDF_RESOURCES_DIR}/HDFCompilerFlags.cmake) #----------------------------------------------------------------------------- # All libs/tests/examples need the main include directories @@ -694,7 +487,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) if (HDF5_ENABLE_Z_LIB_SUPPORT AND ZLIB_FOUND) PACKAGE_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) endif (HDF5_ENABLE_Z_LIB_SUPPORT AND ZLIB_FOUND) - + if (HDF5_ENABLE_SZIP_SUPPORT AND SZIP_FOUND) PACKAGE_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) endif (HDF5_ENABLE_SZIP_SUPPORT AND SZIP_FOUND) @@ -702,7 +495,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) endif (NOT HDF5_EXTERNALLY_CONFIGURED) #----------------------------------------------------------------------------- # Option to use threadsafe -# Note: Currently CMake only allows configuring of threadsafe on +# Note: Currently CMake only allows configuring of threadsafe on # non-Cygwin WINDOWS. #----------------------------------------------------------------------------- if (WIN32) @@ -777,7 +570,7 @@ if (BUILD_TESTING) option (HDF5_TEST_FHEAP_VFD "Execute tests with different VFDs" ON) mark_as_advanced (HDF5_TEST_FHEAP_VFD) endif (HDF5_TEST_VFD) - + include (${HDF5_SOURCE_DIR}/CTestConfig.cmake) configure_file (${HDF_RESOURCES_DIR}/CTestCustom.cmake ${HDF5_BINARY_DIR}/CTestCustom.ctest @ONLY) endif (BUILD_TESTING) @@ -869,7 +662,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") endif (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") #----------------------------------------------------------------------------- -# Check if Fortran's default real is double precision. If it is and HL is +# Check if Fortran's default real is double precision. If it is and HL is # being built then configure should fail due to bug HDFFV-889. #----------------------------------------------------------------------------- if (HDF5_BUILD_FORTRAN AND HDF5_BUILD_HL_LIB ) diff --git a/MANIFEST b/MANIFEST index e76620f..35b8077 100644 --- a/MANIFEST +++ b/MANIFEST @@ -13,7 +13,7 @@ # access to either file, you may request a copy from help@hdfgroup.org. # #------------------------------------------------------------------------------ -# This is the list of files that are part of HDF5 source distribution. +# This is the list of files that are part of HDF5 source distribution. # All files have a `./' prefix and appear in lexicographic order. # Lines that end with _DO_NOT_DISTRIBUTE_ will not be included in a # release. Blank lines and comments are ignored. Comments must start @@ -501,7 +501,7 @@ ./src/H5Bdbg.c ./src/H5Bpkg.h ./src/H5Bprivate.h -./src/H5Bpublic.h +./src/H5Bpublic.h ./src/H5B2.c ./src/H5B2cache.c ./src/H5B2dbg.c @@ -509,7 +509,7 @@ ./src/H5B2int.c ./src/H5B2pkg.h ./src/H5B2private.h -./src/H5B2public.h +./src/H5B2public.h ./src/H5B2stat.c ./src/H5B2test.c ./src/H5C.c @@ -639,7 +639,7 @@ ./src/H5HFman.c ./src/H5HFpkg.h ./src/H5HFprivate.h -./src/H5HFpublic.h +./src/H5HFpublic.h ./src/H5HFsection.c ./src/H5HFspace.c ./src/H5HFstat.c @@ -2261,6 +2261,7 @@ ./config/cmake/H5pubconf.h.in ./config/cmake/hdf5-config.cmake.in ./config/cmake/hdf5-config-version.cmake.in +./config/cmake/HDFCompilerFlags.cmake ./config/cmake/HDF5Macros.cmake ./config/cmake/libhdf5.settings.cmake.in ./config/cmake/mccacheinit.cmake diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake new file mode 100644 index 0000000..c637c73 --- /dev/null +++ b/config/cmake/HDFCompilerFlags.cmake @@ -0,0 +1,274 @@ +#----------------------------------------------------------------------------- +# Compiler specific flags : Shouldn't there be compiler tests for these +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_BUILD_TYPE MATCHES Debug) + set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99") + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") + endif () + else (CMAKE_BUILD_TYPE MATCHES Debug) + set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99") + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstdarg-opt") + endif () + endif (CMAKE_BUILD_TYPE MATCHES Debug) +endif (CMAKE_COMPILER_IS_GNUCC) +if (CMAKE_COMPILER_IS_GNUCXX) + if (CMAKE_BUILD_TYPE MATCHES Debug) + set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS} -std=c99") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common") + endif () + else (CMAKE_BUILD_TYPE MATCHES Debug) + set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS} -std=c99") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstdarg-opt") + endif () + endif (CMAKE_BUILD_TYPE MATCHES Debug) +endif (CMAKE_COMPILER_IS_GNUCXX) + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +option (HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF) +if (HDF5_DISABLE_COMPILER_WARNINGS) + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w") + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w") + endif (MSVC) + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif (WIN32) + # Borland uses -w- to suppress warnings. + if (BORLAND) + set (HDF5_WARNINGS_BLOCKED 1) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") + endif (BORLAND) + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + endif (NOT HDF5_WARNINGS_BLOCKED) +endif (HDF5_DISABLE_COMPILER_WARNINGS) + +#----------------------------------------------------------------------------- +# 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 (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline") + else (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=%none -DBSD_COMP") + endif (NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + # 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} -Wmissing-noreturn -Wpacked -Wdisabled-optimization") + + # Enable more format checking flags, beyond the basic -Wformat included + # in -Wall + set (H5_CFLAGS1 "${H5_CFLAGS1} -Wformat=2") + + # 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_CFLAGS1 "${H5_CFLAGS1} -Wunreachable-code") + endif() + + # 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_CFLAGS2 "${H5_CFLAGS2} -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_CFLAGS3 "${H5_CFLAGS3} -Wunsafe-loop-optimizations -Wc++-compat") + + # Append more extra warning flags that only gcc 4.2+ know about + set (H5_CFLAGS3 "${H5_CFLAGS3} -Wstrict-overflow") + + # Append more extra warning flags that only gcc 4.3+ know about + # + # Technically, variable-length arrays are part of the C99 standard, but + # we should approach them a bit cautiously... -QAK + set (H5_CFLAGS3 "${H5_CFLAGS3} -Wlogical-op -Wlarger-than=2048 -Wvla") + + # Append more extra warning flags that only gcc 4.4+ know about + set (H5_CFLAGS4 "${H5_CFLAGS4} -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_CFLAGS4 "${H5_CFLAGS4} -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants") + endif() + + # Append more extra warning flags that only gcc 4.6+ know about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + set (H5_CFLAGS5 "${H5_CFLAGS5} -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines") + 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_CFLAGS5 "${H5_CFLAGS5} -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn") + endif() + + # Append more extra warning flags that only gcc 4.8+ know about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) + set (H5_CFLAGS5 "${H5_CFLAGS5} -Wsuggest-attribute=format") + endif() + + # Append more extra warning flags that only gcc 4.9+ know about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) + set (H5_CFLAGS5 "${H5_CFLAGS5} -Wdate-time -Wopenmp-simd") + 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_CFLAGS6 "${H5_CFLAGS6} -Warray-bounds=2 -Wc99-c11-compat") + endif() + +endif (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable all warnings +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) +if (HDF5_ENABLE_ALL_WARNINGS) + if (MSVC) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall") + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") + else (MSVC) + if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}") + endif (CMAKE_COMPILER_IS_GNUCC) + endif (MSVC) +endif (HDF5_ENABLE_ALL_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) +if (HDF5_ENABLE_GROUPZERO_WARNINGS) + 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W1") + else (MSVC) + if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic") + endif (CMAKE_COMPILER_IS_GNUCC) + endif (MSVC) +endif (HDF5_ENABLE_GROUPZERO_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) +if (HDF5_ENABLE_GROUPONE_WARNINGS) + 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2") + else (MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS1}") + endif (MSVC) +endif (HDF5_ENABLE_GROUPONE_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) +if (HDF5_ENABLE_GROUPTWO_WARNINGS) + 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") + else (MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS2}") + endif (MSVC) +endif (HDF5_ENABLE_GROUPTWO_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) +if (HDF5_ENABLE_GROUPTHREE_WARNINGS) + 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]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + else (MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS3}") + endif (MSVC) +endif (HDF5_ENABLE_GROUPTHREE_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) +if (HDF5_ENABLE_GROUPFOUR_WARNINGS) + if (NOT MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS4}") + endif (NOT MSVC) +endif (HDF5_ENABLE_GROUPFOUR_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPFIVE_WARNINGS "Enable group five warnings" OFF) +if (HDF5_ENABLE_GROUPFIVE_WARNINGS) + if (NOT MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS5}") + endif (NOT MSVC) +endif (HDF5_ENABLE_GROUPFIVE_WARNINGS) + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_GROUPSIX_WARNINGS "Enable group six warnings" OFF) +if (HDF5_ENABLE_GROUPSIX_WARNINGS) + if (NOT MSVC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS6}") + endif (NOT MSVC) +endif (HDF5_ENABLE_GROUPSIX_WARNINGS) + +#----------------------------------------------------------------------------- +# This is in here to help some of the GCC based IDES like Eclipse +# and code blocks parse the compiler errors and warnings better. +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") +endif (CMAKE_COMPILER_IS_GNUCC) +if (CMAKE_COMPILER_IS_GNUCXX) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") +endif (CMAKE_COMPILER_IS_GNUCXX) -- cgit v0.12