Skip to content

Commit

Permalink
replace deprecated CMAKE_COMPILER_IS_GNU** (HDFGroup#4272)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF authored Mar 28, 2024
1 parent 8787e7f commit 1dfaef2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
12 changes: 6 additions & 6 deletions HDF5Examples/config/cmake/HDFExampleMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ macro (BASIC_SETTINGS varname)
#-----------------------------------------------------------------------------
# Compiler specific flags : Shouldn't there be compiler tests for these
#-----------------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCC)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
endif ()
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}")
endif ()

#-----------------------------------------------------------------------------
# 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)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
endif ()
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
endif ()

Expand All @@ -74,7 +74,7 @@ macro (BASIC_SETTINGS varname)
set (HDF_WARNINGS_BLOCKED 1)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w")
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
endif ()
Expand All @@ -91,7 +91,7 @@ macro (BASIC_SETTINGS varname)
# Most compilers use -w to suppress warnings.
if (NOT HDF_WARNINGS_BLOCKED)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
endif ()
endif ()
Expand Down
6 changes: 3 additions & 3 deletions config/cmake/HDFCXXCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC" AND CMAKE_CXX_COMPILER_LOADED)
endif ()
endif ()

if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}")
if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
Expand Down Expand Up @@ -143,7 +143,7 @@ else ()
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_LOADED
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8)
# add the general CXX flags for g++ compiler versions 4.8 and above.
ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general")
Expand Down Expand Up @@ -311,7 +311,7 @@ endif ()
# 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_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
endif ()

Expand Down
4 changes: 2 additions & 2 deletions config/cmake/HDFCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if (CMAKE_C_COMPILER_ID STREQUAL "NVHPC" )
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${cmake_c_flags_relwithdebinfo_edited}")
endif ()

if (CMAKE_COMPILER_IS_GNUCC)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer")
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
Expand Down Expand Up @@ -405,7 +405,7 @@ endif ()
# 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)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
endif ()

Expand Down
2 changes: 1 addition & 1 deletion config/cmake/LIBAEC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ endif ()
# 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)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
endif ()

Expand Down
6 changes: 3 additions & 3 deletions config/cmake/ZLIB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ endif ()
#-----------------------------------------------------------------------------
# Compiler specific flags : Shouldn't there be compiler tests for these
#-----------------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCC)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -Wno-strict-prototypes")
endif ()
if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
Expand All @@ -139,7 +139,7 @@ endif ()
# 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)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
endif ()

Expand Down Expand Up @@ -196,7 +196,7 @@ if(NOT MINGW)
)
endif()

if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S)
elseif (AMD64)
Expand Down
15 changes: 15 additions & 0 deletions config/sanitizer/sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ if(USE_SANITIZER)
if(UNIX)
append("-fno-omit-frame-pointer" CMAKE_C_FLAGS)
message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}")
if (CMAKE_CXX_COMPILER_LOADED)
append("-fno-omit-frame-pointer" CMAKE_CXX_FLAGS)
endif ()

if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
append("-O1" CMAKE_C_FLAGS)
if (CMAKE_CXX_COMPILER_LOADED)
append("-O1" CMAKE_CXX_FLAGS)
endif ()
endif()

if(USE_SANITIZER MATCHES "([Aa]ddress)")
Expand Down Expand Up @@ -176,13 +182,19 @@ if(USE_SANITIZER)
if(SANITIZER_SELECTED_COMPATIBLE)
message(STATUS " Building with ${SANITIZER_SELECTED_FLAGS}")
append("${SANITIZER_SELECTED_FLAGS}" CMAKE_C_FLAGS)
if (CMAKE_CXX_COMPILER_LOADED)
append("${SANITIZER_SELECTED_FLAGS}" CMAKE_CXX_FLAGS)
endif ()
else()
message(FATAL_ERROR "Unsupported value of USE_SANITIZER: ${USE_SANITIZER}")
endif()
elseif(MSVC)
if(USE_SANITIZER MATCHES "([Aa]ddress)")
message(STATUS "Building with Address sanitizer")
append("-fsanitize=address" CMAKE_C_FLAGS)
if (CMAKE_CXX_COMPILER_LOADED)
append("-fsanitize=address" CMAKE_CXX_FLAGS)
endif ()

if(AFL)
append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER)
Expand All @@ -197,6 +209,9 @@ if(USE_SANITIZER)
if(USE_SANITIZER MATCHES "([Aa]ddress)")
message(STATUS "Building with Address sanitizer")
append("/fsanitize=address" CMAKE_C_FLAGS)
if (CMAKE_CXX_COMPILER_LOADED)
append("/fsanitize=address" CMAKE_CXX_FLAGS)
endif ()
else()
message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}")
endif()
Expand Down

0 comments on commit 1dfaef2

Please sign in to comment.