From dd0c9feb54b1194751eea192769e9c3d75832978 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 22 Mar 2025 16:02:28 +0100 Subject: [PATCH] cmake: replace CMAKE_COMPILER_IS_GNUCC with CMAKE_C_COMPILER_ID Variable `CMAKE_COMPILER_IS_GNUCC` is deprecated and `CMAKE_C_COMPILER_ID` should be used instead. Closes #16797 --- CMake/CurlSymbolHiding.cmake | 2 +- CMake/PickyWarnings.cmake | 8 ++++---- CMake/win32-cache.cmake | 2 +- CMakeLists.txt | 6 +++--- tests/CMakeLists.txt | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMake/CurlSymbolHiding.cmake b/CMake/CurlSymbolHiding.cmake index b962cf0e6c..48ef193b9a 100644 --- a/CMake/CurlSymbolHiding.cmake +++ b/CMake/CurlSymbolHiding.cmake @@ -42,7 +42,7 @@ if(CURL_HIDDEN_SYMBOLS) set(CURL_HIDES_PRIVATE_SYMBOLS TRUE) set(CURL_EXTERN_SYMBOL "__attribute__((__visibility__(\"default\")))") set(CURL_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") - elseif(CMAKE_COMPILER_IS_GNUCC) + elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) # Note: This is considered buggy prior to 4.0 but the autotools do not care, so let us ignore that fact set(CURL_HIDES_PRIVATE_SYMBOLS TRUE) diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index 3a17a98dc5..4f04ed1330 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -26,7 +26,7 @@ include(CheckCCompilerFlag) set(_picky "") if(CURL_WERROR AND - ((CMAKE_COMPILER_IS_GNUCC AND + ((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT DOS AND # Watt-32 headers use the '#include_next' GCC extension NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0 AND NOT CMAKE_VERSION VERSION_LESS 3.23.0) OR # to avoid check_symbol_exists() conflicting with GCC -pedantic-errors @@ -40,7 +40,7 @@ if(APPLE AND list(APPEND _picky "-Werror=partial-availability") # clang 3.6 appleclang 6.3 endif() -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") list(APPEND _picky "-Werror-implicit-function-declaration") # clang 1.0 gcc 2.95 endif() @@ -54,7 +54,7 @@ elseif(BORLAND) endif() if(PICKY_COMPILER) - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") # https://clang.llvm.org/docs/DiagnosticsReference.html # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html @@ -254,7 +254,7 @@ if(PICKY_COMPILER) endif() endforeach() - if(CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_C_COMPILER_ID STREQUAL "GNU") if(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5) # Avoid false positives list(APPEND _picky "-Wno-shadow") diff --git a/CMake/win32-cache.cmake b/CMake/win32-cache.cmake index 615db9e49c..ee2d9f9d3b 100644 --- a/CMake/win32-cache.cmake +++ b/CMake/win32-cache.cmake @@ -75,7 +75,7 @@ else() endif() endif() -if((CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) OR +if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6)) # MinGW or clang-cl set(HAVE_STDATOMIC_H 1) diff --git a/CMakeLists.txt b/CMakeLists.txt index f19467a8cc..fcbd3426c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ if(WINDOWS_STORE AND MINGW) # mingw UWP build # CMake (as of v3.31.2) gets confused and applies the MSVC rc.exe command-line # template to windres. Reset it to the windres template via 'Modules/Platform/Windows-windres.cmake': set(CMAKE_RC_COMPILE_OBJECT " -O coff ") -elseif(WIN32 AND WINCE AND CMAKE_COMPILER_IS_GNUCC) # mingw32ce build +elseif(WIN32 AND WINCE AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # mingw32ce build if(NOT MINGW32CE_LIBRARY_DIR) message(FATAL_ERROR "Set MINGW32CE_LIBRARY_DIR variable to the mingw32ce platform library directory.") endif() @@ -118,7 +118,7 @@ elseif(WIN32 AND WINCE AND CMAKE_COMPILER_IS_GNUCC) # mingw32ce build set(CMAKE_IMPORT_LIBRARY_SUFFIX ".dll.a") set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") -elseif(DOS AND CMAKE_COMPILER_IS_GNUCC) # DJGPP +elseif(DOS AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # DJGPP set(CMAKE_STATIC_LIBRARY_PREFIX "lib") set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") set(CMAKE_FIND_LIBRARY_PREFIXES "lib") @@ -161,7 +161,7 @@ endif() if(AMIGA) string(APPEND _target_flags " AMIGA") endif() -if(CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") string(APPEND _target_flags " GCC") endif() if(MINGW) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b03fd53216..295750c85b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -79,7 +79,7 @@ function(curl_add_pytests _targetname _test_flags) endfunction() # Create configurehelp.pm, used by tests needing to run the C preprocessor. -if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") +if(MSVC OR CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E") if(APPLE AND CMAKE_OSX_SYSROOT) string(APPEND CURL_CPP " -isysroot ${CMAKE_OSX_SYSROOT}") -- 2.47.2