diff options
author | Craig Scott <craig.scott@crascit.com> | 2022-04-09 21:44:50 +1000 |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2022-04-09 21:51:09 +1000 |
commit | a10fc754a6a12c681f3acc7efa84798f6c2ea799 (patch) | |
tree | d0b61816e25a08037bdcfd65a585a7e89a331a44 /Source | |
parent | c6ee02fc8db2b2881d6f314a37f193c8726b55ba (diff) | |
download | cmake-a10fc754a6a12c681f3acc7efa84798f6c2ea799.tar.gz |
CheckSourceCompiles: Avoid linker warning with -fembed-bitcode
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
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 84fa897795..324ce87c2e 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -831,6 +831,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, ? "NEW" : "OLD"); + // Workaround for -Wl,-headerpad_max_install_names issue until we can avoid + // adding that flag in the platform and compiler language files + fprintf(fout, + "include(\"${CMAKE_ROOT}/Modules/Internal/" + "HeaderpadWorkaround.cmake\")\n"); + if (targetType == cmStateEnums::EXECUTABLE) { /* Put the executable at a known location (for COPY_FILE). */ fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", |