summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx59
1 files changed, 42 insertions, 17 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index f5c62f8..45eb113 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1777,10 +1777,18 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
const std::string& lang,
const std::string& config)
{
- // Only add macOS specific flags on Darwin platforms (macOS and iOS):
+ // Only add Apple specific flags on Apple platforms
if (this->Makefile->IsOn("APPLE") && this->EmitUniversalBinaryFlags) {
std::vector<std::string> archs;
target->GetAppleArchs(config, archs);
+ if (!archs.empty() && !lang.empty() &&
+ (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) {
+ for (std::string const& arch : archs) {
+ flags += " -arch ";
+ flags += arch;
+ }
+ }
+
const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
if (sysroot && sysroot[0] == '/' && !sysroot[1]) {
sysroot = nullptr;
@@ -1788,27 +1796,37 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
std::string sysrootFlagVar =
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar);
+ if (sysrootFlag && *sysrootFlag) {
+ std::vector<std::string> arch_sysroots;
+ if (const char* arch_sysroots_str =
+ this->Makefile->GetDefinition("CMAKE_APPLE_ARCH_SYSROOTS")) {
+ cmExpandList(std::string(arch_sysroots_str), arch_sysroots, true);
+ }
+ if (!arch_sysroots.empty()) {
+ assert(arch_sysroots.size() == archs.size());
+ for (size_t i = 0; i < archs.size(); ++i) {
+ if (arch_sysroots[i].empty()) {
+ continue;
+ }
+ flags += " -Xarch_" + archs[i] + " ";
+ // Combine sysroot flag and path to work with -Xarch
+ std::string arch_sysroot = sysrootFlag + arch_sysroots[i];
+ flags += this->ConvertToOutputFormat(arch_sysroot, SHELL);
+ }
+ } else if (sysroot && *sysroot) {
+ flags += " ";
+ flags += sysrootFlag;
+ flags += " ";
+ flags += this->ConvertToOutputFormat(sysroot, SHELL);
+ }
+ }
+
const char* deploymentTarget =
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
std::string deploymentTargetFlagVar =
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
const char* deploymentTargetFlag =
this->Makefile->GetDefinition(deploymentTargetFlagVar);
- if (!archs.empty() && !lang.empty() &&
- (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) {
- for (std::string const& arch : archs) {
- flags += " -arch ";
- flags += arch;
- }
- }
-
- if (sysrootFlag && *sysrootFlag && sysroot && *sysroot) {
- flags += " ";
- flags += sysrootFlag;
- flags += " ";
- flags += this->ConvertToOutputFormat(sysroot, SHELL);
- }
-
if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget &&
*deploymentTarget) {
flags += " ";
@@ -2392,7 +2410,9 @@ void cmLocalGenerator::AppendFlags(
void cmLocalGenerator::AppendFlagEscape(std::string& flags,
const std::string& rawFlag) const
{
- this->AppendFlags(flags, this->EscapeForShell(rawFlag));
+ this->AppendFlags(
+ flags,
+ this->EscapeForShell(rawFlag, false, false, false, this->IsNinjaMulti()));
}
void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
@@ -3206,6 +3226,11 @@ bool cmLocalGenerator::IsNMake() const
return this->GetState()->UseNMake();
}
+bool cmLocalGenerator::IsNinjaMulti() const
+{
+ return this->GetState()->UseNinjaMulti();
+}
+
std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
const cmSourceFile& source, std::string const& dir_max,
bool* hasSourceExtension, char const* customOutputExtension)