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
This commit is contained in:
Brad King
2023-10-17 14:18:47 +00:00
committed by Kitware Robot
12 changed files with 89 additions and 7 deletions
+14
View File
@@ -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) {