|
|
@@ -940,6 +940,37 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkStatement(
|
|
|
this->WriteNvidiaDeviceLinkRule(usedResponseFile, config);
|
|
|
}
|
|
|
|
|
|
+/// Get the target property if it exists, or return a default
|
|
|
+static std::string GetTargetPropertyOrDefault(cmGeneratorTarget const* target,
|
|
|
+ std::string const& property,
|
|
|
+ std::string defaultValue)
|
|
|
+{
|
|
|
+ if (cmValue name = target->GetProperty(property)) {
|
|
|
+ return *name;
|
|
|
+ }
|
|
|
+ return defaultValue;
|
|
|
+}
|
|
|
+
|
|
|
+/// Compute the swift module name for target
|
|
|
+static std::string GetSwiftModuleName(cmGeneratorTarget const* target)
|
|
|
+{
|
|
|
+ return GetTargetPropertyOrDefault(target, "Swift_MODULE_NAME",
|
|
|
+ target->GetName());
|
|
|
+}
|
|
|
+
|
|
|
+/// Compute the swift module path for the target
|
|
|
+/// The returned path will need to be converted to the generator path
|
|
|
+static std::string GetSwiftModulePath(cmGeneratorTarget const* target)
|
|
|
+{
|
|
|
+ std::string moduleName = GetSwiftModuleName(target);
|
|
|
+ std::string moduleDirectory = GetTargetPropertyOrDefault(
|
|
|
+ target, "Swift_MODULE_DIRECTORY",
|
|
|
+ target->LocalGenerator->GetCurrentBinaryDirectory());
|
|
|
+ std::string moduleFileName = GetTargetPropertyOrDefault(
|
|
|
+ target, "Swift_MODULE", moduleName + ".swiftmodule");
|
|
|
+ return moduleDirectory + "/" + moduleFileName;
|
|
|
+}
|
|
|
+
|
|
|
void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
|
|
const std::string& config, const std::string& fileConfig,
|
|
|
bool firstForConfig)
|
|
|
@@ -1038,31 +1069,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
|
|
return targetNames.Base;
|
|
|
}();
|
|
|
|
|
|
- vars["SWIFT_MODULE_NAME"] = [gt]() -> std::string {
|
|
|
- if (cmValue name = gt->GetProperty("Swift_MODULE_NAME")) {
|
|
|
- return *name;
|
|
|
- }
|
|
|
- return gt->GetName();
|
|
|
- }();
|
|
|
-
|
|
|
- vars["SWIFT_MODULE"] = [this](const std::string& module) -> std::string {
|
|
|
- std::string directory =
|
|
|
- this->GetLocalGenerator()->GetCurrentBinaryDirectory();
|
|
|
- if (cmValue prop = this->GetGeneratorTarget()->GetProperty(
|
|
|
- "Swift_MODULE_DIRECTORY")) {
|
|
|
- directory = *prop;
|
|
|
- }
|
|
|
-
|
|
|
- std::string name = module + ".swiftmodule";
|
|
|
- if (cmValue prop =
|
|
|
- this->GetGeneratorTarget()->GetProperty("Swift_MODULE")) {
|
|
|
- name = *prop;
|
|
|
- }
|
|
|
-
|
|
|
- return this->GetLocalGenerator()->ConvertToOutputFormat(
|
|
|
- this->ConvertToNinjaPath(directory + "/" + name),
|
|
|
- cmOutputConverter::SHELL);
|
|
|
- }(vars["SWIFT_MODULE_NAME"]);
|
|
|
+ vars["SWIFT_MODULE_NAME"] = GetSwiftModuleName(gt);
|
|
|
+ vars["SWIFT_MODULE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
|
|
+ this->ConvertToNinjaPath(GetSwiftModulePath(gt)),
|
|
|
+ cmOutputConverter::SHELL);
|
|
|
|
|
|
vars["SWIFT_SOURCES"] = [this, config]() -> std::string {
|
|
|
std::vector<cmSourceFile const*> sources;
|