summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-02 14:25:54 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-03-02 14:25:54 (GMT)
commit2187818706241201b067605138bbcaea420411b5 (patch)
tree40eee46f158a23d7776370a4e03a956c42651270 /Source
parenta52d35b8ef75ea4b6c9411d24450fc17706fdc9f (diff)
parent54a48c6781dd02f2ebbdb19a77c9a4fb59e67735 (diff)
downloadCMake-2187818706241201b067605138bbcaea420411b5.zip
CMake-2187818706241201b067605138bbcaea420411b5.tar.gz
CMake-2187818706241201b067605138bbcaea420411b5.tar.bz2
Merge topic 'xcode-enhance-schemes'
54a48c67 Xcode: Use proper buildable name for schema f4977d05 Xcode: Select executable target for execution in schema 7202db5d Xcode: Fix schema container location calculation 59950821 Xcode: Do not autocreate schemes 6a54d28e Xcode: Use proper indentation for schemes
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx37
-rw-r--r--Source/cmGlobalXCodeGenerator.h4
-rw-r--r--Source/cmXCodeScheme.cxx49
-rw-r--r--Source/cmXCodeScheme.h12
-rw-r--r--Source/cmXMLWriter.cxx11
-rw-r--r--Source/cmXMLWriter.h3
6 files changed, 92 insertions, 24 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d1b6130..b023d5c 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3344,7 +3344,8 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
if (this->GetCMakeInstance()->GetState()->GetGlobalPropertyAsBool(
"XCODE_GENERATE_SCHEME") &&
this->XcodeVersion >= 70) {
- this->OutputXCodeSharedSchemes(xcodeDir, root);
+ this->OutputXCodeSharedSchemes(xcodeDir);
+ this->OutputXCodeWorkspaceSettings(xcodeDir);
}
this->ClearXCodeObjects();
@@ -3356,7 +3357,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
}
void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
- const std::string& xcProjDir, cmLocalGenerator* root)
+ const std::string& xcProjDir)
{
for (std::vector<cmXCodeObject*>::const_iterator i =
this->XCodeObjects.begin();
@@ -3368,11 +3369,41 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
cmXCodeScheme schm(obj, this->CurrentConfigurationTypes,
this->XcodeVersion);
schm.WriteXCodeSharedScheme(xcProjDir,
- root->GetCurrentSourceDirectory());
+ this->RelativeToSource(xcProjDir.c_str()));
}
}
}
+void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings(
+ const std::string& xcProjDir)
+{
+ std::string xcodeSharedDataDir = xcProjDir;
+ xcodeSharedDataDir += "/project.xcworkspace/xcshareddata";
+ cmSystemTools::MakeDirectory(xcodeSharedDataDir);
+
+ std::string workspaceSettingsFile = xcodeSharedDataDir;
+ workspaceSettingsFile += "/WorkspaceSettings.xcsettings";
+
+ cmGeneratedFileStream fout(workspaceSettingsFile.c_str());
+ fout.SetCopyIfDifferent(true);
+ if (!fout) {
+ return;
+ }
+
+ cmXMLWriter xout(fout);
+ xout.StartDocument();
+ xout.Doctype("plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\""
+ "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
+ xout.StartElement("plist");
+ xout.Attribute("version", "1.0");
+ xout.StartElement("dict");
+ xout.Element("key", "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
+ xout.Element("false");
+ xout.EndElement(); // dict
+ xout.EndElement(); // plist
+ xout.EndDocument();
+}
+
void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmLocalGenerator*,
std::vector<cmLocalGenerator*>&)
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index c9157b0..9eacdef 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -166,8 +166,8 @@ private:
void OutputXCodeProject(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
// Write shared scheme files for all the native targets
- void OutputXCodeSharedSchemes(const std::string& xcProjDir,
- cmLocalGenerator* root);
+ void OutputXCodeSharedSchemes(const std::string& xcProjDir);
+ void OutputXCodeWorkspaceSettings(const std::string& xcProjDir);
void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath,
diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx
index 3c8c0b7..5c22531 100644
--- a/Source/cmXCodeScheme.cxx
+++ b/Source/cmXCodeScheme.cxx
@@ -3,6 +3,7 @@
#include "cmXCodeScheme.h"
#include <iomanip>
+#include <iostream>
#include <sstream>
#include "cmGeneratedFileStream.h"
@@ -12,7 +13,9 @@
cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj,
const std::vector<std::string>& configList,
unsigned int xcVersion)
- : TargetName(xcObj->GetTarget()->GetName())
+ : Target(xcObj)
+ , TargetName(xcObj->GetTarget()->GetName())
+ , BuildableName(xcObj->GetTarget()->GetFullName())
, TargetId(xcObj->GetId())
, ConfigList(configList)
, XcodeVersion(xcVersion)
@@ -20,7 +23,7 @@ cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj,
}
void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir,
- const std::string sourceRoot)
+ const std::string& container)
{
// Create shared scheme sub-directory tree
//
@@ -39,14 +42,14 @@ void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir,
return;
}
- std::string xcProjRelDir = xcProjDir.substr(sourceRoot.size() + 1);
- WriteXCodeXCScheme(fout, xcProjRelDir);
+ WriteXCodeXCScheme(fout, container);
}
void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
- const std::string& xcProjDir)
+ const std::string& container)
{
cmXMLWriter xout(fout);
+ xout.SetIndentationElement(std::string(3, ' '));
xout.StartDocument();
xout.StartElement("Scheme");
@@ -54,9 +57,9 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
xout.Attribute("LastUpgradeVersion", WriteVersionString());
xout.Attribute("version", "1.3");
- WriteBuildAction(xout, xcProjDir);
+ WriteBuildAction(xout, container);
WriteTestAction(xout, FindConfiguration("Debug"));
- WriteLaunchAction(xout, FindConfiguration("Debug"), xcProjDir);
+ WriteLaunchAction(xout, FindConfiguration("Debug"), container);
WriteProfileAction(xout, FindConfiguration("Release"));
WriteAnalyzeAction(xout, FindConfiguration("Debug"));
WriteArchiveAction(xout, FindConfiguration("Release"));
@@ -65,7 +68,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
}
void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout,
- const std::string& xcProjDir)
+ const std::string& container)
{
xout.StartElement("BuildAction");
xout.BreakAttributes();
@@ -85,9 +88,9 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout,
xout.BreakAttributes();
xout.Attribute("BuildableIdentifier", "primary");
xout.Attribute("BlueprintIdentifier", this->TargetId);
- xout.Attribute("BuildableName", this->TargetName);
+ xout.Attribute("BuildableName", this->BuildableName);
xout.Attribute("BlueprintName", this->TargetName);
- xout.Attribute("ReferencedContainer", "container:" + xcProjDir);
+ xout.Attribute("ReferencedContainer", "container:" + container);
xout.EndElement();
xout.EndElement(); // BuildActionEntry
@@ -118,7 +121,7 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
std::string configuration,
- const std::string& xcProjDir)
+ const std::string& container)
{
xout.StartElement("LaunchAction");
xout.BreakAttributes();
@@ -134,15 +137,22 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
xout.Attribute("debugServiceExtension", "internal");
xout.Attribute("allowLocationSimulation", "YES");
- xout.StartElement("MacroExpansion");
+ if (IsExecutable(this->Target)) {
+ xout.StartElement("BuildableProductRunnable");
+ xout.BreakAttributes();
+ xout.Attribute("runnableDebuggingMode", "0");
+
+ } else {
+ xout.StartElement("MacroExpansion");
+ }
xout.StartElement("BuildableReference");
xout.BreakAttributes();
xout.Attribute("BuildableIdentifier", "primary");
xout.Attribute("BlueprintIdentifier", this->TargetId);
- xout.Attribute("BuildableName", this->TargetName);
+ xout.Attribute("BuildableName", this->BuildableName);
xout.Attribute("BlueprintName", this->TargetName);
- xout.Attribute("ReferencedContainer", "container:" + xcProjDir);
+ xout.Attribute("ReferencedContainer", "container:" + container);
xout.EndElement();
xout.EndElement(); // MacroExpansion
@@ -204,3 +214,14 @@ std::string cmXCodeScheme::FindConfiguration(const std::string& name)
return name;
}
+
+bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target)
+{
+ cmGeneratorTarget* gt = target->GetTarget();
+ if (!gt) {
+ cmSystemTools::Error("Error no target on xobject\n");
+ return false;
+ }
+
+ return gt->GetType() == cmStateEnums::EXECUTABLE;
+}
diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h
index b174c51..0a8e737 100644
--- a/Source/cmXCodeScheme.h
+++ b/Source/cmXCodeScheme.h
@@ -21,26 +21,30 @@ public:
unsigned int xcVersion);
void WriteXCodeSharedScheme(const std::string& xcProjDir,
- const std::string sourceRoot);
+ const std::string& container);
private:
+ const cmXCodeObject* const Target;
const std::string& TargetName;
+ const std::string BuildableName;
const std::string& TargetId;
const std::vector<std::string>& ConfigList;
const unsigned int XcodeVersion;
- void WriteXCodeXCScheme(std::ostream& fout, const std::string& xcProjDir);
+ void WriteXCodeXCScheme(std::ostream& fout, const std::string& container);
- void WriteBuildAction(cmXMLWriter& xout, const std::string& xcProjDir);
+ void WriteBuildAction(cmXMLWriter& xout, const std::string& container);
void WriteTestAction(cmXMLWriter& xout, std::string configuration);
void WriteLaunchAction(cmXMLWriter& xout, std::string configuration,
- const std::string& xcProjDir);
+ const std::string& container);
void WriteProfileAction(cmXMLWriter& xout, std::string configuration);
void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration);
void WriteArchiveAction(cmXMLWriter& xout, std::string configuration);
std::string WriteVersionString();
std::string FindConfiguration(const std::string& name);
+
+ static bool IsExecutable(const cmXCodeObject* target);
};
#endif
diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx
index 2f50fe9..541cb3d 100644
--- a/Source/cmXMLWriter.cxx
+++ b/Source/cmXMLWriter.cxx
@@ -7,6 +7,7 @@
cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level)
: Output(output)
+ , IndentationElement(1, '\t')
, Level(level)
, ElementOpen(false)
, BreakAttrib(false)
@@ -100,10 +101,18 @@ void cmXMLWriter::FragmentFile(const char* fname)
this->Output << fin.rdbuf();
}
+void cmXMLWriter::SetIndentationElement(std::string const& element)
+{
+ this->IndentationElement = element;
+}
+
void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent)
{
if (condition) {
- this->Output << '\n' << std::string(indent + this->Level, '\t');
+ this->Output << '\n';
+ for (std::size_t i = 0; i < indent + this->Level; ++i) {
+ this->Output << this->IndentationElement;
+ }
}
}
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index 904f73b..6d1e6b4 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -60,6 +60,8 @@ public:
void FragmentFile(const char* fname);
+ void SetIndentationElement(std::string const& element);
+
private:
cmXMLWriter(const cmXMLWriter&);
cmXMLWriter& operator=(const cmXMLWriter&);
@@ -107,6 +109,7 @@ private:
private:
std::ostream& Output;
std::stack<std::string, std::vector<std::string> > Elements;
+ std::string IndentationElement;
std::size_t Level;
bool ElementOpen;
bool BreakAttrib;