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
This commit is contained in:
Brad King
2022-04-22 12:55:49 +00:00
committed by Kitware Robot
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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}