diff options
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e353a37..d6ab769 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -546,7 +546,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( target->GetType() == cmStateEnums::STATIC_LIBRARY || target->GetType() == cmStateEnums::SHARED_LIBRARY || target->GetType() == cmStateEnums::MODULE_LIBRARY))) { - makeHelper[makeHelper.size() - 1] = // fill placeholder + makeHelper.back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; commandLines.push_back(makeHelper); @@ -589,8 +589,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( this->CurrentReRunCMakeMakefile += "/CMakeScripts"; cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str()); this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; - cmGeneratedFileStream makefileStream( - this->CurrentReRunCMakeMakefile.c_str()); + cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile); makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n\n"; @@ -1404,7 +1403,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) fname += "."; fname += cmSystemTools::LowerCase(llang); { - cmGeneratedFileStream fout(fname.c_str()); + cmGeneratedFileStream fout(fname); fout << "\n"; } if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) { @@ -1666,7 +1665,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( { std::string makefileName = makefileBasename; makefileName += configName; - cmGeneratedFileStream makefileStream(makefileName.c_str()); + cmGeneratedFileStream makefileStream(makefileName); if (!makefileStream) { return; } @@ -1755,6 +1754,26 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } } +void cmGlobalXCodeGenerator::AddPositionIndependentLinkAttribute( + cmGeneratorTarget* target, cmXCodeObject* buildSettings, + const std::string& configName) +{ + // For now, only EXECUTABLE is concerned + if (target->GetType() != cmStateEnums::EXECUTABLE) { + return; + } + + const char* PICValue = target->GetLinkPIEProperty(configName); + if (PICValue == nullptr) { + // POSITION_INDEPENDENT_CODE is not set + return; + } + + buildSettings->AddAttribute( + "LD_NO_PIE", + this->CreateString(cmSystemTools::IsOn(PICValue) ? "NO" : "YES")); +} + void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, cmXCodeObject* buildSettings, const std::string& configName) @@ -1806,6 +1825,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, buildSettings->AddAttribute("LLVM_LTO", this->CreateString(ltoValue)); } + // Handle PIE linker configuration + this->AddPositionIndependentLinkAttribute(gtgt, buildSettings, configName); + // Add define flags this->CurrentLocalGenerator->AppendFlags( defFlags, this->CurrentMakefile->GetDefineFlags()); @@ -1814,9 +1836,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, BuildObjectListOrString ppDefs(this, true); this->AppendDefines( ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); - if (const char* exportMacro = gtgt->GetExportMacro()) { + if (const std::string* exportMacro = gtgt->GetExportMacro()) { // Add the export symbol definition for shared library objects. - this->AppendDefines(ppDefs, exportMacro); + this->AppendDefines(ppDefs, exportMacro->c_str()); } std::vector<std::string> targetDefines; if (!langForPreprocessor.empty()) { @@ -2841,8 +2863,7 @@ bool cmGlobalXCodeGenerator::CreateGroups( } // Add the file to the list of sources. std::string const& source = sf->GetFullPath(); - cmSourceGroup* sourceGroup = - mf->FindSourceGroup(source.c_str(), sourceGroups); + cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); std::string key = GetGroupMapKeyFromPath(gtgt, source); this->GroupMap[key] = pbxgroup; @@ -2855,8 +2876,7 @@ bool cmGlobalXCodeGenerator::CreateGroups( listfile += "/CMakeLists.txt"; cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(listfile); std::string const& source = sf->GetFullPath(); - cmSourceGroup* sourceGroup = - mf->FindSourceGroup(source.c_str(), sourceGroups); + cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup); std::string key = GetGroupMapKeyFromPath(gtgt, source); this->GroupMap[key] = pbxgroup; @@ -3228,7 +3248,7 @@ void cmGlobalXCodeGenerator::ComputeObjectDirArch(cmMakefile* mf) void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector<cmXCodeObject*>& targets) { - cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str()); + cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile); if (!makefileStream) { cmSystemTools::Error("Could not create", this->CurrentXCodeHackMakefile.c_str()); @@ -3369,7 +3389,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( xcodeDir += ".xcodeproj"; cmSystemTools::MakeDirectory(xcodeDir.c_str()); std::string xcodeProjFile = xcodeDir + "/project.pbxproj"; - cmGeneratedFileStream fout(xcodeProjFile.c_str()); + cmGeneratedFileStream fout(xcodeProjFile); fout.SetCopyIfDifferent(true); if (!fout) { return; @@ -3446,7 +3466,7 @@ void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings( std::string workspaceSettingsFile = xcodeSharedDataDir; workspaceSettingsFile += "/WorkspaceSettings.xcsettings"; - cmGeneratedFileStream fout(workspaceSettingsFile.c_str()); + cmGeneratedFileStream fout(workspaceSettingsFile); fout.SetCopyIfDifferent(true); if (!fout) { return; @@ -3543,7 +3563,7 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p) { // We force conversion because Xcode breakpoints do not work unless // they are in a file named relative to the source tree. - return cmOutputConverter::ForceToRelativePath( + return cmSystemTools::ForceToRelativePath( cmSystemTools::JoinPath(this->ProjectSourceDirectoryComponents), p); } |