summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-04-09 11:44:50 (GMT)
committerCraig Scott <craig.scott@crascit.com>2022-04-09 11:51:09 (GMT)
commita10fc754a6a12c681f3acc7efa84798f6c2ea799 (patch)
treed0b61816e25a08037bdcfd65a585a7e89a331a44 /Source/cmCoreTryCompile.cxx
parentc6ee02fc8db2b2881d6f314a37f193c8726b55ba (diff)
downloadCMake-a10fc754a6a12c681f3acc7efa84798f6c2ea799.zip
CMake-a10fc754a6a12c681f3acc7efa84798f6c2ea799.tar.gz
CMake-a10fc754a6a12c681f3acc7efa84798f6c2ea799.tar.bz2
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/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 84fa897..324ce87 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",