mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Swift: Factor out Swift-specific target flags
Swift started the trend of piling language-specific target flags in `cmLocalGenerator::AddLanguageFlags`. Other languages have added their own under language-specific `Add<Lang>TargetFlags`. I'm refactoring where Swift piles on its language-specific target flags to match the pattern other languages are using.
This commit is contained in:
@@ -2810,6 +2810,18 @@ void cmGeneratorTarget::AddRustTargetFlags(std::string& flags) const
|
||||
}
|
||||
}
|
||||
|
||||
void cmGeneratorTarget::AddSwiftTargetFlags(std::string& flags) const
|
||||
{
|
||||
if (cmValue version = GetProperty("Swift_LANGUAGE_VERSION")) {
|
||||
if (cmSystemTools::VersionCompare(
|
||||
cmSystemTools::OP_GREATER_EQUAL,
|
||||
this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"),
|
||||
"4.2")) {
|
||||
flags += " -swift-version " + *version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmGeneratorTarget::AddCUDAToolkitFlags(std::string& flags) const
|
||||
{
|
||||
std::string const& compiler =
|
||||
|
||||
@@ -628,6 +628,8 @@ public:
|
||||
|
||||
void AddRustTargetFlags(std::string& flags) const;
|
||||
|
||||
void AddSwiftTargetFlags(std::string& flags) const;
|
||||
|
||||
std::string GetFeatureSpecificLinkRuleVariable(
|
||||
std::string const& var, std::string const& lang,
|
||||
std::string const& config) const;
|
||||
|
||||
@@ -2115,14 +2115,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
||||
(compilerId == "OpenWatcom" || compilerSimulateId == "OpenWatcom");
|
||||
|
||||
if (lang == "Swift") {
|
||||
if (cmValue v = target->GetProperty("Swift_LANGUAGE_VERSION")) {
|
||||
if (cmSystemTools::VersionCompare(
|
||||
cmSystemTools::OP_GREATER_EQUAL,
|
||||
this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"),
|
||||
"4.2")) {
|
||||
this->AppendFlags(flags, "-swift-version " + *v);
|
||||
}
|
||||
}
|
||||
target->AddSwiftTargetFlags(flags);
|
||||
} else if (lang == "CUDA") {
|
||||
target->AddCUDAArchitectureFlags(compileOrLink, config, flags);
|
||||
target->AddCUDAToolkitFlags(flags);
|
||||
|
||||
Reference in New Issue
Block a user