summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-10-17 14:18:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-10-17 14:18:56 (GMT)
commitc672e51bd375b3fca4a22eef00ad6bcb8d4b1a10 (patch)
tree45b3ac6c9bdd8ff409867c390046652348de3c29 /Source/cmCoreTryCompile.cxx
parentbb9a91c500c6c8ce57e57cef5b4c0fdac9b03e43 (diff)
parent0f37000304fc2cbf3945a2a2be9f969be3eef62d (diff)
downloadCMake-c672e51bd375b3fca4a22eef00ad6bcb8d4b1a10.zip
CMake-c672e51bd375b3fca4a22eef00ad6bcb8d4b1a10.tar.gz
CMake-c672e51bd375b3fca4a22eef00ad6bcb8d4b1a10.tar.bz2
Merge topic 'try_compile-linker-language'
0f37000304 try_{compile,run}: add LINKER_LANGUAGE option dc0dbffb0f Tests: Remove redundant policy setting from RunCMake.try_{compile,run} cases Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !8871
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 69d5ffc..3596d47 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -178,6 +178,7 @@ auto const TryCompileBaseSourcesArgParser =
ArgumentParser::ExpectAtLeast{ 0 })
.Bind("LINK_LIBRARIES"_s, &Arguments::LinkLibraries)
.Bind("LINK_OPTIONS"_s, &Arguments::LinkOptions)
+ .Bind("LINKER_LANGUAGE"_s, &Arguments::LinkerLanguage)
.Bind("COPY_FILE"_s, &Arguments::CopyFileTo)
.Bind("COPY_FILE_ERROR"_s, &Arguments::CopyFileError)
.BIND_LANG_PROPS(C)
@@ -1045,6 +1046,19 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
}
}
+ if (arguments.LinkerLanguage) {
+ std::string LinkerLanguage = *arguments.LinkerLanguage;
+ if (testLangs.find(LinkerLanguage) == testLangs.end()) {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "Linker language '" + LinkerLanguage +
+ "' must be enabled in project(LANGUAGES).");
+ }
+
+ fprintf(fout, "set_property(TARGET %s PROPERTY LINKER_LANGUAGE %s)\n",
+ targetName.c_str(), LinkerLanguage.c_str());
+ }
+
if (arguments.LinkLibraries) {
std::string libsToLink = " ";
for (std::string const& i : *arguments.LinkLibraries) {