aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/ninja/Ninja.cpp26
-rw-r--r--src/CmakeModule.cpp19
2 files changed, 24 insertions, 21 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 45fb9cb..ec6a237 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -428,26 +428,24 @@ namespace backend
allLinkerFlags += " ";
allLinkerFlags += binaryDependency;
}
+
+ vector<string> linkerFlags;
- string staticLinkerFlags;
auto parentProjStaticLinkerFlagCallbackFunc = staticLinkerFlagCallbackFunc;
if (!staticLinkerFlagCallbackFunc || libraryType == LibraryType::DYNAMIC)
{
- staticLinkerFlagCallbackFunc = [&staticLinkerFlags](const string &linkerFlag)
+ staticLinkerFlagCallbackFunc = [&linkerFlags](const string &linkerFlag)
{
- staticLinkerFlags += " ";
- staticLinkerFlags += linkerFlag;
+ linkerFlags.push_back(linkerFlag);
};
}
- string dynamicLinkerFlags;
auto parentProjDynamicLinkerFlagCallbackFunc = dynamicLinkerFlagCallback;
if(!dynamicLinkerFlagCallback || libraryType != LibraryType::STATIC)
{
- dynamicLinkerFlagCallback = [&dynamicLinkerFlags](const string &linkerFlag)
+ dynamicLinkerFlagCallback = [&linkerFlags](const string &linkerFlag)
{
- dynamicLinkerFlags += " ";
- dynamicLinkerFlags += linkerFlag;
+ linkerFlags.push_back(linkerFlag);
};
}
@@ -462,11 +460,15 @@ namespace backend
if(!buildSubProjectResult)
return buildSubProjectResult;
- Result<bool> linkerFlags = getLinkerFlags(config, staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallback, globalIncludeDirCallback, cflagsCallbackFunc);
- if (linkerFlags.isErr())
- return Result<bool>::Err(linkerFlags.getErrMsg());
+ Result<bool> linkerFlagsResult = getLinkerFlags(config, staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallback, globalIncludeDirCallback, cflagsCallbackFunc);
+ if (linkerFlagsResult.isErr())
+ return Result<bool>::Err(linkerFlagsResult.getErrMsg());
- allLinkerFlags += staticLinkerFlags + dynamicLinkerFlags;
+ for(vector<string>::reverse_iterator it = linkerFlags.rbegin(), end = linkerFlags.rend(); it != end; ++it)
+ {
+ allLinkerFlags += " ";
+ allLinkerFlags += *it;
+ }
result += dependencyExportIncludeDirs;
result += "\n\n";
diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp
index 27047ba..cdc03eb 100644
--- a/src/CmakeModule.cpp
+++ b/src/CmakeModule.cpp
@@ -42,26 +42,23 @@ namespace sibs
}
#endif
- string staticLinkerFlags;
+ vector<string> linkerFlags;
auto parentProjStaticLinkerFlagCallbackFunc = staticLinkerFlagCallbackFunc;
if (!staticLinkerFlagCallbackFunc || (config.getPackageType() == PackageType::DYNAMIC || config.getPackageType() == PackageType::LIBRARY))
{
- staticLinkerFlagCallbackFunc = [&staticLinkerFlags](const string &linkerFlag)
+ staticLinkerFlagCallbackFunc = [&linkerFlags](const string &linkerFlag)
{
- staticLinkerFlags += " ";
- staticLinkerFlags += linkerFlag;
+ linkerFlags.push_back(linkerFlag);
};
}
- string dynamicLinkerFlags;
auto parentProjDynamicLinkerFlagCallbackFunc = dynamicLinkerFlagCallbackFunc;
// TODO: If project contains no source files, then we shouldn't override this function... why?
if(!dynamicLinkerFlagCallbackFunc || config.getPackageType() != PackageType::STATIC)
{
- dynamicLinkerFlagCallbackFunc = [&dynamicLinkerFlags](const string &linkerFlag)
+ dynamicLinkerFlagCallbackFunc = [&linkerFlags](const string &linkerFlag)
{
- dynamicLinkerFlags += " ";
- dynamicLinkerFlags += linkerFlag;
+ linkerFlags.push_back(linkerFlag);
};
}
@@ -114,7 +111,11 @@ namespace sibs
if(!globalLibResult)
return globalLibResult;
- allLinkerFlags += staticLinkerFlags + dynamicLinkerFlags;
+ for(vector<string>::reverse_iterator it = linkerFlags.rbegin(), end = linkerFlags.rend(); it != end; ++it)
+ {
+ allLinkerFlags += " ";
+ allLinkerFlags += *it;
+ }
Result<bool> createBuildDirResult = createDirectoryRecursive(buildPath.c_str());
if (createBuildDirResult.isErr())