summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-22 12:55:49 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-04-22 12:55:56 (GMT)
commitddefed68e52e08452e5e014524b9bff26804cafe (patch)
tree822c7fc391ece0d862047af9dc92181deec27ab5 /Modules
parent32eba762bef091c74c1fe9c7e0b1e504ab71824f (diff)
parent4941887d7defecb3016d2bd94d3a45754251ca56 (diff)
downloadCMake-ddefed68e52e08452e5e014524b9bff26804cafe.zip
CMake-ddefed68e52e08452e5e014524b9bff26804cafe.tar.gz
CMake-ddefed68e52e08452e5e014524b9bff26804cafe.tar.bz2
Merge topic 'CheckCompilerFlags-revert-linker-warnings' into release-3.23
4941887d7d CheckCompilerFlags: Revert "Catch linker warning about ignored flags" c2341ece47 CheckLinkerFlag: Catch linker warning when the checked flag is ignored Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !7190
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeCheckCompilerFlagCommonPatterns.cmake1
-rw-r--r--Modules/Internal/CheckLinkerFlag.cmake9
2 files changed, 9 insertions, 1 deletions
diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
index 8f59acd..bda1d71 100644
--- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
+++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
@@ -13,7 +13,6 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR)
FAIL_REGEX "unknown .*option" # Clang
FAIL_REGEX "optimization flag .* not supported" # Clang
FAIL_REGEX "unknown argument ignored" # Clang (cl)
- FAIL_REGEX "warning: .* ignored" # Clang (linker)
FAIL_REGEX "ignoring unknown option" # MSVC, Intel
FAIL_REGEX "warning D9002" # MSVC, any lang
FAIL_REGEX "option.*not supported" # Intel
diff --git a/Modules/Internal/CheckLinkerFlag.cmake b/Modules/Internal/CheckLinkerFlag.cmake
index 51d4225..7613105 100644
--- a/Modules/Internal/CheckLinkerFlag.cmake
+++ b/Modules/Internal/CheckLinkerFlag.cmake
@@ -25,6 +25,15 @@ function(CMAKE_CHECK_LINKER_FLAG _lang _flag _var)
set(CMAKE_REQUIRED_LINK_OPTIONS "${_flag}")
check_compiler_flag_common_patterns(_common_patterns)
+
+ # Match linker warnings if the exact flag is ignored.
+ foreach(flag IN LISTS _flag)
+ string(REGEX REPLACE "([][+.*?()^$])" [[\\\1]] _flag_regex "${flag}")
+ list(APPEND _common_patterns
+ FAIL_REGEX "warning: .*${_flag_regex}.* ignored"
+ )
+ endforeach()
+
cmake_check_source_compiles(${_lang}
"${_lang_src}"
${_var}