summaryrefslogtreecommitdiffstats
path: root/Modules/Internal
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-13 19:52:14 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-13 20:18:50 (GMT)
commit97fcd3bd300b19d6ee4b2682fd7c5630c6a1e814 (patch)
tree04d8e2b7f565942ce8191602c06b16b0b3ab8442 /Modules/Internal
parentbd74679ab56baa14eedc95958f3ed95466b624bd (diff)
downloadCMake-97fcd3bd300b19d6ee4b2682fd7c5630c6a1e814.zip
CMake-97fcd3bd300b19d6ee4b2682fd7c5630c6a1e814.tar.gz
CMake-97fcd3bd300b19d6ee4b2682fd7c5630c6a1e814.tar.bz2
CheckCompilerFlag: Revert 'Match the Clang "argument unused" output ...'
Revert commit 5b45a3d0ce (CheckCompilerFlag: Match the Clang "argument unused" output for all languages, 2023-01-23, v3.26.0-rc1~38^2). It broke existing projects that were silently tolerating unrelated unused arguments in their checks for C and CXX. For example, using `CFLAGS=-nostdinc` or `CXXFLAGS=-nostdinc++` causes those flags to be used when driving the linker as well, and Clang warns they are unused in that case. Add a test case covering the now-restored behavior. Fixes: #24591
Diffstat (limited to 'Modules/Internal')
-rw-r--r--Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake1
-rw-r--r--Modules/Internal/CheckFlagCommonConfig.cmake10
2 files changed, 8 insertions, 3 deletions
diff --git a/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake b/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake
index ff8908b..b671b4a 100644
--- a/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake
+++ b/Modules/Internal/CMakeTryCompilerOrLinkerFlag.cmake
@@ -69,6 +69,7 @@ function(CMAKE_TRY_COMPILER_OR_LINKER_FLAG lang flag result)
set (CCCF_COMMAND_PATTERN "<FLAG> -o <OUTPUT> <SOURCE>")
endif()
+ list (APPEND CCCF_FAIL_REGEX "argument unused during compilation") # clang
if (check_lang STREQUAL "C")
list(APPEND CCCF_FAIL_REGEX
"command line option .* is valid for .* but not for C") # GNU
diff --git a/Modules/Internal/CheckFlagCommonConfig.cmake b/Modules/Internal/CheckFlagCommonConfig.cmake
index 61eada2..f8481cd 100644
--- a/Modules/Internal/CheckFlagCommonConfig.cmake
+++ b/Modules/Internal/CheckFlagCommonConfig.cmake
@@ -22,26 +22,30 @@ macro(CMAKE_CHECK_FLAG_COMMON_INIT _FUNC _LANG _SRC _PATTERNS)
FAIL_REGEX "-Werror=.* argument .* is not valid for C\\+\\+")
elseif("${_LANG}" STREQUAL "CUDA")
set(${_SRC} "__host__ int main() { return 0; }")
- set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+") # Host GNU
+ set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+" # Host GNU
+ FAIL_REGEX "argument unused during compilation: .*") # Clang
elseif("${_LANG}" STREQUAL "Fortran")
set(${_SRC} " program test\n stop\n end program")
set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for Fortran")
elseif("${_LANG}" STREQUAL "HIP")
set(${_SRC} "__host__ int main() { return 0; }")
+ set(${_PATTERNS} FAIL_REGEX "argument unused during compilation: .*") # Clang
elseif("${_LANG}" STREQUAL "OBJC")
set(${_SRC} [=[
#ifndef __OBJC__
# error "Not an Objective-C compiler"
#endif
int main(void) { return 0; }]=])
- set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C") # GNU
+ set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C" # GNU
+ FAIL_REGEX "argument unused during compilation: .*") # Clang
elseif("${_LANG}" STREQUAL "OBJCXX")
set(${_SRC} [=[
#ifndef __OBJC__
# error "Not an Objective-C++ compiler"
#endif
int main(void) { return 0; }]=])
- set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+") # GNU
+ set(${_PATTERNS} FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+" # GNU
+ FAIL_REGEX "argument unused during compilation: .*") # Clang
elseif("${_LANG}" STREQUAL "ISPC")
set(${_SRC} "float func(uniform int32, float a) { return a / 2.25; }")
elseif("${_LANG}" STREQUAL "Swift")