mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
When the Apple linker sees -headerpad_max_install_names and
bitcode is enabled with a flag like -fembed-bitcode, it issues a warning
and ignores the -headerpad_max_install_names flag. This causes
unrelated compiler and linker flag checks to fail for valid flags.
In f745e0497e (CheckCompilerFlags: Catch linker warning about ignored
flags, 2022-01-03), we started detecting linker warnings, which caused
a regression for projects that were setting -fembed-bitcode in their
CMAKE_CXX_FLAGS or similar. Prevent that regression by removing
the -headerpad_max_install_names linker flag when we know it will
warn and be ignored anyway.
Fixes: #23390
Issue: #23408
19 lines
625 B
CMake
19 lines
625 B
CMake
enable_language(C)
|
|
|
|
include(CheckCompilerFlag)
|
|
|
|
# Confirm we can check the conflicting flag directly. This should pass with
|
|
# or without the workaround.
|
|
check_compiler_flag(C "-fembed-bitcode" result1)
|
|
if(NOT result1)
|
|
message(FATAL_ERROR "False negative when -fembed-bitcode tested directly")
|
|
endif()
|
|
|
|
# Check conflicting flag set by user or project won't cause a false negative
|
|
# when testing a valid flag. This only passes with the workaround.
|
|
set(CMAKE_C_FLAGS -fembed-bitcode)
|
|
check_compiler_flag(C "-O" result2)
|
|
if(NOT result2)
|
|
message(FATAL_ERROR "False negative when -fembed-bitcode set in CMAKE_C_FLAGS")
|
|
endif()
|