2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2005-01-24 22:35:54 +00:00
|
|
|
#include "cmGlobalXCodeGenerator.h"
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2019-11-07 17:52:06 +00:00
|
|
|
#include <algorithm>
|
2019-09-06 20:58:06 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2016-11-22 23:41:44 +00:00
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
|
|
|
|
2019-08-04 08:49:16 +00:00
|
|
|
#include <cm/memory>
|
2019-12-09 16:39:29 +00:00
|
|
|
#include <cmext/algorithm>
|
2019-07-02 09:08:04 +00:00
|
|
|
|
2019-09-30 14:46:28 +00:00
|
|
|
#include "cmsys/RegularExpression.hxx"
|
|
|
|
|
2017-09-21 21:06:05 +00:00
|
|
|
#include "cmAlgorithms.h"
|
2008-01-22 14:13:04 +00:00
|
|
|
#include "cmComputeLinkInformation.h"
|
2019-03-23 15:57:16 +00:00
|
|
|
#include "cmCustomCommand.h"
|
2010-12-07 21:23:38 +00:00
|
|
|
#include "cmCustomCommandGenerator.h"
|
2019-09-13 17:44:37 +00:00
|
|
|
#include "cmCustomCommandLines.h"
|
2016-11-22 23:41:44 +00:00
|
|
|
#include "cmDocumentationEntry.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-11-22 23:41:44 +00:00
|
|
|
#include "cmGeneratorExpression.h"
|
2012-03-13 20:41:28 +00:00
|
|
|
#include "cmGeneratorTarget.h"
|
2012-11-19 14:48:33 +00:00
|
|
|
#include "cmGlobalGeneratorFactory.h"
|
2016-11-22 23:41:44 +00:00
|
|
|
#include "cmLocalGenerator.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmLocalXCodeGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2018-11-22 03:36:50 +00:00
|
|
|
#include "cmMessageType.h"
|
2016-11-22 23:41:44 +00:00
|
|
|
#include "cmOutputConverter.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmSourceFile.h"
|
2016-11-22 23:41:44 +00:00
|
|
|
#include "cmSourceGroup.h"
|
2017-01-15 22:23:31 +00:00
|
|
|
#include "cmState.h"
|
2016-11-22 23:41:44 +00:00
|
|
|
#include "cmStateTypes.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTarget.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmXCode21Object.h"
|
|
|
|
#include "cmXCodeObject.h"
|
2017-01-18 14:20:09 +00:00
|
|
|
#include "cmXCodeScheme.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmake.h"
|
2005-07-19 20:40:44 +00:00
|
|
|
|
2016-11-22 23:41:44 +00:00
|
|
|
struct cmLinkImplementation;
|
2009-09-19 16:00:09 +00:00
|
|
|
|
2019-08-09 14:41:44 +00:00
|
|
|
#if !defined(CMAKE_BOOTSTRAP) && defined(__APPLE__)
|
2018-06-01 13:53:41 +00:00
|
|
|
# define HAVE_APPLICATION_SERVICES
|
|
|
|
# include <ApplicationServices/ApplicationServices.h>
|
2017-10-11 18:58:35 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-09 14:41:44 +00:00
|
|
|
#if !defined(CMAKE_BOOTSTRAP)
|
2018-06-01 13:53:41 +00:00
|
|
|
# include "cmXMLParser.h"
|
2005-07-19 20:40:44 +00:00
|
|
|
|
|
|
|
// parse the xml file storing the installed version of Xcode on
|
|
|
|
// the machine
|
|
|
|
class cmXcodeVersionParser : public cmXMLParser
|
|
|
|
{
|
|
|
|
public:
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXcodeVersionParser()
|
|
|
|
: Version("1.5")
|
|
|
|
{
|
|
|
|
}
|
2017-09-19 14:00:21 +00:00
|
|
|
void StartElement(const std::string&, const char**) override
|
|
|
|
{
|
|
|
|
this->Data = "";
|
|
|
|
}
|
|
|
|
void EndElement(const std::string& name) override
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
if (name == "key") {
|
|
|
|
this->Key = this->Data;
|
|
|
|
} else if (name == "string") {
|
|
|
|
if (this->Key == "CFBundleShortVersionString") {
|
|
|
|
this->Version = this->Data;
|
|
|
|
}
|
2005-07-19 20:40:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-09-19 14:00:21 +00:00
|
|
|
void CharacterDataHandler(const char* data, int length) override
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
this->Data.append(data, length);
|
|
|
|
}
|
2009-09-23 12:48:39 +00:00
|
|
|
std::string Version;
|
2006-03-15 17:02:34 +00:00
|
|
|
std::string Key;
|
|
|
|
std::string Data;
|
2005-07-19 20:40:44 +00:00
|
|
|
};
|
2005-07-19 22:05:18 +00:00
|
|
|
#endif
|
2005-07-19 20:40:44 +00:00
|
|
|
|
2009-07-29 20:39:45 +00:00
|
|
|
// Builds either an object list or a space-separated string from the
|
|
|
|
// given inputs.
|
|
|
|
class cmGlobalXCodeGenerator::BuildObjectListOrString
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGlobalXCodeGenerator* Generator;
|
|
|
|
cmXCodeObject* Group;
|
2009-07-29 20:39:45 +00:00
|
|
|
bool Empty;
|
|
|
|
std::string String;
|
|
|
|
|
|
|
|
public:
|
2016-05-16 14:34:04 +00:00
|
|
|
BuildObjectListOrString(cmGlobalXCodeGenerator* gen, bool buildObjectList)
|
|
|
|
: Generator(gen)
|
2017-09-18 21:57:50 +00:00
|
|
|
, Group(nullptr)
|
2016-05-16 14:34:04 +00:00
|
|
|
, Empty(true)
|
|
|
|
{
|
|
|
|
if (buildObjectList) {
|
2009-07-29 20:39:45 +00:00
|
|
|
this->Group = this->Generator->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-29 20:39:45 +00:00
|
|
|
|
|
|
|
bool IsEmpty() const { return this->Empty; }
|
|
|
|
|
2016-04-20 21:14:52 +00:00
|
|
|
void Add(const std::string& newString)
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
2009-07-29 20:39:45 +00:00
|
|
|
this->Empty = false;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Group) {
|
2009-07-29 20:39:45 +00:00
|
|
|
this->Group->AddObject(this->Generator->CreateString(newString));
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2009-07-29 20:39:45 +00:00
|
|
|
this->String += newString;
|
|
|
|
this->String += ' ';
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-29 20:39:45 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& GetString() const { return this->String; }
|
2009-07-29 20:39:45 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* CreateList()
|
|
|
|
{
|
|
|
|
if (this->Group) {
|
2009-07-29 20:39:45 +00:00
|
|
|
return this->Group;
|
|
|
|
}
|
2017-09-19 14:19:31 +00:00
|
|
|
return this->Generator->CreateString(this->String);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-29 20:39:45 +00:00
|
|
|
};
|
|
|
|
|
2012-11-19 14:48:33 +00:00
|
|
|
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
|
|
|
|
{
|
|
|
|
public:
|
2020-01-02 16:07:09 +00:00
|
|
|
std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
|
|
|
|
const std::string& name, cmake* cm) const override;
|
2012-11-19 14:48:33 +00:00
|
|
|
|
2017-09-15 13:56:26 +00:00
|
|
|
void GetDocumentation(cmDocumentationEntry& entry) const override
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
cmGlobalXCodeGenerator::GetDocumentation(entry);
|
|
|
|
}
|
2012-11-19 14:52:46 +00:00
|
|
|
|
2019-01-18 16:08:45 +00:00
|
|
|
std::vector<std::string> GetGeneratorNames() const override
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
2019-01-18 16:08:45 +00:00
|
|
|
std::vector<std::string> names;
|
2016-05-16 14:34:04 +00:00
|
|
|
names.push_back(cmGlobalXCodeGenerator::GetActualName());
|
2019-01-18 16:08:45 +00:00
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
|
|
|
|
{
|
|
|
|
return std::vector<std::string>();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-15 19:17:54 +00:00
|
|
|
|
2017-09-15 13:56:26 +00:00
|
|
|
bool SupportsToolset() const override { return true; }
|
|
|
|
bool SupportsPlatform() const override { return false; }
|
2019-01-18 15:13:55 +00:00
|
|
|
|
|
|
|
std::vector<std::string> GetKnownPlatforms() const override
|
|
|
|
{
|
|
|
|
return std::vector<std::string>();
|
|
|
|
}
|
2019-01-18 16:45:33 +00:00
|
|
|
|
|
|
|
std::string GetDefaultPlatformName() const override { return std::string(); }
|
2012-11-19 14:48:33 +00:00
|
|
|
};
|
|
|
|
|
2017-04-21 17:08:30 +00:00
|
|
|
cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(
|
|
|
|
cmake* cm, std::string const& version_string, unsigned int version_number)
|
2015-05-24 09:31:14 +00:00
|
|
|
: cmGlobalGenerator(cm)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2017-04-21 17:08:30 +00:00
|
|
|
this->VersionString = version_string;
|
|
|
|
this->XcodeVersion = version_number;
|
2009-09-23 12:48:39 +00:00
|
|
|
|
2017-09-18 21:57:50 +00:00
|
|
|
this->RootObject = nullptr;
|
|
|
|
this->MainGroupChildren = nullptr;
|
|
|
|
this->CurrentMakefile = nullptr;
|
|
|
|
this->CurrentLocalGenerator = nullptr;
|
2015-01-28 18:31:18 +00:00
|
|
|
this->XcodeBuildCommandInitialized = false;
|
2017-04-03 16:47:32 +00:00
|
|
|
|
2017-04-05 18:14:13 +00:00
|
|
|
this->ObjectDirArchDefault = "$(CURRENT_ARCH)";
|
2017-06-29 12:19:23 +00:00
|
|
|
this->ObjectDirArch = this->ObjectDirArchDefault;
|
2017-04-05 18:00:27 +00:00
|
|
|
|
2017-04-03 16:47:32 +00:00
|
|
|
cm->GetState()->SetIsGeneratorMultiConfig(true);
|
2005-07-19 20:40:44 +00:00
|
|
|
}
|
|
|
|
|
2020-01-02 16:07:09 +00:00
|
|
|
std::unique_ptr<cmGlobalGeneratorFactory> cmGlobalXCodeGenerator::NewFactory()
|
2012-11-19 14:48:33 +00:00
|
|
|
{
|
2020-01-02 16:07:09 +00:00
|
|
|
return std::unique_ptr<cmGlobalGeneratorFactory>(new Factory);
|
2012-11-19 14:48:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-02 16:07:09 +00:00
|
|
|
std::unique_ptr<cmGlobalGenerator>
|
|
|
|
cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(const std::string& name,
|
|
|
|
cmake* cm) const
|
2010-09-29 12:38:18 +00:00
|
|
|
{
|
2017-09-20 21:53:14 +00:00
|
|
|
if (name != GetActualName()) {
|
2020-01-02 16:07:09 +00:00
|
|
|
return std::unique_ptr<cmGlobalGenerator>();
|
2017-09-20 21:53:14 +00:00
|
|
|
}
|
2019-08-09 14:41:44 +00:00
|
|
|
#if !defined(CMAKE_BOOTSTRAP)
|
2005-07-19 20:40:44 +00:00
|
|
|
cmXcodeVersionParser parser;
|
2012-08-10 15:58:47 +00:00
|
|
|
std::string versionFile;
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string out;
|
2019-01-12 01:48:19 +00:00
|
|
|
bool commandResult = cmSystemTools::RunSingleCommand(
|
|
|
|
"xcode-select --print-path", &out, nullptr, nullptr, nullptr,
|
|
|
|
cmSystemTools::OUTPUT_NONE);
|
|
|
|
if (commandResult) {
|
|
|
|
std::string::size_type pos = out.find(".app/");
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
versionFile = out.substr(0, pos + 5) + "Contents/version.plist";
|
|
|
|
}
|
2012-08-10 15:58:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-14 13:16:11 +00:00
|
|
|
if (!versionFile.empty() && cmSystemTools::FileExists(versionFile)) {
|
2012-08-10 15:58:47 +00:00
|
|
|
parser.ParseFile(versionFile.c_str());
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (cmSystemTools::FileExists(
|
|
|
|
"/Applications/Xcode.app/Contents/version.plist")) {
|
|
|
|
parser.ParseFile("/Applications/Xcode.app/Contents/version.plist");
|
|
|
|
} else {
|
|
|
|
parser.ParseFile(
|
|
|
|
"/Developer/Applications/Xcode.app/Contents/version.plist");
|
|
|
|
}
|
2017-04-21 17:08:30 +00:00
|
|
|
std::string const& version_string = parser.Version;
|
|
|
|
|
|
|
|
// Compute an integer form of the version number.
|
|
|
|
unsigned int v[2] = { 0, 0 };
|
|
|
|
sscanf(version_string.c_str(), "%u.%u", &v[0], &v[1]);
|
|
|
|
unsigned int version_number = 10 * v[0] + v[1];
|
|
|
|
|
2019-02-10 10:22:38 +00:00
|
|
|
if (version_number < 50) {
|
2018-11-22 03:36:50 +00:00
|
|
|
cm->IssueMessage(MessageType::FATAL_ERROR,
|
2017-04-21 16:57:11 +00:00
|
|
|
"Xcode " + version_string + " not supported.");
|
2020-01-02 16:07:09 +00:00
|
|
|
return std::unique_ptr<cmGlobalGenerator>();
|
2017-04-21 16:57:11 +00:00
|
|
|
}
|
|
|
|
|
2020-01-02 16:07:09 +00:00
|
|
|
return std::unique_ptr<cmGlobalGenerator>(
|
|
|
|
cm::make_unique<cmGlobalXCodeGenerator>(cm, version_string,
|
|
|
|
version_number));
|
2005-07-19 22:05:18 +00:00
|
|
|
#else
|
2011-05-27 22:12:14 +00:00
|
|
|
std::cerr << "CMake should be built with cmake to use Xcode, "
|
2016-05-16 14:34:04 +00:00
|
|
|
"default to Xcode 1.5\n";
|
2020-01-02 16:07:09 +00:00
|
|
|
return std::unique_ptr<cmGlobalGenerator>(
|
|
|
|
cm::make_unique<cmGlobalXCodeGenerator>(cm));
|
2005-07-19 22:05:18 +00:00
|
|
|
#endif
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 14:36:26 +00:00
|
|
|
bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
|
2015-01-28 19:00:02 +00:00
|
|
|
{
|
|
|
|
// The Xcode generator knows how to lookup its build tool
|
|
|
|
// directly instead of needing a helper module to do it, so we
|
|
|
|
// do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
|
2019-08-17 09:04:11 +00:00
|
|
|
if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
|
2019-07-17 14:20:58 +00:00
|
|
|
mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetXcodeBuildCommand());
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-10-20 14:36:26 +00:00
|
|
|
return true;
|
2015-01-28 19:00:02 +00:00
|
|
|
}
|
|
|
|
|
2015-01-28 18:31:18 +00:00
|
|
|
std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!this->XcodeBuildCommandInitialized) {
|
2015-01-28 18:31:18 +00:00
|
|
|
this->XcodeBuildCommandInitialized = true;
|
|
|
|
this->XcodeBuildCommand = this->FindXcodeBuildCommand();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-01-28 18:31:18 +00:00
|
|
|
return this->XcodeBuildCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
|
|
|
|
{
|
2019-02-10 10:22:38 +00:00
|
|
|
std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
|
|
|
|
if (makeProgram.empty()) {
|
|
|
|
makeProgram = "xcodebuild";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2019-02-10 10:22:38 +00:00
|
|
|
return makeProgram;
|
2015-01-28 18:31:18 +00:00
|
|
|
}
|
|
|
|
|
2014-06-04 17:21:55 +00:00
|
|
|
bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
|
2019-09-14 00:32:13 +00:00
|
|
|
bool build, cmMakefile* mf)
|
2012-12-20 15:16:57 +00:00
|
|
|
{
|
2017-05-30 19:37:46 +00:00
|
|
|
if (ts.find_first_of(",=") != std::string::npos) {
|
2017-04-21 16:57:11 +00:00
|
|
|
std::ostringstream e;
|
|
|
|
/* clang-format off */
|
|
|
|
e <<
|
|
|
|
"Generator\n"
|
|
|
|
" " << this->GetName() << "\n"
|
|
|
|
"does not recognize the toolset\n"
|
|
|
|
" " << ts << "\n"
|
|
|
|
"that was specified.";
|
|
|
|
/* clang-format on */
|
2018-11-22 03:36:50 +00:00
|
|
|
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
2017-04-21 16:57:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this->GeneratorToolset = ts;
|
2019-09-14 00:32:13 +00:00
|
|
|
if (build) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-04-21 16:57:11 +00:00
|
|
|
if (!this->GeneratorToolset.empty()) {
|
2019-07-17 14:20:58 +00:00
|
|
|
mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", this->GeneratorToolset);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-04-21 16:57:11 +00:00
|
|
|
return true;
|
2012-12-20 15:16:57 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::EnableLanguage(
|
|
|
|
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
|
2010-09-29 12:38:18 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
mf->AddDefinition("XCODE", "1");
|
2019-07-17 14:20:58 +00:00
|
|
|
mf->AddDefinition("XCODE_VERSION", this->VersionString);
|
2017-04-21 16:57:11 +00:00
|
|
|
if (!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
|
|
|
|
mf->AddCacheDefinition(
|
|
|
|
"CMAKE_CONFIGURATION_TYPES", "Debug;Release;MinSizeRel;RelWithDebInfo",
|
|
|
|
"Semicolon separated list of supported configuration types, "
|
|
|
|
"only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
|
|
|
|
"anything else will be ignored.",
|
|
|
|
cmStateEnums::STRING);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-01 20:48:33 +00:00
|
|
|
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
|
2007-06-28 13:09:26 +00:00
|
|
|
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
|
2017-04-05 17:33:37 +00:00
|
|
|
this->ComputeArchitectures(mf);
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2017-10-11 18:58:35 +00:00
|
|
|
bool cmGlobalXCodeGenerator::Open(const std::string& bindir,
|
|
|
|
const std::string& projectName, bool dryRun)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
#ifdef HAVE_APPLICATION_SERVICES
|
|
|
|
std::string url = bindir + "/" + projectName + ".xcodeproj";
|
|
|
|
|
|
|
|
if (dryRun) {
|
|
|
|
return cmSystemTools::FileExists(url, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
CFStringRef cfStr = CFStringCreateWithCString(
|
|
|
|
kCFAllocatorDefault, url.c_str(), kCFStringEncodingUTF8);
|
|
|
|
if (cfStr) {
|
|
|
|
CFURLRef cfUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfStr,
|
|
|
|
kCFURLPOSIXPathStyle, true);
|
|
|
|
if (cfUrl) {
|
|
|
|
OSStatus err = LSOpenCFURLRef(cfUrl, nullptr);
|
|
|
|
ret = err == noErr;
|
|
|
|
CFRelease(cfUrl);
|
|
|
|
}
|
|
|
|
CFRelease(cfStr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-02-08 13:28:49 +00:00
|
|
|
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
|
|
|
|
cmGlobalXCodeGenerator::GenerateBuildCommand(
|
|
|
|
const std::string& makeProgram, const std::string& projectName,
|
|
|
|
const std::string& /*projectDir*/,
|
|
|
|
std::vector<std::string> const& targetNames, const std::string& config,
|
|
|
|
bool /*fast*/, int jobs, bool /*verbose*/,
|
|
|
|
std::vector<std::string> const& makeOptions)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2019-02-08 13:28:49 +00:00
|
|
|
GeneratedMakeCommand makeCommand;
|
2005-02-01 18:07:42 +00:00
|
|
|
// now build the test
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add(
|
2016-05-16 14:34:04 +00:00
|
|
|
this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand()));
|
2005-02-01 18:07:42 +00:00
|
|
|
|
2018-06-26 19:24:19 +00:00
|
|
|
if (!projectName.empty()) {
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add("-project");
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string projectArg = cmStrCat(projectName, ".xcodeproj");
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add(projectArg);
|
2018-06-26 19:24:19 +00:00
|
|
|
}
|
2019-08-19 12:31:52 +00:00
|
|
|
if (cmContains(targetNames, "clean")) {
|
2019-02-08 13:28:49 +00:00
|
|
|
makeCommand.Add("clean");
|
|
|
|
makeCommand.Add("-target", "ALL_BUILD");
|
|
|
|
} else {
|
|
|
|
makeCommand.Add("build");
|
|
|
|
if (targetNames.empty() ||
|
|
|
|
((targetNames.size() == 1) && targetNames.front().empty())) {
|
|
|
|
makeCommand.Add("-target", "ALL_BUILD");
|
|
|
|
} else {
|
|
|
|
for (const auto& tname : targetNames) {
|
|
|
|
if (!tname.empty()) {
|
|
|
|
makeCommand.Add("-target", tname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-10-30 20:13:33 +00:00
|
|
|
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add("-configuration", (config.empty() ? "Debug" : config));
|
2018-04-14 20:50:19 +00:00
|
|
|
|
|
|
|
if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add("-jobs");
|
2018-04-14 20:50:19 +00:00
|
|
|
if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add(std::to_string(jobs));
|
2018-04-14 20:50:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 19:39:01 +00:00
|
|
|
if (this->XcodeVersion >= 70) {
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add("-hideShellScriptEnvironment");
|
2018-06-10 19:39:01 +00:00
|
|
|
}
|
2019-03-04 09:21:26 +00:00
|
|
|
makeCommand.Add(makeOptions.begin(), makeOptions.end());
|
2019-02-08 13:28:49 +00:00
|
|
|
return { std::move(makeCommand) };
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2019-03-31 09:27:12 +00:00
|
|
|
//! Create a local generator appropriate to this Global Generator
|
2019-12-09 17:13:42 +00:00
|
|
|
std::unique_ptr<cmLocalGenerator> cmGlobalXCodeGenerator::CreateLocalGenerator(
|
|
|
|
cmMakefile* mf)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2019-12-09 17:13:42 +00:00
|
|
|
return std::unique_ptr<cmLocalGenerator>(
|
|
|
|
cm::make_unique<cmLocalXCodeGenerator>(this, mf));
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2015-09-15 18:36:02 +00:00
|
|
|
void cmGlobalXCodeGenerator::AddExtraIDETargets()
|
|
|
|
{
|
2007-05-10 14:05:36 +00:00
|
|
|
// make sure extra targets are added before calling
|
|
|
|
// the parent generate which will call trace depends
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto keyVal : this->ProjectMap) {
|
|
|
|
cmLocalGenerator* root = keyVal.second[0];
|
2007-05-11 17:52:33 +00:00
|
|
|
this->SetGenerationRoot(root);
|
2005-02-18 18:32:51 +00:00
|
|
|
// add ALL_BUILD, INSTALL, etc
|
2017-11-07 07:41:47 +00:00
|
|
|
this->AddExtraTargets(root, keyVal.second);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-07-25 17:03:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-19 11:54:29 +00:00
|
|
|
void cmGlobalXCodeGenerator::ComputeTargetOrder()
|
|
|
|
{
|
|
|
|
size_t index = 0;
|
|
|
|
auto const& lgens = this->GetLocalGenerators();
|
2019-11-07 17:52:06 +00:00
|
|
|
for (auto const& lgen : lgens) {
|
|
|
|
const auto& targets = lgen->GetGeneratorTargets();
|
|
|
|
for (const auto& gt : targets) {
|
|
|
|
this->ComputeTargetOrder(gt.get(), index);
|
2018-07-19 11:54:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(index == this->TargetOrderIndex.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalXCodeGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
|
|
|
|
size_t& index)
|
|
|
|
{
|
|
|
|
std::map<cmGeneratorTarget const*, size_t>::value_type value(gt, 0);
|
|
|
|
auto insertion = this->TargetOrderIndex.insert(value);
|
|
|
|
if (!insertion.second) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto entry = insertion.first;
|
|
|
|
|
|
|
|
auto& deps = this->GetTargetDirectDepends(gt);
|
|
|
|
for (auto& d : deps) {
|
|
|
|
this->ComputeTargetOrder(d, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
entry->second = index++;
|
|
|
|
}
|
|
|
|
|
2015-07-25 17:03:51 +00:00
|
|
|
void cmGlobalXCodeGenerator::Generate()
|
|
|
|
{
|
2007-05-10 14:05:36 +00:00
|
|
|
this->cmGlobalGenerator::Generate();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2012-03-16 14:14:33 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 11:54:29 +00:00
|
|
|
|
|
|
|
this->ComputeTargetOrder();
|
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto keyVal : this->ProjectMap) {
|
|
|
|
cmLocalGenerator* root = keyVal.second[0];
|
2017-10-19 20:48:13 +00:00
|
|
|
|
|
|
|
bool generateTopLevelProjectOnly =
|
|
|
|
root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
|
|
|
|
|
|
|
|
if (generateTopLevelProjectOnly) {
|
|
|
|
cmStateSnapshot snp = root->GetStateSnapshot();
|
|
|
|
if (snp.GetBuildsystemDirectoryParent().IsValid()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-11 17:52:33 +00:00
|
|
|
this->SetGenerationRoot(root);
|
2005-02-18 18:32:51 +00:00
|
|
|
// now create the project
|
2017-11-07 07:41:47 +00:00
|
|
|
this->OutputXCodeProject(root, keyVal.second);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-18 18:32:51 +00:00
|
|
|
}
|
2005-02-17 22:54:14 +00:00
|
|
|
|
2007-05-11 17:52:33 +00:00
|
|
|
void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root)
|
|
|
|
{
|
2015-10-06 22:29:25 +00:00
|
|
|
this->CurrentProject = root->GetProjectName();
|
2007-05-11 17:52:33 +00:00
|
|
|
this->SetCurrentLocalGenerator(root);
|
2015-10-07 17:25:29 +00:00
|
|
|
cmSystemTools::SplitPath(
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->GetCurrentSourceDirectory(),
|
|
|
|
this->ProjectSourceDirectoryComponents);
|
2015-09-24 22:13:20 +00:00
|
|
|
cmSystemTools::SplitPath(
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->GetCurrentBinaryDirectory(),
|
|
|
|
this->ProjectOutputDirectoryComponents);
|
2007-05-11 17:52:33 +00:00
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
this->CurrentXCodeHackMakefile =
|
|
|
|
cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeScripts");
|
2019-05-14 13:16:11 +00:00
|
|
|
cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile);
|
2007-05-11 17:52:33 +00:00
|
|
|
this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make";
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(
|
|
|
|
std::string const& tName, std::string const& configName)
|
2011-06-06 21:34:43 +00:00
|
|
|
{
|
2011-08-27 18:17:00 +00:00
|
|
|
std::string target = tName;
|
Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and
`with` are string literals with a size of one.
Automate with:
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
2016-05-24 20:58:11 +00:00
|
|
|
std::replace(target.begin(), target.end(), ' ', '_');
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string out = cmStrCat("PostBuild.", target, '.', configName);
|
2011-06-06 21:34:43 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2011-07-26 21:13:42 +00:00
|
|
|
#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
|
2019-01-30 14:33:35 +00:00
|
|
|
#define OBJECT_LIBRARY_ARTIFACT_DIR std::string()
|
2011-07-26 21:13:42 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::AddExtraTargets(
|
|
|
|
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens)
|
2005-02-18 18:32:51 +00:00
|
|
|
{
|
2017-09-18 21:57:50 +00:00
|
|
|
const char* no_working_directory = nullptr;
|
2019-09-20 23:17:15 +00:00
|
|
|
std::vector<std::string> no_byproducts;
|
2005-02-22 15:32:44 +00:00
|
|
|
std::vector<std::string> no_depends;
|
2019-09-20 23:17:15 +00:00
|
|
|
|
|
|
|
// Add ALL_BUILD
|
2019-10-17 15:02:20 +00:00
|
|
|
cmTarget* allbuild = root->AddUtilityCommand(
|
|
|
|
"ALL_BUILD", true, no_working_directory, no_byproducts, no_depends,
|
2019-09-20 23:17:15 +00:00
|
|
|
cmMakeSingleCommandLine({ "echo", "Build all projects" }));
|
2015-08-04 22:00:53 +00:00
|
|
|
|
2019-11-07 17:52:06 +00:00
|
|
|
root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(allbuild, root));
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2010-09-29 12:38:18 +00:00
|
|
|
// Add XCODE depend helper
|
2015-09-24 22:13:20 +00:00
|
|
|
std::string dir = root->GetCurrentBinaryDirectory();
|
2019-09-13 17:44:37 +00:00
|
|
|
cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
|
|
|
|
{ "make", "-C", dir, "-f", this->CurrentXCodeHackMakefile,
|
|
|
|
"OBJDIR=$(OBJDIR)", /* placeholder, see below */ "" });
|
2011-06-06 21:34:43 +00:00
|
|
|
|
2011-07-26 21:13:42 +00:00
|
|
|
// Add ZERO_CHECK
|
2018-02-23 13:56:22 +00:00
|
|
|
bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION");
|
2018-02-21 22:42:55 +00:00
|
|
|
bool generateTopLevelProjectOnly =
|
2019-10-17 15:02:20 +00:00
|
|
|
root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
|
2018-02-21 22:42:55 +00:00
|
|
|
bool isTopLevel =
|
|
|
|
!root->GetStateSnapshot().GetBuildsystemDirectoryParent().IsValid();
|
2020-01-25 22:41:42 +00:00
|
|
|
bool isGenerateProject = isTopLevel || !generateTopLevelProjectOnly;
|
|
|
|
if (regenerate && isGenerateProject) {
|
2011-07-26 21:13:42 +00:00
|
|
|
this->CreateReRunCMakeFile(root, gens);
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string file =
|
2018-02-14 15:50:14 +00:00
|
|
|
this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile);
|
2011-07-26 21:13:42 +00:00
|
|
|
cmSystemTools::ReplaceString(file, "\\ ", " ");
|
2019-10-17 15:02:20 +00:00
|
|
|
cmTarget* check =
|
|
|
|
root->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true,
|
|
|
|
no_working_directory, no_byproducts, no_depends,
|
|
|
|
cmMakeSingleCommandLine({ "make", "-f", file }));
|
2015-08-04 22:00:53 +00:00
|
|
|
|
2019-11-07 17:52:06 +00:00
|
|
|
root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(check, root));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-28 20:07:13 +00:00
|
|
|
|
2005-02-18 18:32:51 +00:00
|
|
|
// now make the allbuild depend on all the non-utility targets
|
|
|
|
// in the project
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& gen : gens) {
|
2019-11-07 17:52:06 +00:00
|
|
|
for (const auto& target : gen->GetGeneratorTargets()) {
|
2016-10-18 19:28:46 +00:00
|
|
|
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
2015-07-28 16:37:55 +00:00
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-07-28 16:37:55 +00:00
|
|
|
|
2019-09-20 23:17:15 +00:00
|
|
|
if (regenerate &&
|
|
|
|
(target->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) {
|
2015-10-21 18:32:20 +00:00
|
|
|
target->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-07-26 21:13:42 +00:00
|
|
|
|
2010-09-29 12:38:18 +00:00
|
|
|
// make all exe, shared libs and modules
|
2008-01-10 20:17:23 +00:00
|
|
|
// run the depend check makefile as a post build rule
|
|
|
|
// this will make sure that when the next target is built
|
|
|
|
// things are up-to-date
|
2020-01-25 22:41:42 +00:00
|
|
|
if (isGenerateProject &&
|
|
|
|
target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
|
2019-09-13 17:44:37 +00:00
|
|
|
commandLines.front().back() = // fill placeholder
|
2015-10-21 18:32:20 +00:00
|
|
|
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
|
2019-10-17 15:02:20 +00:00
|
|
|
gen->AddCustomCommandToTarget(
|
2016-05-16 14:34:04 +00:00
|
|
|
target->GetName(), no_byproducts, no_depends, commandLines,
|
2019-09-20 20:44:14 +00:00
|
|
|
cmCustomCommandType::POST_BUILD, "Depend check for xcode",
|
|
|
|
dir.c_str(), true, false, "", "", false,
|
|
|
|
cmObjectLibraryCommands::Accept);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-07-26 21:13:42 +00:00
|
|
|
|
2019-11-07 17:52:06 +00:00
|
|
|
if (!this->IsExcluded(gens[0], target.get())) {
|
2015-10-21 18:32:20 +00:00
|
|
|
allbuild->AddUtility(target->GetName());
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:07:23 +00:00
|
|
|
void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
|
|
|
|
cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens)
|
2005-02-28 20:07:13 +00:00
|
|
|
{
|
2011-01-13 17:07:23 +00:00
|
|
|
std::vector<std::string> lfiles;
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto gen : gens) {
|
2019-12-09 16:39:29 +00:00
|
|
|
cm::append(lfiles, gen->GetMakefile()->GetListFiles());
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-01-13 17:07:23 +00:00
|
|
|
|
2005-02-28 20:07:13 +00:00
|
|
|
// sort the array
|
2019-09-04 20:17:22 +00:00
|
|
|
std::sort(lfiles.begin(), lfiles.end());
|
|
|
|
lfiles.erase(std::unique(lfiles.begin(), lfiles.end()), lfiles.end());
|
2018-02-14 16:34:35 +00:00
|
|
|
|
|
|
|
cmake* cm = this->GetCMakeInstance();
|
|
|
|
if (cm->DoWriteGlobVerifyTarget()) {
|
|
|
|
lfiles.emplace_back(cm->GetGlobVerifyStamp());
|
|
|
|
}
|
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
this->CurrentReRunCMakeMakefile =
|
|
|
|
cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeScripts");
|
2019-05-14 13:16:11 +00:00
|
|
|
cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile);
|
2006-03-15 16:02:08 +00:00
|
|
|
this->CurrentReRunCMakeMakefile += "/ReRunCMake.make";
|
2018-11-27 18:19:45 +00:00
|
|
|
cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile);
|
2005-12-21 20:45:55 +00:00
|
|
|
makefileStream.SetCopyIfDifferent(true);
|
2016-03-06 16:46:53 +00:00
|
|
|
makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
|
|
|
|
|
2018-02-07 20:24:53 +00:00
|
|
|
makefileStream << "TARGETS:= \n";
|
2016-03-06 16:46:53 +00:00
|
|
|
makefileStream << "empty:= \n";
|
|
|
|
makefileStream << "space:= $(empty) $(empty)\n";
|
|
|
|
makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
|
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& lfile : lfiles) {
|
2016-03-06 16:46:53 +00:00
|
|
|
makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
|
2018-02-14 15:50:14 +00:00
|
|
|
<< this->ConvertToRelativeForMake(lfile) << "))\n";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-02-14 16:34:35 +00:00
|
|
|
makefileStream << "\n";
|
2016-03-06 16:46:53 +00:00
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string checkCache =
|
|
|
|
cmStrCat(root->GetBinaryDirectory(), "/CMakeFiles/cmake.check_cache");
|
2016-03-06 16:46:53 +00:00
|
|
|
|
2018-02-14 16:34:35 +00:00
|
|
|
if (cm->DoWriteGlobVerifyTarget()) {
|
|
|
|
makefileStream << ".NOTPARALLEL:\n\n";
|
|
|
|
makefileStream << ".PHONY: all VERIFY_GLOBS\n\n";
|
|
|
|
makefileStream << "all: VERIFY_GLOBS "
|
|
|
|
<< this->ConvertToRelativeForMake(checkCache) << "\n\n";
|
|
|
|
makefileStream << "VERIFY_GLOBS:\n";
|
|
|
|
makefileStream << "\t"
|
|
|
|
<< this->ConvertToRelativeForMake(
|
|
|
|
cmSystemTools::GetCMakeCommand())
|
|
|
|
<< " -P "
|
|
|
|
<< this->ConvertToRelativeForMake(cm->GetGlobVerifyScript())
|
|
|
|
<< "\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
makefileStream << this->ConvertToRelativeForMake(checkCache)
|
2016-03-06 16:46:53 +00:00
|
|
|
<< ": $(TARGETS)\n";
|
2016-05-16 14:34:04 +00:00
|
|
|
makefileStream << "\t"
|
|
|
|
<< this->ConvertToRelativeForMake(
|
2018-02-14 15:50:14 +00:00
|
|
|
cmSystemTools::GetCMakeCommand())
|
2016-05-16 14:34:04 +00:00
|
|
|
<< " -H"
|
|
|
|
<< this->ConvertToRelativeForMake(root->GetSourceDirectory())
|
|
|
|
<< " -B"
|
|
|
|
<< this->ConvertToRelativeForMake(root->GetBinaryDirectory())
|
|
|
|
<< "\n";
|
2005-02-28 20:07:13 +00:00
|
|
|
}
|
|
|
|
|
2015-04-07 17:14:52 +00:00
|
|
|
static bool objectIdLessThan(cmXCodeObject* l, cmXCodeObject* r)
|
|
|
|
{
|
|
|
|
return l->GetId() < r->GetId();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalXCodeGenerator::SortXCodeObjects()
|
|
|
|
{
|
|
|
|
std::sort(this->XCodeObjects.begin(), this->XCodeObjects.end(),
|
|
|
|
objectIdLessThan);
|
|
|
|
}
|
|
|
|
|
2005-01-24 22:35:54 +00:00
|
|
|
void cmGlobalXCodeGenerator::ClearXCodeObjects()
|
|
|
|
{
|
2006-03-15 16:02:08 +00:00
|
|
|
this->TargetDoneSet.clear();
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& obj : this->XCodeObjects) {
|
|
|
|
delete obj;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-03-15 16:02:08 +00:00
|
|
|
this->XCodeObjects.clear();
|
2011-08-23 22:22:33 +00:00
|
|
|
this->XCodeObjectIDs.clear();
|
2014-12-01 17:56:46 +00:00
|
|
|
this->XCodeObjectMap.clear();
|
2006-03-15 16:02:08 +00:00
|
|
|
this->GroupMap.clear();
|
|
|
|
this->GroupNameMap.clear();
|
|
|
|
this->TargetGroup.clear();
|
2007-08-14 15:45:15 +00:00
|
|
|
this->FileRefs.clear();
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::addObject(cmXCodeObject* obj)
|
2011-08-23 22:22:33 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (obj->GetType() == cmXCodeObject::OBJECT) {
|
2017-09-19 13:54:08 +00:00
|
|
|
const std::string& id = obj->GetId();
|
2011-08-23 22:22:33 +00:00
|
|
|
|
|
|
|
// If this is a duplicate id, it's an error:
|
|
|
|
//
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->XCodeObjectIDs.count(id)) {
|
2011-08-23 22:22:33 +00:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"Xcode generator: duplicate object ids not allowed");
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-08-23 22:22:33 +00:00
|
|
|
|
|
|
|
this->XCodeObjectIDs.insert(id);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-08-23 22:22:33 +00:00
|
|
|
|
|
|
|
this->XCodeObjects.push_back(obj);
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(
|
|
|
|
cmXCodeObject::PBXType ptype)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2017-04-21 16:57:11 +00:00
|
|
|
cmXCodeObject* obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT);
|
2011-08-23 22:22:33 +00:00
|
|
|
this->addObject(obj);
|
2005-01-24 22:35:54 +00:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
|
2005-01-25 20:26:57 +00:00
|
|
|
{
|
2005-01-27 21:11:44 +00:00
|
|
|
cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type);
|
2011-08-23 22:22:33 +00:00
|
|
|
this->addObject(obj);
|
2005-01-27 21:11:44 +00:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateString(const std::string& s)
|
2005-01-27 21:11:44 +00:00
|
|
|
{
|
|
|
|
cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING);
|
2005-01-25 20:26:57 +00:00
|
|
|
obj->SetString(s);
|
|
|
|
return obj;
|
|
|
|
}
|
2005-02-18 18:32:51 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateObjectReference(
|
|
|
|
cmXCodeObject* ref)
|
2005-01-28 21:00:10 +00:00
|
|
|
{
|
|
|
|
cmXCodeObject* obj = this->CreateObject(cmXCodeObject::OBJECT_REF);
|
|
|
|
obj->SetObject(ref);
|
|
|
|
return obj;
|
|
|
|
}
|
2005-01-25 20:26:57 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateFlatClone(cmXCodeObject* orig)
|
2016-01-03 10:55:50 +00:00
|
|
|
{
|
|
|
|
cmXCodeObject* obj = this->CreateObject(orig->GetType());
|
|
|
|
obj->CopyAttributes(orig);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string GetGroupMapKeyFromPath(cmGeneratorTarget* target,
|
|
|
|
const std::string& fullpath)
|
2007-08-14 15:45:15 +00:00
|
|
|
{
|
2015-10-19 19:23:29 +00:00
|
|
|
std::string key(target->GetName());
|
2007-08-14 15:45:15 +00:00
|
|
|
key += "-";
|
2012-03-15 16:05:31 +00:00
|
|
|
key += fullpath;
|
2007-08-14 15:45:15 +00:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
|
|
|
|
const std::string& fullpath, cmGeneratorTarget* target,
|
|
|
|
const std::string& lang, cmSourceFile* sf)
|
2012-03-15 16:05:31 +00:00
|
|
|
{
|
|
|
|
// Using a map and the full path guarantees that we will always get the same
|
|
|
|
// fileRef object for any given full path.
|
|
|
|
//
|
|
|
|
cmXCodeObject* fileRef =
|
2015-10-19 19:23:29 +00:00
|
|
|
this->CreateXCodeFileReferenceFromPath(fullpath, target, lang, sf);
|
2012-03-15 16:05:31 +00:00
|
|
|
|
|
|
|
cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
|
|
|
|
buildFile->SetComment(fileRef->GetComment());
|
|
|
|
buildFile->AddAttribute("fileRef", this->CreateObjectReference(fileRef));
|
|
|
|
|
|
|
|
return buildFile;
|
|
|
|
}
|
|
|
|
|
2017-12-01 16:10:45 +00:00
|
|
|
class XCodeGeneratorExpressionInterpreter
|
|
|
|
: public cmGeneratorExpressionInterpreter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
XCodeGeneratorExpressionInterpreter(cmSourceFile* sourceFile,
|
|
|
|
cmLocalGenerator* localGenerator,
|
2018-09-06 20:49:34 +00:00
|
|
|
cmGeneratorTarget* headTarget,
|
2017-12-13 15:34:11 +00:00
|
|
|
const std::string& lang)
|
2018-09-06 20:49:34 +00:00
|
|
|
: cmGeneratorExpressionInterpreter(
|
|
|
|
localGenerator, "NO-PER-CONFIG-SUPPORT-IN-XCODE", headTarget, lang)
|
2017-12-01 16:10:45 +00:00
|
|
|
, SourceFile(sourceFile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-23 19:30:01 +00:00
|
|
|
XCodeGeneratorExpressionInterpreter(
|
|
|
|
XCodeGeneratorExpressionInterpreter const&) = delete;
|
|
|
|
XCodeGeneratorExpressionInterpreter& operator=(
|
|
|
|
XCodeGeneratorExpressionInterpreter const&) = delete;
|
|
|
|
|
2017-12-01 16:10:45 +00:00
|
|
|
using cmGeneratorExpressionInterpreter::Evaluate;
|
|
|
|
|
2018-08-25 23:57:00 +00:00
|
|
|
const std::string& Evaluate(const char* expression,
|
|
|
|
const std::string& property)
|
2017-12-01 16:10:45 +00:00
|
|
|
{
|
2018-08-25 23:57:00 +00:00
|
|
|
const std::string& processed =
|
2017-12-13 15:34:11 +00:00
|
|
|
this->cmGeneratorExpressionInterpreter::Evaluate(expression, property);
|
2018-09-06 20:49:34 +00:00
|
|
|
if (this->CompiledGeneratorExpression->GetHadContextSensitiveCondition()) {
|
2017-12-01 16:10:45 +00:00
|
|
|
std::ostringstream e;
|
|
|
|
/* clang-format off */
|
|
|
|
e <<
|
|
|
|
"Xcode does not support per-config per-source " << property << ":\n"
|
|
|
|
" " << expression << "\n"
|
|
|
|
"specified for source:\n"
|
2019-11-05 19:20:21 +00:00
|
|
|
" " << this->SourceFile->ResolveFullPath() << "\n";
|
2017-12-01 16:10:45 +00:00
|
|
|
/* clang-format on */
|
2018-11-22 03:36:50 +00:00
|
|
|
this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
2017-12-01 16:10:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return processed;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
cmSourceFile* SourceFile = nullptr;
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
|
|
|
|
cmLocalGenerator* lg, cmSourceFile* sf, cmGeneratorTarget* gtgt)
|
2005-01-27 21:11:44 +00:00
|
|
|
{
|
2017-12-13 15:34:11 +00:00
|
|
|
std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
|
|
|
|
|
|
|
|
XCodeGeneratorExpressionInterpreter genexInterpreter(sf, lg, gtgt, lang);
|
2017-12-01 16:10:45 +00:00
|
|
|
|
2007-08-14 15:45:15 +00:00
|
|
|
// Add flags from target and source file properties.
|
2005-02-11 19:25:05 +00:00
|
|
|
std::string flags;
|
2011-09-01 14:52:51 +00:00
|
|
|
const char* srcfmt = sf->GetProperty("Fortran_FORMAT");
|
2016-06-05 21:44:39 +00:00
|
|
|
switch (cmOutputConverter::GetFortranFormat(srcfmt)) {
|
2016-05-19 21:11:40 +00:00
|
|
|
case cmOutputConverter::FortranFormatFixed:
|
2016-05-16 14:34:04 +00:00
|
|
|
flags = "-fixed " + flags;
|
|
|
|
break;
|
2016-05-19 21:11:40 +00:00
|
|
|
case cmOutputConverter::FortranFormatFree:
|
2016-05-16 14:34:04 +00:00
|
|
|
flags = "-free " + flags;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-12-13 15:34:11 +00:00
|
|
|
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
|
|
|
|
if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) {
|
|
|
|
lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
|
2016-10-25 16:23:22 +00:00
|
|
|
}
|
2017-12-15 11:31:53 +00:00
|
|
|
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
|
|
|
|
if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) {
|
|
|
|
lg->AppendCompileOptions(
|
|
|
|
flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
|
|
|
|
}
|
2005-11-16 18:13:39 +00:00
|
|
|
|
2008-01-14 14:20:58 +00:00
|
|
|
// Add per-source definitions.
|
2009-06-29 17:02:05 +00:00
|
|
|
BuildObjectListOrString flagsBuild(this, false);
|
2017-12-13 15:34:11 +00:00
|
|
|
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
|
|
|
|
if (const char* compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) {
|
2017-11-30 14:06:21 +00:00
|
|
|
this->AppendDefines(
|
2018-08-25 23:57:00 +00:00
|
|
|
flagsBuild,
|
|
|
|
genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS).c_str(),
|
2017-12-13 15:34:11 +00:00
|
|
|
true);
|
2017-11-30 14:06:21 +00:00
|
|
|
}
|
2019-10-05 10:20:37 +00:00
|
|
|
|
|
|
|
if (sf->GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS")) {
|
|
|
|
this->AppendDefines(flagsBuild, "CMAKE_SKIP_PRECOMPILE_HEADERS", true);
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!flagsBuild.IsEmpty()) {
|
|
|
|
if (!flags.empty()) {
|
2009-06-29 17:02:05 +00:00
|
|
|
flags += ' ';
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
flags += flagsBuild.GetString();
|
|
|
|
}
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2017-12-21 16:03:18 +00:00
|
|
|
// Add per-source include directories.
|
|
|
|
std::vector<std::string> includes;
|
|
|
|
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
|
|
|
|
if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) {
|
|
|
|
lg->AppendIncludeDirectories(
|
|
|
|
includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
|
|
|
|
*sf);
|
|
|
|
}
|
|
|
|
lg->AppendFlags(flags, lg->GetIncludeFlags(includes, gtgt, lang, true));
|
|
|
|
|
2012-03-15 16:05:31 +00:00
|
|
|
cmXCodeObject* buildFile =
|
2019-11-05 19:20:21 +00:00
|
|
|
this->CreateXCodeSourceFileFromPath(sf->ResolveFullPath(), gtgt, lang, sf);
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
2016-06-04 01:32:38 +00:00
|
|
|
settings->AddAttributeIfNotEmpty("COMPILER_FLAGS",
|
|
|
|
this->CreateString(flags));
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2014-02-06 10:24:37 +00:00
|
|
|
cmGeneratorTarget::SourceFileFlags tsFlags =
|
2016-05-16 14:34:04 +00:00
|
|
|
gtgt->GetTargetSourceFileFlags(sf);
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2016-06-04 01:32:38 +00:00
|
|
|
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
|
2007-08-14 15:45:15 +00:00
|
|
|
// Is this a "private" or "public" framework header file?
|
|
|
|
// Set the ATTRIBUTES attribute appropriately...
|
|
|
|
//
|
2016-05-16 14:34:04 +00:00
|
|
|
if (gtgt->IsFrameworkOnApple()) {
|
|
|
|
if (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) {
|
2007-08-14 15:45:15 +00:00
|
|
|
attrs->AddObject(this->CreateString("Private"));
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader) {
|
2007-08-14 15:45:15 +00:00
|
|
|
attrs->AddObject(this->CreateString("Public"));
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2016-06-04 01:51:18 +00:00
|
|
|
// Add user-specified file attributes.
|
|
|
|
const char* extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES");
|
|
|
|
if (extraFileAttributes) {
|
|
|
|
// Expand the list of attributes.
|
2019-08-23 14:17:39 +00:00
|
|
|
std::vector<std::string> attributes = cmExpandedList(extraFileAttributes);
|
2016-06-04 01:51:18 +00:00
|
|
|
|
|
|
|
// Store the attributes.
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& attribute : attributes) {
|
|
|
|
attrs->AddObject(this->CreateString(attribute));
|
2016-06-04 01:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-04 01:32:38 +00:00
|
|
|
settings->AddAttributeIfNotEmpty("ATTRIBUTES", attrs);
|
|
|
|
|
|
|
|
buildFile->AddAttributeIfNotEmpty("settings", settings);
|
2008-10-09 15:01:48 +00:00
|
|
|
return buildFile;
|
|
|
|
}
|
|
|
|
|
2018-04-13 12:49:37 +00:00
|
|
|
void cmGlobalXCodeGenerator::AddXCodeProjBuildRule(
|
|
|
|
cmGeneratorTarget* target, std::vector<cmSourceFile*>& sources) const
|
|
|
|
{
|
|
|
|
std::string listfile =
|
2019-08-22 14:34:40 +00:00
|
|
|
cmStrCat(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
|
|
|
|
"/CMakeLists.txt");
|
2019-11-05 19:19:36 +00:00
|
|
|
cmSourceFile* srcCMakeLists = target->Makefile->GetOrCreateSource(
|
|
|
|
listfile, false, cmSourceFileLocationKind::Known);
|
2019-08-19 12:31:52 +00:00
|
|
|
if (!cmContains(sources, srcCMakeLists)) {
|
2018-04-13 12:49:37 +00:00
|
|
|
sources.push_back(srcCMakeLists);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string GetSourcecodeValueFromFileExtension(const std::string& _ext,
|
|
|
|
const std::string& lang,
|
|
|
|
bool& keepLastKnownFileType)
|
2008-10-09 15:01:48 +00:00
|
|
|
{
|
2012-03-15 16:05:31 +00:00
|
|
|
std::string ext = cmSystemTools::LowerCase(_ext);
|
2005-02-01 20:48:33 +00:00
|
|
|
std::string sourcecode = "sourcecode";
|
2008-09-05 19:51:19 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (ext == "o") {
|
2005-02-18 18:32:51 +00:00
|
|
|
sourcecode = "compiled.mach-o.objfile";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "xctest") {
|
2015-02-25 20:07:43 +00:00
|
|
|
sourcecode = "wrapper.cfbundle";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "xib") {
|
2014-01-16 18:16:34 +00:00
|
|
|
keepLastKnownFileType = true;
|
2009-02-19 16:20:09 +00:00
|
|
|
sourcecode = "file.xib";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "storyboard") {
|
2014-01-16 18:16:34 +00:00
|
|
|
keepLastKnownFileType = true;
|
2012-05-11 14:32:00 +00:00
|
|
|
sourcecode = "file.storyboard";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "mm") {
|
2005-02-17 22:54:14 +00:00
|
|
|
sourcecode += ".cpp.objcpp";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "m") {
|
2008-09-05 19:51:19 +00:00
|
|
|
sourcecode += ".c.objc";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "swift") {
|
2015-07-06 20:15:49 +00:00
|
|
|
sourcecode += ".swift";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "plist") {
|
2006-01-05 14:13:06 +00:00
|
|
|
sourcecode += ".text.plist";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "h") {
|
2009-07-08 17:03:34 +00:00
|
|
|
sourcecode += ".c.h";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "hxx" || ext == "hpp" || ext == "txx" || ext == "pch" ||
|
|
|
|
ext == "hh") {
|
2009-07-08 17:03:34 +00:00
|
|
|
sourcecode += ".cpp.h";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "png" || ext == "gif" || ext == "jpg") {
|
2014-01-16 18:16:34 +00:00
|
|
|
keepLastKnownFileType = true;
|
2012-03-15 16:05:31 +00:00
|
|
|
sourcecode = "image";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "txt") {
|
2012-03-15 16:05:31 +00:00
|
|
|
sourcecode += ".text";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (lang == "CXX") {
|
2012-03-15 16:05:31 +00:00
|
|
|
sourcecode += ".cpp.cpp";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (lang == "C") {
|
2012-03-15 16:05:31 +00:00
|
|
|
sourcecode += ".c.c";
|
2019-11-20 14:43:00 +00:00
|
|
|
} else if (lang == "OBJCXX") {
|
|
|
|
sourcecode += ".cpp.objcpp";
|
|
|
|
} else if (lang == "OBJC") {
|
|
|
|
sourcecode += ".c.objc";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (lang == "Fortran") {
|
2012-03-15 16:05:31 +00:00
|
|
|
sourcecode += ".fortran.f90";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (lang == "ASM") {
|
2012-08-15 13:50:51 +00:00
|
|
|
sourcecode += ".asm";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (ext == "metal") {
|
2015-04-01 19:02:42 +00:00
|
|
|
sourcecode += ".metal";
|
2016-06-04 01:27:39 +00:00
|
|
|
} else if (ext == "mig") {
|
|
|
|
sourcecode += ".mig";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
// else
|
2008-09-05 19:51:19 +00:00
|
|
|
// {
|
|
|
|
// // Already specialized above or we leave sourcecode == "sourcecode"
|
|
|
|
// // which is probably the most correct choice. Extensionless headers,
|
|
|
|
// // for example... Or file types unknown to Xcode that do not map to a
|
2013-04-16 19:42:44 +00:00
|
|
|
// // valid explicitFileType value.
|
2008-09-05 19:51:19 +00:00
|
|
|
// }
|
|
|
|
|
2012-03-15 16:05:31 +00:00
|
|
|
return sourcecode;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
|
|
|
|
const std::string& fullpath, cmGeneratorTarget* target,
|
|
|
|
const std::string& lang, cmSourceFile* sf)
|
2012-03-15 16:05:31 +00:00
|
|
|
{
|
2015-10-19 19:23:29 +00:00
|
|
|
std::string key = GetGroupMapKeyFromPath(target, fullpath);
|
2014-09-03 15:54:05 +00:00
|
|
|
cmXCodeObject* fileRef = this->FileRefs[key];
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!fileRef) {
|
2012-03-15 16:05:31 +00:00
|
|
|
fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
|
2014-09-03 15:54:05 +00:00
|
|
|
fileRef->SetComment(fullpath);
|
|
|
|
this->FileRefs[key] = fileRef;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-03-15 16:05:31 +00:00
|
|
|
cmXCodeObject* group = this->GroupMap[key];
|
|
|
|
cmXCodeObject* children = group->GetObject("children");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!children->HasObject(fileRef)) {
|
2012-03-15 16:05:31 +00:00
|
|
|
children->AddObject(fileRef);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-03-15 16:05:31 +00:00
|
|
|
fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
|
|
|
|
|
2014-05-15 17:50:26 +00:00
|
|
|
bool useLastKnownFileType = false;
|
|
|
|
std::string fileType;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (sf) {
|
|
|
|
if (const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
|
2014-05-15 17:50:53 +00:00
|
|
|
fileType = e;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE")) {
|
2014-05-15 17:50:53 +00:00
|
|
|
useLastKnownFileType = true;
|
|
|
|
fileType = l;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (fileType.empty()) {
|
2014-09-03 14:33:12 +00:00
|
|
|
// Compute the extension without leading '.'.
|
|
|
|
std::string ext = cmSystemTools::GetFilenameLastExtension(fullpath);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!ext.empty()) {
|
2014-09-03 14:33:12 +00:00
|
|
|
ext = ext.substr(1);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-09-03 14:33:12 +00:00
|
|
|
|
2014-05-15 17:50:26 +00:00
|
|
|
// If fullpath references a directory, then we need to specify
|
|
|
|
// lastKnownFileType as folder in order for Xcode to be able to
|
|
|
|
// open the contents of the folder.
|
|
|
|
// (Xcode 4.6 does not like explicitFileType=folder).
|
2016-09-04 14:55:05 +00:00
|
|
|
if (cmSystemTools::FileIsDirectory(fullpath)) {
|
2016-05-16 14:34:04 +00:00
|
|
|
fileType = (ext == "xcassets" ? "folder.assetcatalog" : "folder");
|
2014-05-15 17:50:26 +00:00
|
|
|
useLastKnownFileType = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
|
|
|
fileType =
|
|
|
|
GetSourcecodeValueFromFileExtension(ext, lang, useLastKnownFileType);
|
2013-10-21 14:46:25 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-09-05 19:51:19 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
fileRef->AddAttribute(useLastKnownFileType ? "lastKnownFileType"
|
|
|
|
: "explicitFileType",
|
2014-05-15 17:50:26 +00:00
|
|
|
this->CreateString(fileType));
|
|
|
|
|
2009-09-22 20:18:31 +00:00
|
|
|
// Store the file path relative to the top of the source tree.
|
2019-03-17 19:22:26 +00:00
|
|
|
std::string path = this->RelativeToSource(fullpath);
|
2016-09-04 14:55:05 +00:00
|
|
|
std::string name = cmSystemTools::GetFilenameName(path);
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* sourceTree =
|
2019-05-14 13:16:11 +00:00
|
|
|
cmSystemTools::FileIsFullPath(path) ? "<absolute>" : "SOURCE_ROOT";
|
2016-04-20 21:11:17 +00:00
|
|
|
fileRef->AddAttribute("name", this->CreateString(name));
|
|
|
|
fileRef->AddAttribute("path", this->CreateString(path));
|
2009-09-22 20:18:31 +00:00
|
|
|
fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
|
2008-10-09 15:01:48 +00:00
|
|
|
return fileRef;
|
2005-01-27 21:11:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference(
|
|
|
|
cmSourceFile* sf, cmGeneratorTarget* target)
|
2012-03-15 16:05:31 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
|
2012-03-15 16:05:31 +00:00
|
|
|
|
2019-11-05 19:20:21 +00:00
|
|
|
return this->CreateXCodeFileReferenceFromPath(sf->ResolveFullPath(), target,
|
2016-05-16 14:34:04 +00:00
|
|
|
lang, sf);
|
2012-03-15 16:05:31 +00:00
|
|
|
}
|
|
|
|
|
2005-02-18 18:32:51 +00:00
|
|
|
bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname)
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" ||
|
|
|
|
tname == "install" || tname == "package" || tname == "RUN_TESTS" ||
|
|
|
|
tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
|
|
|
|
if (this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) {
|
2005-02-18 18:32:51 +00:00
|
|
|
return true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-03-15 16:02:08 +00:00
|
|
|
this->TargetDoneSet.insert(tname);
|
2005-02-18 18:32:51 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-18 18:32:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-02-24 22:46:49 +00:00
|
|
|
void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
|
|
|
|
{
|
2006-03-15 16:02:08 +00:00
|
|
|
this->CurrentLocalGenerator = gen;
|
|
|
|
this->CurrentMakefile = gen->GetMakefile();
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// Select the current set of configuration types.
|
2006-03-15 16:02:08 +00:00
|
|
|
this->CurrentConfigurationTypes.clear();
|
2010-09-08 18:54:49 +00:00
|
|
|
this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->CurrentConfigurationTypes.empty()) {
|
2019-01-16 06:13:07 +00:00
|
|
|
this->CurrentConfigurationTypes.emplace_back();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-24 22:46:49 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 13:23:21 +00:00
|
|
|
struct cmSourceFilePathCompare
|
|
|
|
{
|
|
|
|
bool operator()(cmSourceFile* l, cmSourceFile* r)
|
|
|
|
{
|
2019-11-05 19:20:21 +00:00
|
|
|
return l->ResolveFullPath() < r->ResolveFullPath();
|
2013-02-16 13:23:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-01-16 22:37:26 +00:00
|
|
|
struct cmCompareTargets
|
|
|
|
{
|
2018-07-19 15:54:10 +00:00
|
|
|
bool operator()(cmXCodeObject* l, cmXCodeObject* r) const
|
2015-01-16 22:37:26 +00:00
|
|
|
{
|
2018-07-19 15:54:10 +00:00
|
|
|
std::string const& a = l->GetTarget()->GetName();
|
|
|
|
std::string const& b = r->GetTarget()->GetName();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (a == "ALL_BUILD") {
|
2015-01-16 22:37:26 +00:00
|
|
|
return true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (b == "ALL_BUILD") {
|
2015-01-16 22:37:26 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:54:10 +00:00
|
|
|
return a < b;
|
2015-01-16 22:37:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmGlobalXCodeGenerator::CreateXCodeTargets(
|
|
|
|
cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets)
|
2005-01-27 21:11:44 +00:00
|
|
|
{
|
2005-02-24 22:46:49 +00:00
|
|
|
this->SetCurrentLocalGenerator(gen);
|
2019-11-07 17:52:06 +00:00
|
|
|
std::vector<cmGeneratorTarget*> gts;
|
2019-12-09 16:39:29 +00:00
|
|
|
cm::append(gts, this->CurrentLocalGenerator->GetGeneratorTargets());
|
2018-07-19 16:47:45 +00:00
|
|
|
std::sort(gts.begin(), gts.end(),
|
|
|
|
[this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) {
|
|
|
|
return this->TargetOrderIndex[l] < this->TargetOrderIndex[r];
|
|
|
|
});
|
2018-07-19 15:54:10 +00:00
|
|
|
for (auto gtgt : gts) {
|
2018-07-19 15:51:43 +00:00
|
|
|
if (!this->CreateXCodeTarget(gtgt, targets)) {
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
}
|
2018-07-19 15:54:10 +00:00
|
|
|
std::sort(targets.begin(), targets.end(), cmCompareTargets());
|
2018-07-19 15:51:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-05-09 12:25:45 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
bool cmGlobalXCodeGenerator::CreateXCodeTarget(
|
|
|
|
cmGeneratorTarget* gtgt, std::vector<cmXCodeObject*>& targets)
|
|
|
|
{
|
|
|
|
std::string targetName = gtgt->GetName();
|
2012-11-02 14:47:40 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// make sure ALL_BUILD, INSTALL, etc are only done once
|
|
|
|
if (this->SpecialTargetEmitted(targetName)) {
|
|
|
|
return true;
|
|
|
|
}
|
2005-02-03 22:42:55 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gtgt->GetType() == cmStateEnums::UTILITY ||
|
|
|
|
gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
|
|
|
cmXCodeObject* t = this->CreateUtilityTarget(gtgt);
|
|
|
|
if (!t) {
|
2015-01-19 13:27:15 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
targets.push_back(t);
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-18 17:30:09 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// organize the sources
|
|
|
|
std::vector<cmSourceFile*> classes;
|
|
|
|
if (!gtgt->GetConfigCommonSourceFiles(classes)) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-18 17:30:09 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// Add CMakeLists.txt file for user convenience.
|
|
|
|
this->AddXCodeProjBuildRule(gtgt, classes);
|
2013-02-16 13:23:21 +00:00
|
|
|
|
2019-04-10 12:04:15 +00:00
|
|
|
// Add the Info.plist we are about to generate for an App Bundle.
|
|
|
|
if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
|
|
|
|
std::string plist = this->ComputeInfoPListLocation(gtgt);
|
2019-11-05 19:19:36 +00:00
|
|
|
cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
|
|
|
|
plist, true, cmSourceFileLocationKind::Known);
|
2019-04-10 12:04:15 +00:00
|
|
|
classes.push_back(sf);
|
|
|
|
}
|
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
|
2014-03-14 12:21:26 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
gtgt->ComputeObjectMapping();
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
std::vector<cmXCodeObject*> externalObjFiles;
|
|
|
|
std::vector<cmXCodeObject*> headerFiles;
|
|
|
|
std::vector<cmXCodeObject*> resourceFiles;
|
|
|
|
std::vector<cmXCodeObject*> sourceFiles;
|
|
|
|
for (auto sourceFile : classes) {
|
|
|
|
cmXCodeObject* xsf = this->CreateXCodeSourceFile(
|
|
|
|
this->CurrentLocalGenerator, sourceFile, gtgt);
|
|
|
|
cmXCodeObject* fr = xsf->GetObject("fileRef");
|
|
|
|
cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType");
|
2007-10-10 15:06:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
cmGeneratorTarget::SourceFileFlags tsFlags =
|
|
|
|
gtgt->GetTargetSourceFileFlags(sourceFile);
|
|
|
|
|
|
|
|
if (filetype && filetype->GetString() == "compiled.mach-o.objfile") {
|
|
|
|
if (sourceFile->GetObjectLibrary().empty()) {
|
|
|
|
externalObjFiles.push_back(xsf);
|
|
|
|
}
|
|
|
|
} else if (this->IsHeaderFile(sourceFile) ||
|
|
|
|
(tsFlags.Type ==
|
|
|
|
cmGeneratorTarget::SourceFileTypePrivateHeader) ||
|
|
|
|
(tsFlags.Type ==
|
|
|
|
cmGeneratorTarget::SourceFileTypePublicHeader)) {
|
|
|
|
headerFiles.push_back(xsf);
|
|
|
|
} else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) {
|
|
|
|
resourceFiles.push_back(xsf);
|
2019-11-09 03:28:18 +00:00
|
|
|
} else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY") &&
|
|
|
|
!gtgt->IsSourceFilePartOfUnityBatch(
|
|
|
|
sourceFile->ResolveFullPath())) {
|
2018-07-19 15:51:43 +00:00
|
|
|
// Include this file in the build if it has a known language
|
|
|
|
// and has not been listed as an ignored extension for this
|
|
|
|
// generator.
|
|
|
|
if (!this->CurrentLocalGenerator->GetSourceFileLanguage(*sourceFile)
|
|
|
|
.empty() &&
|
|
|
|
!this->IgnoreFile(sourceFile->GetExtension().c_str())) {
|
|
|
|
sourceFiles.push_back(xsf);
|
2005-01-27 21:11:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// some build phases only apply to bundles and/or frameworks
|
|
|
|
bool isFrameworkTarget = gtgt->IsFrameworkOnApple();
|
|
|
|
bool isBundleTarget = gtgt->GetPropertyAsBool("MACOSX_BUNDLE");
|
|
|
|
bool isCFBundleTarget = gtgt->IsCFBundleOnApple();
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
cmXCodeObject* buildFiles = nullptr;
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// create source build phase
|
|
|
|
cmXCodeObject* sourceBuildPhase = nullptr;
|
|
|
|
if (!sourceFiles.empty()) {
|
|
|
|
sourceBuildPhase = this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase);
|
|
|
|
sourceBuildPhase->SetComment("Sources");
|
|
|
|
sourceBuildPhase->AddAttribute("buildActionMask",
|
|
|
|
this->CreateString("2147483647"));
|
|
|
|
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
for (auto& sourceFile : sourceFiles) {
|
|
|
|
buildFiles->AddObject(sourceFile);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
sourceBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
|
|
|
this->CreateString("0"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// create header build phase - only for framework targets
|
|
|
|
cmXCodeObject* headerBuildPhase = nullptr;
|
|
|
|
if (!headerFiles.empty() && isFrameworkTarget) {
|
|
|
|
headerBuildPhase = this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase);
|
|
|
|
headerBuildPhase->SetComment("Headers");
|
|
|
|
headerBuildPhase->AddAttribute("buildActionMask",
|
|
|
|
this->CreateString("2147483647"));
|
|
|
|
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
for (auto& headerFile : headerFiles) {
|
|
|
|
buildFiles->AddObject(headerFile);
|
|
|
|
}
|
|
|
|
headerBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
|
|
|
this->CreateString("0"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// create resource build phase - only for framework or bundle targets
|
|
|
|
cmXCodeObject* resourceBuildPhase = nullptr;
|
|
|
|
if (!resourceFiles.empty() &&
|
|
|
|
(isFrameworkTarget || isBundleTarget || isCFBundleTarget)) {
|
|
|
|
resourceBuildPhase =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
|
|
|
|
resourceBuildPhase->SetComment("Resources");
|
|
|
|
resourceBuildPhase->AddAttribute("buildActionMask",
|
2007-08-14 15:45:15 +00:00
|
|
|
this->CreateString("2147483647"));
|
2018-07-19 15:51:43 +00:00
|
|
|
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
for (auto& resourceFile : resourceFiles) {
|
|
|
|
buildFiles->AddObject(resourceFile);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
resourceBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
|
|
|
this->CreateString("0"));
|
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// create vector of "non-resource content file" build phases - only for
|
|
|
|
// framework or bundle targets
|
|
|
|
std::vector<cmXCodeObject*> contentBuildPhases;
|
|
|
|
if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
|
2019-09-04 16:03:01 +00:00
|
|
|
using mapOfVectorOfSourceFiles =
|
|
|
|
std::map<std::string, std::vector<cmSourceFile*>>;
|
2018-07-19 15:51:43 +00:00
|
|
|
mapOfVectorOfSourceFiles bundleFiles;
|
|
|
|
for (auto sourceFile : classes) {
|
|
|
|
cmGeneratorTarget::SourceFileFlags tsFlags =
|
|
|
|
gtgt->GetTargetSourceFileFlags(sourceFile);
|
|
|
|
if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) {
|
|
|
|
bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-09 17:40:08 +00:00
|
|
|
for (auto const& keySources : bundleFiles) {
|
2018-07-19 15:51:43 +00:00
|
|
|
cmXCodeObject* copyFilesBuildPhase =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
|
|
|
|
copyFilesBuildPhase->SetComment("Copy files");
|
|
|
|
copyFilesBuildPhase->AddAttribute("buildActionMask",
|
|
|
|
this->CreateString("2147483647"));
|
|
|
|
copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
|
|
|
|
this->CreateString("6"));
|
|
|
|
std::ostringstream ostr;
|
|
|
|
if (gtgt->IsFrameworkOnApple()) {
|
|
|
|
// dstPath in frameworks is relative to Versions/<version>
|
|
|
|
ostr << keySources.first;
|
|
|
|
} else if (keySources.first != "MacOS") {
|
|
|
|
if (gtgt->Target->GetMakefile()->PlatformIsAppleEmbedded()) {
|
2017-11-07 07:41:47 +00:00
|
|
|
ostr << keySources.first;
|
2018-07-19 15:51:43 +00:00
|
|
|
} else {
|
|
|
|
// dstPath in bundles is relative to Contents/MacOS
|
|
|
|
ostr << "../" << keySources.first;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
copyFilesBuildPhase->AddAttribute("dstPath",
|
|
|
|
this->CreateString(ostr.str()));
|
|
|
|
copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
|
|
|
this->CreateString("0"));
|
|
|
|
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
copyFilesBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
for (auto sourceFile : keySources.second) {
|
|
|
|
cmXCodeObject* xsf = this->CreateXCodeSourceFile(
|
|
|
|
this->CurrentLocalGenerator, sourceFile, gtgt);
|
|
|
|
buildFiles->AddObject(xsf);
|
|
|
|
}
|
|
|
|
contentBuildPhases.push_back(copyFilesBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// create vector of "resource content file" build phases - only for
|
|
|
|
// framework or bundle targets
|
|
|
|
if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
|
2019-09-04 16:03:01 +00:00
|
|
|
using mapOfVectorOfSourceFiles =
|
|
|
|
std::map<std::string, std::vector<cmSourceFile*>>;
|
2018-07-19 15:51:43 +00:00
|
|
|
mapOfVectorOfSourceFiles bundleFiles;
|
|
|
|
for (auto sourceFile : classes) {
|
|
|
|
cmGeneratorTarget::SourceFileFlags tsFlags =
|
|
|
|
gtgt->GetTargetSourceFileFlags(sourceFile);
|
|
|
|
if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) {
|
|
|
|
bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
|
2017-02-26 21:12:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-09 17:40:08 +00:00
|
|
|
for (auto const& keySources : bundleFiles) {
|
2018-07-19 15:51:43 +00:00
|
|
|
cmXCodeObject* copyFilesBuildPhase =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
|
|
|
|
copyFilesBuildPhase->SetComment("Copy files");
|
|
|
|
copyFilesBuildPhase->AddAttribute("buildActionMask",
|
2007-08-14 15:45:15 +00:00
|
|
|
this->CreateString("2147483647"));
|
2018-07-19 15:51:43 +00:00
|
|
|
copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
|
|
|
|
this->CreateString("7"));
|
|
|
|
copyFilesBuildPhase->AddAttribute("dstPath",
|
|
|
|
this->CreateString(keySources.first));
|
|
|
|
copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
|
|
|
this->CreateString("0"));
|
2006-03-29 20:02:35 +00:00
|
|
|
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2018-07-19 15:51:43 +00:00
|
|
|
copyFilesBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
for (auto sourceFile : keySources.second) {
|
|
|
|
cmXCodeObject* xsf = this->CreateXCodeSourceFile(
|
|
|
|
this->CurrentLocalGenerator, sourceFile, gtgt);
|
|
|
|
buildFiles->AddObject(xsf);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
contentBuildPhases.push_back(copyFilesBuildPhase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// create framework build phase
|
|
|
|
cmXCodeObject* frameworkBuildPhase = nullptr;
|
|
|
|
if (!externalObjFiles.empty()) {
|
|
|
|
frameworkBuildPhase =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase);
|
|
|
|
frameworkBuildPhase->SetComment("Frameworks");
|
|
|
|
frameworkBuildPhase->AddAttribute("buildActionMask",
|
|
|
|
this->CreateString("2147483647"));
|
|
|
|
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
frameworkBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
for (auto& externalObjFile : externalObjFiles) {
|
|
|
|
buildFiles->AddObject(externalObjFile);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-07-19 15:51:43 +00:00
|
|
|
frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
|
|
|
this->CreateString("0"));
|
|
|
|
}
|
2007-05-24 21:06:32 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
// create list of build phases and create the Xcode target
|
|
|
|
cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
this->CreateCustomCommands(buildPhases, sourceBuildPhase, headerBuildPhase,
|
|
|
|
resourceBuildPhase, contentBuildPhases,
|
|
|
|
frameworkBuildPhase, gtgt);
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2018-07-19 15:51:43 +00:00
|
|
|
targets.push_back(this->CreateXCodeTarget(gtgt, buildPhases));
|
2015-01-19 13:27:15 +00:00
|
|
|
return true;
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
|
|
|
|
2009-07-10 20:51:44 +00:00
|
|
|
void cmGlobalXCodeGenerator::ForceLinkerLanguages()
|
|
|
|
{
|
2019-12-09 17:13:42 +00:00
|
|
|
for (const auto& localGenerator : this->LocalGenerators) {
|
2015-10-25 11:22:51 +00:00
|
|
|
// All targets depend on the build-system check target.
|
2019-11-07 17:52:06 +00:00
|
|
|
for (const auto& tgt : localGenerator->GetGeneratorTargets()) {
|
2015-10-25 11:22:51 +00:00
|
|
|
// This makes sure all targets link using the proper language.
|
2019-11-07 17:52:06 +00:00
|
|
|
this->ForceLinkerLanguage(tgt.get());
|
2009-07-10 20:51:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-10 20:51:44 +00:00
|
|
|
}
|
|
|
|
|
2015-10-21 18:38:10 +00:00
|
|
|
void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
|
2009-07-10 20:51:44 +00:00
|
|
|
{
|
|
|
|
// This matters only for targets that link.
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() != cmStateEnums::EXECUTABLE &&
|
|
|
|
gtgt->GetType() != cmStateEnums::SHARED_LIBRARY &&
|
|
|
|
gtgt->GetType() != cmStateEnums::MODULE_LIBRARY) {
|
2009-07-10 20:51:44 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-10 20:51:44 +00:00
|
|
|
|
2015-08-04 17:19:49 +00:00
|
|
|
std::string llang = gtgt->GetLinkerLanguage("NOCONFIG");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (llang.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
2009-07-10 20:51:44 +00:00
|
|
|
|
|
|
|
// If the language is compiled as a source trust Xcode to link with it.
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& Language :
|
|
|
|
gtgt->GetLinkImplementation("NOCONFIG")->Languages) {
|
2017-09-20 21:44:34 +00:00
|
|
|
if (Language == llang) {
|
2016-05-16 14:34:04 +00:00
|
|
|
return;
|
2009-07-10 20:51:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-10 20:51:44 +00:00
|
|
|
|
|
|
|
// Add an empty source file to the target that compiles with the
|
|
|
|
// linker language. This should convince Xcode to choose the proper
|
|
|
|
// language.
|
2015-10-21 18:38:10 +00:00
|
|
|
cmMakefile* mf = gtgt->Target->GetMakefile();
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string fname = cmStrCat(
|
|
|
|
gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/CMakeFiles/",
|
|
|
|
gtgt->GetName(), "-CMakeForceLinker.", cmSystemTools::LowerCase(llang));
|
2009-07-10 20:51:44 +00:00
|
|
|
{
|
2018-11-27 18:19:45 +00:00
|
|
|
cmGeneratedFileStream fout(fname);
|
2016-05-16 14:34:04 +00:00
|
|
|
fout << "\n";
|
2009-07-10 20:51:44 +00:00
|
|
|
}
|
2016-09-04 14:55:05 +00:00
|
|
|
if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) {
|
2014-02-04 02:20:56 +00:00
|
|
|
sf->SetProperty("LANGUAGE", llang.c_str());
|
2015-08-29 16:10:19 +00:00
|
|
|
gtgt->AddSource(fname);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-10 20:51:44 +00:00
|
|
|
}
|
|
|
|
|
2009-03-16 18:30:24 +00:00
|
|
|
bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
|
|
|
|
{
|
2019-08-19 12:31:52 +00:00
|
|
|
return cmContains(this->CMakeInstance->GetHeaderExtensions(),
|
|
|
|
sf->GetExtension());
|
2009-03-16 18:30:24 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase(
|
|
|
|
const char* name, const char* name2, cmGeneratorTarget* target,
|
|
|
|
const std::vector<cmCustomCommand>& commands)
|
2005-02-28 20:07:13 +00:00
|
|
|
{
|
2017-09-20 20:50:20 +00:00
|
|
|
if (commands.empty() && strcmp(name, "CMake ReRun") != 0) {
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2010-09-29 12:38:18 +00:00
|
|
|
cmXCodeObject* buildPhase =
|
2005-02-28 20:07:13 +00:00
|
|
|
this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase);
|
|
|
|
buildPhase->AddAttribute("buildActionMask",
|
2005-11-18 19:12:09 +00:00
|
|
|
this->CreateString("2147483647"));
|
2005-02-28 20:07:13 +00:00
|
|
|
cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
buildPhase->AddAttribute("files", buildFiles);
|
2016-05-16 14:34:04 +00:00
|
|
|
buildPhase->AddAttribute("name", this->CreateString(name));
|
2010-09-29 12:38:18 +00:00
|
|
|
buildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
2005-02-28 20:07:13 +00:00
|
|
|
this->CreateString("0"));
|
2016-05-16 14:34:04 +00:00
|
|
|
buildPhase->AddAttribute("shellPath", this->CreateString("/bin/sh"));
|
|
|
|
this->AddCommandsToBuildPhase(buildPhase, target, commands, name2);
|
2005-02-28 20:07:13 +00:00
|
|
|
return buildPhase;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::CreateCustomCommands(
|
|
|
|
cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
|
|
|
|
cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
|
2019-09-09 17:38:01 +00:00
|
|
|
std::vector<cmXCodeObject*> const& contentBuildPhases,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt)
|
|
|
|
{
|
|
|
|
std::vector<cmCustomCommand> const& prebuild = gtgt->GetPreBuildCommands();
|
|
|
|
std::vector<cmCustomCommand> const& prelink = gtgt->GetPreLinkCommands();
|
|
|
|
std::vector<cmCustomCommand> postbuild = gtgt->GetPostBuildCommands();
|
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY &&
|
2016-05-16 14:34:04 +00:00
|
|
|
!gtgt->IsFrameworkOnApple()) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string str_file = cmStrCat("$<TARGET_FILE:", gtgt->GetName(), '>');
|
|
|
|
std::string str_so_file =
|
|
|
|
cmStrCat("$<TARGET_SONAME_FILE:", gtgt->GetName(), '>');
|
|
|
|
std::string str_link_file =
|
|
|
|
cmStrCat("$<TARGET_LINKER_FILE:", gtgt->GetName(), '>');
|
2019-09-13 17:44:37 +00:00
|
|
|
cmCustomCommandLines cmd = cmMakeSingleCommandLine(
|
|
|
|
{ cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library",
|
|
|
|
str_file, str_so_file, str_link_file });
|
2013-05-14 02:45:35 +00:00
|
|
|
|
2019-10-17 14:15:44 +00:00
|
|
|
cmCustomCommand command(
|
|
|
|
std::vector<std::string>(), std::vector<std::string>(),
|
|
|
|
std::vector<std::string>(), cmd, this->CurrentMakefile->GetBacktrace(),
|
|
|
|
"Creating symlinks", "");
|
2013-05-14 02:45:35 +00:00
|
|
|
|
2019-10-17 14:15:44 +00:00
|
|
|
postbuild.push_back(std::move(command));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-05-14 02:45:35 +00:00
|
|
|
|
2013-07-14 16:22:57 +00:00
|
|
|
std::vector<cmSourceFile*> classes;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!gtgt->GetConfigCommonSourceFiles(classes)) {
|
2014-02-13 16:25:00 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-15 22:25:40 +00:00
|
|
|
// add all the sources
|
|
|
|
std::vector<cmCustomCommand> commands;
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto sourceFile : classes) {
|
|
|
|
if (sourceFile->GetCustomCommand()) {
|
|
|
|
commands.push_back(*sourceFile->GetCustomCommand());
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-15 22:25:40 +00:00
|
|
|
// create prebuild phase
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmakeRulesBuildPhase = this->CreateBuildPhase(
|
|
|
|
"CMake Rules", "cmakeRulesBuildPhase", gtgt, commands);
|
2005-02-15 22:25:40 +00:00
|
|
|
// create prebuild phase
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* preBuildPhase = this->CreateBuildPhase(
|
|
|
|
"CMake PreBuild Rules", "preBuildCommands", gtgt, prebuild);
|
2007-08-14 15:45:15 +00:00
|
|
|
// create prelink phase
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* preLinkPhase = this->CreateBuildPhase(
|
|
|
|
"CMake PreLink Rules", "preLinkCommands", gtgt, prelink);
|
2007-08-14 15:45:15 +00:00
|
|
|
// create postbuild phase
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* postBuildPhase = this->CreateBuildPhase(
|
|
|
|
"CMake PostBuild Rules", "postBuildPhase", gtgt, postbuild);
|
2007-08-14 15:45:15 +00:00
|
|
|
|
|
|
|
// The order here is the order they will be built in.
|
|
|
|
// The order "headers, resources, sources" mimics a native project generated
|
|
|
|
// from an xcode template...
|
|
|
|
//
|
2016-05-16 14:34:04 +00:00
|
|
|
if (preBuildPhase) {
|
2005-02-15 22:25:40 +00:00
|
|
|
buildPhases->AddObject(preBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (cmakeRulesBuildPhase) {
|
2005-02-15 22:25:40 +00:00
|
|
|
buildPhases->AddObject(cmakeRulesBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (headerBuildPhase) {
|
2005-01-27 21:11:44 +00:00
|
|
|
buildPhases->AddObject(headerBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (resourceBuildPhase) {
|
2007-08-14 15:45:15 +00:00
|
|
|
buildPhases->AddObject(resourceBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto obj : contentBuildPhases) {
|
|
|
|
buildPhases->AddObject(obj);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (sourceBuildPhase) {
|
2007-08-14 15:45:15 +00:00
|
|
|
buildPhases->AddObject(sourceBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (preLinkPhase) {
|
2005-02-15 22:25:40 +00:00
|
|
|
buildPhases->AddObject(preLinkPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (frameworkBuildPhase) {
|
2005-01-27 21:11:44 +00:00
|
|
|
buildPhases->AddObject(frameworkBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (postBuildPhase) {
|
2005-02-15 22:25:40 +00:00
|
|
|
buildPhases->AddObject(postBuildPhase);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-18 16:29:22 +00:00
|
|
|
// This function removes each occurrence of the flag and returns the last one
|
2011-08-18 17:30:51 +00:00
|
|
|
// (i.e., the dominant flag in GCC)
|
2005-09-02 20:29:32 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
|
|
|
|
std::string& flags)
|
|
|
|
{
|
|
|
|
std::string retFlag;
|
2013-01-18 16:29:22 +00:00
|
|
|
std::string::size_type lastOccurancePos = flags.rfind(flag);
|
2011-08-18 17:30:51 +00:00
|
|
|
bool saved = false;
|
2017-05-30 19:37:46 +00:00
|
|
|
while (lastOccurancePos != std::string::npos) {
|
2016-05-16 14:34:04 +00:00
|
|
|
// increment pos, we use lastOccurancePos to reduce search space on next
|
|
|
|
// inc
|
2013-01-18 16:29:22 +00:00
|
|
|
std::string::size_type pos = lastOccurancePos;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (pos == 0 || flags[pos - 1] == ' ') {
|
|
|
|
while (pos < flags.size() && flags[pos] != ' ') {
|
|
|
|
if (!saved) {
|
2011-08-18 17:30:51 +00:00
|
|
|
retFlag += flags[pos];
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-08-18 17:30:51 +00:00
|
|
|
flags[pos] = ' ';
|
|
|
|
pos++;
|
2013-01-18 16:29:22 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
saved = true;
|
2005-09-02 20:29:32 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
// decrement lastOccurancePos while making sure we don't loop around
|
|
|
|
// and become a very large positive number since size_type is unsigned
|
|
|
|
lastOccurancePos = lastOccurancePos == 0 ? 0 : lastOccurancePos - 1;
|
|
|
|
lastOccurancePos = flags.rfind(flag, lastOccurancePos);
|
|
|
|
}
|
2005-09-02 20:29:32 +00:00
|
|
|
return retFlag;
|
|
|
|
}
|
2007-05-09 12:25:45 +00:00
|
|
|
|
2015-10-18 19:53:12 +00:00
|
|
|
// This function removes each matching occurrence of the expression and
|
|
|
|
// returns the last one (i.e., the dominant flag in GCC)
|
|
|
|
std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
|
|
|
|
int matchIndex,
|
|
|
|
std::string& flags)
|
|
|
|
{
|
|
|
|
std::string retFlag;
|
|
|
|
|
|
|
|
cmsys::RegularExpression regex(exp);
|
|
|
|
assert(regex.is_valid());
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!regex.is_valid()) {
|
2015-10-18 19:53:12 +00:00
|
|
|
return retFlag;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-18 19:53:12 +00:00
|
|
|
|
|
|
|
std::string::size_type offset = 0;
|
|
|
|
|
2019-05-14 13:16:11 +00:00
|
|
|
while (regex.find(&flags[offset])) {
|
2015-10-18 19:53:12 +00:00
|
|
|
const std::string::size_type startPos = offset + regex.start(matchIndex);
|
|
|
|
const std::string::size_type endPos = offset + regex.end(matchIndex);
|
|
|
|
const std::string::size_type size = endPos - startPos;
|
|
|
|
|
|
|
|
offset = startPos + 1;
|
|
|
|
|
|
|
|
retFlag.assign(flags, startPos, size);
|
|
|
|
flags.replace(startPos, size, size, ' ');
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-18 19:53:12 +00:00
|
|
|
|
|
|
|
return retFlag;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2016-01-02 16:57:06 +00:00
|
|
|
// This function strips off Xcode attributes that do not target the current
|
|
|
|
// configuration
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::FilterConfigurationAttribute(
|
|
|
|
std::string const& configName, std::string& attribute)
|
2016-01-02 16:57:06 +00:00
|
|
|
{
|
|
|
|
// Handle [variant=<config>] condition explicitly here.
|
|
|
|
std::string::size_type beginVariant = attribute.find("[variant=");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (beginVariant == std::string::npos) {
|
2016-01-02 16:57:06 +00:00
|
|
|
// There is no variant in this attribute.
|
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-01-02 16:57:06 +00:00
|
|
|
|
2017-09-19 14:19:14 +00:00
|
|
|
std::string::size_type endVariant = attribute.find(']', beginVariant + 9);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (endVariant == std::string::npos) {
|
2016-01-02 16:57:06 +00:00
|
|
|
// There is no terminating bracket.
|
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-01-02 16:57:06 +00:00
|
|
|
|
|
|
|
// Compare the variant to the configuration.
|
|
|
|
std::string variant =
|
2016-05-16 14:34:04 +00:00
|
|
|
attribute.substr(beginVariant + 9, endVariant - beginVariant - 9);
|
|
|
|
if (variant == configName) {
|
2016-01-02 16:57:06 +00:00
|
|
|
// The variant matches the configuration so use this
|
|
|
|
// attribute but drop the [variant=<config>] condition.
|
2016-05-16 14:34:04 +00:00
|
|
|
attribute.erase(beginVariant, endVariant - beginVariant + 1);
|
|
|
|
} else {
|
2016-01-02 16:57:06 +00:00
|
|
|
// The variant does not match the configuration so
|
|
|
|
// do not use this attribute.
|
|
|
|
attribute.clear();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-01-02 16:57:06 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
|
|
|
|
cmXCodeObject* buildphase, cmGeneratorTarget* target,
|
|
|
|
std::vector<cmCustomCommand> const& commands, const char* name)
|
2005-02-15 22:25:40 +00:00
|
|
|
{
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string dir = cmStrCat(
|
|
|
|
this->CurrentLocalGenerator->GetCurrentBinaryDirectory(), "/CMakeScripts");
|
2019-05-14 13:16:11 +00:00
|
|
|
cmSystemTools::MakeDirectory(dir);
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string makefile =
|
|
|
|
cmStrCat(dir, '/', target->GetName(), '_', name, ".make");
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& currentConfig : this->CurrentConfigurationTypes) {
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateCustomRulesMakefile(makefile.c_str(), target, commands,
|
2017-11-07 07:41:47 +00:00
|
|
|
currentConfig);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2015-09-24 22:13:20 +00:00
|
|
|
std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
|
2018-02-14 15:50:14 +00:00
|
|
|
cdir = this->ConvertToRelativeForMake(cdir);
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string makecmd =
|
|
|
|
cmStrCat("make -C ", cdir, " -f ",
|
|
|
|
this->ConvertToRelativeForMake((makefile + "$CONFIGURATION")),
|
|
|
|
" OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\") all");
|
2016-05-16 14:34:04 +00:00
|
|
|
buildphase->AddAttribute("shellScript", this->CreateString(makecmd));
|
|
|
|
buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
|
2007-05-09 12:25:45 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
|
|
|
|
const char* makefileBasename, cmGeneratorTarget* target,
|
|
|
|
std::vector<cmCustomCommand> const& commands, const std::string& configName)
|
2007-05-09 12:25:45 +00:00
|
|
|
{
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string makefileName = cmStrCat(makefileBasename, configName);
|
2018-11-27 18:19:45 +00:00
|
|
|
cmGeneratedFileStream makefileStream(makefileName);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!makefileStream) {
|
2005-02-15 22:25:40 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-12-21 20:45:55 +00:00
|
|
|
makefileStream.SetCopyIfDifferent(true);
|
2005-02-15 22:25:40 +00:00
|
|
|
makefileStream << "# Generated by CMake, DO NOT EDIT\n";
|
2015-10-19 19:23:29 +00:00
|
|
|
makefileStream << "# Custom rules for " << target->GetName() << "\n";
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2011-01-11 22:34:06 +00:00
|
|
|
// disable the implicit rules
|
2016-05-16 14:34:04 +00:00
|
|
|
makefileStream << ".SUFFIXES: "
|
|
|
|
<< "\n";
|
2011-01-11 22:34:06 +00:00
|
|
|
|
2005-02-15 22:25:40 +00:00
|
|
|
// have all depend on all outputs
|
|
|
|
makefileStream << "all: ";
|
2014-02-10 05:21:34 +00:00
|
|
|
std::map<const cmCustomCommand*, std::string> tname;
|
2005-02-17 22:54:14 +00:00
|
|
|
int count = 0;
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& command : commands) {
|
|
|
|
cmCustomCommandGenerator ccg(command, configName,
|
|
|
|
this->CurrentLocalGenerator);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (ccg.GetNumberOfCommands() > 0) {
|
2014-03-10 19:47:19 +00:00
|
|
|
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!outputs.empty()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& output : outputs) {
|
2018-02-14 15:50:14 +00:00
|
|
|
makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(output);
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream str;
|
2016-05-16 14:34:04 +00:00
|
|
|
str << "_buildpart_" << count++;
|
2019-05-14 13:16:11 +00:00
|
|
|
tname[&ccg.GetCC()] = target->GetName() + str.str();
|
2014-03-10 19:47:19 +00:00
|
|
|
makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-15 22:25:40 +00:00
|
|
|
makefileStream << "\n\n";
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& command : commands) {
|
|
|
|
cmCustomCommandGenerator ccg(command, configName,
|
|
|
|
this->CurrentLocalGenerator);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (ccg.GetNumberOfCommands() > 0) {
|
2006-09-29 20:14:34 +00:00
|
|
|
makefileStream << "\n";
|
2014-03-10 19:47:19 +00:00
|
|
|
const std::vector<std::string>& outputs = ccg.GetOutputs();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!outputs.empty()) {
|
2007-05-09 12:25:45 +00:00
|
|
|
// There is at least one output, start the rule for it
|
2014-12-05 14:50:31 +00:00
|
|
|
const char* sep = "";
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& output : outputs) {
|
2018-02-14 15:50:14 +00:00
|
|
|
makefileStream << sep << this->ConvertToRelativeForMake(output);
|
2014-12-05 14:50:31 +00:00
|
|
|
sep = " ";
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
makefileStream << ": ";
|
|
|
|
} else {
|
2006-04-11 15:06:19 +00:00
|
|
|
// There are no outputs. Use the generated force rule name.
|
2014-03-10 19:47:19 +00:00
|
|
|
makefileStream << tname[&ccg.GetCC()] << ": ";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& d : ccg.GetDepends()) {
|
2010-12-08 21:51:16 +00:00
|
|
|
std::string dep;
|
2017-09-20 21:44:34 +00:00
|
|
|
if (this->CurrentLocalGenerator->GetRealDependency(d, configName,
|
2016-09-04 14:55:05 +00:00
|
|
|
dep)) {
|
2018-02-14 15:50:14 +00:00
|
|
|
makefileStream << "\\\n" << this->ConvertToRelativeForMake(dep);
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-15 22:25:40 +00:00
|
|
|
makefileStream << "\n";
|
2005-02-22 15:32:44 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (const char* comment = ccg.GetComment()) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string echo_cmd =
|
|
|
|
cmStrCat("echo ",
|
|
|
|
(this->CurrentLocalGenerator->EscapeForShell(
|
|
|
|
comment, ccg.GetCC().GetEscapeAllowMakeVars())));
|
2016-06-06 21:53:32 +00:00
|
|
|
makefileStream << "\t" << echo_cmd << "\n";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2007-12-18 14:50:08 +00:00
|
|
|
|
2005-02-22 15:32:44 +00:00
|
|
|
// Add each command line to the set of commands.
|
2016-05-16 14:34:04 +00:00
|
|
|
for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
|
2005-02-22 15:32:44 +00:00
|
|
|
// Build the command line in a single string.
|
2010-12-07 21:23:38 +00:00
|
|
|
std::string cmd2 = ccg.GetCommand(c);
|
2006-02-08 19:12:34 +00:00
|
|
|
cmSystemTools::ReplaceString(cmd2, "/./", "/");
|
2018-02-14 15:50:14 +00:00
|
|
|
cmd2 = this->ConvertToRelativeForMake(cmd2);
|
2006-02-08 19:12:34 +00:00
|
|
|
std::string cmd;
|
2014-03-10 19:47:19 +00:00
|
|
|
std::string wd = ccg.GetWorkingDirectory();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!wd.empty()) {
|
2006-02-08 19:12:34 +00:00
|
|
|
cmd += "cd ";
|
2018-02-14 15:50:14 +00:00
|
|
|
cmd += this->ConvertToRelativeForMake(wd);
|
2006-02-08 19:12:34 +00:00
|
|
|
cmd += " && ";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-02-08 19:12:34 +00:00
|
|
|
cmd += cmd2;
|
2010-12-07 21:23:38 +00:00
|
|
|
ccg.AppendArguments(c, cmd);
|
2016-06-06 21:53:32 +00:00
|
|
|
makefileStream << "\t" << cmd << "\n";
|
2005-02-15 22:25:40 +00:00
|
|
|
}
|
2005-01-27 21:11:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-01-28 22:21:35 +00:00
|
|
|
}
|
2005-02-01 18:07:42 +00:00
|
|
|
|
2018-10-02 15:34:57 +00:00
|
|
|
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(
|
2019-08-17 09:04:11 +00:00
|
|
|
"LD_NO_PIE", this->CreateString(cmIsOn(PICValue) ? "NO" : "YES"));
|
2018-10-02 15:34:57 +00:00
|
|
|
}
|
|
|
|
|
2015-10-19 19:23:29 +00:00
|
|
|
void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* buildSettings,
|
|
|
|
const std::string& configName)
|
2005-02-01 18:07:42 +00:00
|
|
|
{
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
2012-11-02 14:47:40 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-11-02 14:47:40 +00:00
|
|
|
|
2005-07-28 18:52:16 +00:00
|
|
|
std::string defFlags;
|
2016-10-18 19:28:46 +00:00
|
|
|
bool shared = ((gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) ||
|
|
|
|
(gtgt->GetType() == cmStateEnums::MODULE_LIBRARY));
|
|
|
|
bool binary = ((gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
|
|
|
|
(gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) ||
|
|
|
|
(gtgt->GetType() == cmStateEnums::EXECUTABLE) || shared);
|
2007-03-28 03:15:59 +00:00
|
|
|
|
2015-02-06 16:01:48 +00:00
|
|
|
// Compute the compilation flags for each language.
|
|
|
|
std::set<std::string> languages;
|
2015-08-05 15:37:50 +00:00
|
|
|
gtgt->GetLanguages(languages, configName);
|
2015-02-06 16:01:48 +00:00
|
|
|
std::map<std::string, std::string> cflags;
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& lang : languages) {
|
2015-02-06 16:01:48 +00:00
|
|
|
std::string& flags = cflags[lang];
|
2006-02-24 16:13:31 +00:00
|
|
|
|
2005-02-02 22:16:07 +00:00
|
|
|
// Add language-specific flags.
|
2017-04-27 20:15:07 +00:00
|
|
|
this->CurrentLocalGenerator->AddLanguageFlags(flags, gtgt, lang,
|
|
|
|
configName);
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2019-04-01 17:37:02 +00:00
|
|
|
if (gtgt->IsIPOEnabled(lang, configName)) {
|
|
|
|
this->CurrentLocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
|
|
|
|
}
|
|
|
|
|
2005-02-02 22:16:07 +00:00
|
|
|
// Add shared-library flags if needed.
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang,
|
|
|
|
configName);
|
2013-05-18 10:12:18 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt, lang);
|
2013-06-27 16:04:02 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->AddCompileOptions(flags, gtgt, lang,
|
|
|
|
configName);
|
|
|
|
}
|
2015-02-06 16:01:48 +00:00
|
|
|
|
2015-08-04 17:19:49 +00:00
|
|
|
std::string llang = gtgt->GetLinkerLanguage(configName);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (binary && llang.empty()) {
|
|
|
|
cmSystemTools::Error(
|
2019-05-14 13:16:11 +00:00
|
|
|
"CMake can not determine linker language for target: " +
|
|
|
|
gtgt->GetName());
|
2010-09-30 18:54:20 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2018-01-11 16:23:06 +00:00
|
|
|
std::string const& langForPreprocessor = llang;
|
2005-02-11 19:25:05 +00:00
|
|
|
|
2017-06-14 14:12:48 +00:00
|
|
|
if (gtgt->IsIPOEnabled(llang, configName)) {
|
2017-04-27 13:18:26 +00:00
|
|
|
const char* ltoValue =
|
|
|
|
this->CurrentMakefile->IsOn("_CMAKE_LTO_THIN") ? "YES_THIN" : "YES";
|
|
|
|
buildSettings->AddAttribute("LLVM_LTO", this->CreateString(ltoValue));
|
|
|
|
}
|
2017-03-09 13:05:19 +00:00
|
|
|
|
2018-10-02 15:34:57 +00:00
|
|
|
// Handle PIE linker configuration
|
|
|
|
this->AddPositionIndependentLinkAttribute(gtgt, buildSettings, configName);
|
|
|
|
|
2005-02-14 21:46:32 +00:00
|
|
|
// Add define flags
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->AppendFlags(
|
|
|
|
defFlags, this->CurrentMakefile->GetDefineFlags());
|
2008-01-14 14:20:58 +00:00
|
|
|
|
|
|
|
// Add preprocessor definitions for this target and configuration.
|
2017-04-21 16:57:11 +00:00
|
|
|
BuildObjectListOrString ppDefs(this, true);
|
|
|
|
this->AppendDefines(
|
|
|
|
ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
|
2018-10-14 23:00:34 +00:00
|
|
|
if (const std::string* exportMacro = gtgt->GetExportMacro()) {
|
2008-01-14 14:20:58 +00:00
|
|
|
// Add the export symbol definition for shared library objects.
|
2018-10-14 23:00:34 +00:00
|
|
|
this->AppendDefines(ppDefs, exportMacro->c_str());
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-06 16:13:35 +00:00
|
|
|
std::vector<std::string> targetDefines;
|
2018-01-11 16:23:06 +00:00
|
|
|
if (!langForPreprocessor.empty()) {
|
|
|
|
gtgt->GetCompileDefinitions(targetDefines, configName,
|
|
|
|
langForPreprocessor);
|
|
|
|
}
|
2013-06-06 16:13:35 +00:00
|
|
|
this->AppendDefines(ppDefs, targetDefines);
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("GCC_PREPROCESSOR_DEFINITIONS",
|
|
|
|
ppDefs.CreateList());
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2013-05-22 12:44:00 +00:00
|
|
|
std::string extraLinkOptionsVar;
|
2005-12-19 16:29:57 +00:00
|
|
|
std::string extraLinkOptions;
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::EXECUTABLE) {
|
2013-05-22 12:44:00 +00:00
|
|
|
extraLinkOptionsVar = "CMAKE_EXE_LINKER_FLAGS";
|
2016-10-18 19:28:46 +00:00
|
|
|
} else if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) {
|
2013-05-22 12:44:00 +00:00
|
|
|
extraLinkOptionsVar = "CMAKE_SHARED_LINKER_FLAGS";
|
2016-10-18 19:28:46 +00:00
|
|
|
} else if (gtgt->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
2013-05-22 12:44:00 +00:00
|
|
|
extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!extraLinkOptionsVar.empty()) {
|
|
|
|
this->CurrentLocalGenerator->AddConfigVariableFlags(
|
2016-09-04 14:55:05 +00:00
|
|
|
extraLinkOptions, extraLinkOptionsVar, configName);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2010-05-28 17:23:31 +00:00
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
|
|
|
|
gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) {
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->GetStaticLibraryFlags(
|
2018-08-15 13:20:18 +00:00
|
|
|
extraLinkOptions, cmSystemTools::UpperCase(configName), llang, gtgt);
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2015-10-21 18:36:59 +00:00
|
|
|
const char* targetLinkFlags = gtgt->GetProperty("LINK_FLAGS");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (targetLinkFlags) {
|
|
|
|
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions,
|
|
|
|
targetLinkFlags);
|
|
|
|
}
|
|
|
|
if (!configName.empty()) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string linkFlagsVar =
|
|
|
|
cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(configName));
|
2016-09-04 14:55:05 +00:00
|
|
|
if (const char* linkFlags = gtgt->GetProperty(linkFlagsVar)) {
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, linkFlags);
|
2009-11-06 13:04:19 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-24 15:01:01 +00:00
|
|
|
std::vector<std::string> opts;
|
|
|
|
gtgt->GetLinkOptions(opts, configName, llang);
|
|
|
|
// LINK_OPTIONS are escaped.
|
|
|
|
this->CurrentLocalGenerator->AppendCompileOptions(extraLinkOptions, opts);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-12-19 16:29:57 +00:00
|
|
|
|
2009-10-21 17:00:49 +00:00
|
|
|
// Set target-specific architectures.
|
|
|
|
std::vector<std::string> archs;
|
2012-09-15 23:16:43 +00:00
|
|
|
gtgt->GetAppleArchs(configName, archs);
|
2012-09-21 06:51:42 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!archs.empty()) {
|
2009-10-21 17:00:49 +00:00
|
|
|
// Enable ARCHS attribute.
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("NO"));
|
2009-10-21 17:00:49 +00:00
|
|
|
|
|
|
|
// Store ARCHS value.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (archs.size() == 1) {
|
|
|
|
buildSettings->AddAttribute("ARCHS", this->CreateString(archs[0]));
|
|
|
|
} else {
|
2009-10-21 17:00:49 +00:00
|
|
|
cmXCodeObject* archObjects =
|
|
|
|
this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& arch : archs) {
|
|
|
|
archObjects->AddObject(this->CreateString(arch));
|
2009-10-21 17:00:49 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("ARCHS", archObjects);
|
2009-10-21 17:00:49 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-10-21 17:00:49 +00:00
|
|
|
|
2006-01-13 23:18:32 +00:00
|
|
|
// Get the product name components.
|
|
|
|
std::string pnprefix;
|
|
|
|
std::string pnbase;
|
|
|
|
std::string pnsuffix;
|
2015-08-04 17:19:47 +00:00
|
|
|
gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName);
|
2006-01-13 23:18:32 +00:00
|
|
|
|
2015-10-21 18:36:59 +00:00
|
|
|
const char* version = gtgt->GetProperty("VERSION");
|
|
|
|
const char* soversion = gtgt->GetProperty("SOVERSION");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) {
|
2017-09-18 21:57:50 +00:00
|
|
|
version = nullptr;
|
|
|
|
soversion = nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (version && !soversion) {
|
2013-05-14 02:45:35 +00:00
|
|
|
soversion = version;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!version && soversion) {
|
2013-05-14 02:45:35 +00:00
|
|
|
version = soversion;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-05-14 02:45:35 +00:00
|
|
|
|
|
|
|
std::string realName = pnbase;
|
|
|
|
std::string soName = pnbase;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (version && soversion) {
|
2013-05-14 02:45:35 +00:00
|
|
|
realName += ".";
|
|
|
|
realName += version;
|
|
|
|
soName += ".";
|
|
|
|
soName += soversion;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-05-14 02:45:35 +00:00
|
|
|
|
2006-01-13 23:18:32 +00:00
|
|
|
// Set attributes to specify the proper name for the target.
|
2015-09-24 22:13:20 +00:00
|
|
|
std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
|
|
|
gtgt->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
|
|
|
gtgt->GetType() == cmStateEnums::MODULE_LIBRARY ||
|
|
|
|
gtgt->GetType() == cmStateEnums::EXECUTABLE) {
|
2017-04-21 16:57:11 +00:00
|
|
|
if (!gtgt->UsesDefaultOutputDir(configName,
|
|
|
|
cmStateEnums::RuntimeBinaryArtifact)) {
|
|
|
|
std::string pncdir = gtgt->GetDirectory(configName);
|
|
|
|
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
|
|
|
|
this->CreateString(pncdir));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-03-15 18:31:32 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) {
|
2013-05-06 02:19:05 +00:00
|
|
|
pnprefix = "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-05-06 02:19:05 +00:00
|
|
|
|
2010-09-29 12:38:18 +00:00
|
|
|
buildSettings->AddAttribute("EXECUTABLE_PREFIX",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(pnprefix));
|
2010-09-29 12:38:18 +00:00
|
|
|
buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(pnsuffix));
|
2016-10-18 19:28:46 +00:00
|
|
|
} else if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
|
2012-03-15 18:31:32 +00:00
|
|
|
pnprefix = "lib";
|
2015-10-21 18:36:59 +00:00
|
|
|
pnbase = gtgt->GetName();
|
2012-03-15 18:31:32 +00:00
|
|
|
pnsuffix = ".a";
|
|
|
|
|
2019-01-30 14:33:35 +00:00
|
|
|
std::string pncdir = this->GetObjectsDirectory(
|
|
|
|
this->CurrentProject, configName, gtgt, OBJECT_LIBRARY_ARTIFACT_DIR);
|
2017-04-21 16:57:11 +00:00
|
|
|
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
|
|
|
|
this->CreateString(pncdir));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-03-15 18:31:32 +00:00
|
|
|
|
|
|
|
// Store the product name for all target types.
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("PRODUCT_NAME", this->CreateString(realName));
|
|
|
|
buildSettings->AddAttribute("SYMROOT", this->CreateString(pndir));
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// Handle settings for each target type.
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (gtgt->GetType()) {
|
2016-12-26 17:07:24 +00:00
|
|
|
case cmStateEnums::STATIC_LIBRARY:
|
|
|
|
if (gtgt->GetPropertyAsBool("FRAMEWORK")) {
|
|
|
|
std::string fw_version = gtgt->GetFrameworkVersion();
|
|
|
|
buildSettings->AddAttribute("FRAMEWORK_VERSION",
|
|
|
|
this->CreateString(fw_version));
|
|
|
|
const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (ext) {
|
|
|
|
buildSettings->AddAttribute("WRAPPER_EXTENSION",
|
|
|
|
this->CreateString(ext));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string plist = this->ComputeInfoPListLocation(gtgt);
|
|
|
|
// Xcode will create the final version of Info.plist at build time,
|
|
|
|
// so let it replace the framework name. This avoids creating
|
|
|
|
// a per-configuration Info.plist file.
|
|
|
|
this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
|
2019-02-18 14:54:51 +00:00
|
|
|
gtgt, "$(EXECUTABLE_NAME)", plist);
|
2016-12-26 17:07:24 +00:00
|
|
|
buildSettings->AddAttribute("INFOPLIST_FILE",
|
|
|
|
this->CreateString(plist));
|
|
|
|
buildSettings->AddAttribute("MACH_O_TYPE",
|
|
|
|
this->CreateString("staticlib"));
|
|
|
|
} else {
|
|
|
|
buildSettings->AddAttribute("LIBRARY_STYLE",
|
|
|
|
this->CreateString("STATIC"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cmStateEnums::OBJECT_LIBRARY: {
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("LIBRARY_STYLE",
|
|
|
|
this->CreateString("STATIC"));
|
|
|
|
break;
|
2005-11-18 19:12:09 +00:00
|
|
|
}
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::MODULE_LIBRARY: {
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("LIBRARY_STYLE",
|
|
|
|
this->CreateString("BUNDLE"));
|
|
|
|
if (gtgt->IsCFBundleOnApple()) {
|
|
|
|
// It turns out that a BUNDLE is basically the same
|
|
|
|
// in many ways as an application bundle, as far as
|
|
|
|
// link flags go
|
|
|
|
std::string createFlags = this->LookupFlags(
|
|
|
|
"CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS", "-bundle");
|
|
|
|
if (!createFlags.empty()) {
|
|
|
|
extraLinkOptions += " ";
|
|
|
|
extraLinkOptions += createFlags;
|
2010-10-07 02:43:04 +00:00
|
|
|
}
|
2016-06-18 20:59:40 +00:00
|
|
|
const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (ext) {
|
|
|
|
buildSettings->AddAttribute("WRAPPER_EXTENSION",
|
|
|
|
this->CreateString(ext));
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string plist = this->ComputeInfoPListLocation(gtgt);
|
|
|
|
// Xcode will create the final version of Info.plist at build time,
|
|
|
|
// so let it replace the cfbundle name. This avoids creating
|
|
|
|
// a per-configuration Info.plist file. The cfbundle plist
|
|
|
|
// is very similar to the application bundle plist
|
|
|
|
this->CurrentLocalGenerator->GenerateAppleInfoPList(
|
2019-02-18 14:54:51 +00:00
|
|
|
gtgt, "$(EXECUTABLE_NAME)", plist);
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("INFOPLIST_FILE",
|
|
|
|
this->CreateString(plist));
|
2017-04-21 16:57:11 +00:00
|
|
|
} else {
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("MACH_O_TYPE",
|
|
|
|
this->CreateString("mh_bundle"));
|
|
|
|
buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC",
|
|
|
|
this->CreateString("NO"));
|
|
|
|
// Add the flags to create an executable.
|
|
|
|
std::string createFlags =
|
|
|
|
this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
|
|
|
|
if (!createFlags.empty()) {
|
|
|
|
extraLinkOptions += " ";
|
|
|
|
extraLinkOptions += createFlags;
|
|
|
|
}
|
2005-02-14 21:46:32 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
break;
|
2005-11-18 19:12:09 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::SHARED_LIBRARY: {
|
2016-05-16 14:34:04 +00:00
|
|
|
if (gtgt->GetPropertyAsBool("FRAMEWORK")) {
|
|
|
|
std::string fw_version = gtgt->GetFrameworkVersion();
|
|
|
|
buildSettings->AddAttribute("FRAMEWORK_VERSION",
|
|
|
|
this->CreateString(fw_version));
|
2016-06-19 19:26:40 +00:00
|
|
|
const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (ext) {
|
|
|
|
buildSettings->AddAttribute("WRAPPER_EXTENSION",
|
|
|
|
this->CreateString(ext));
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
|
|
|
|
std::string plist = this->ComputeInfoPListLocation(gtgt);
|
|
|
|
// Xcode will create the final version of Info.plist at build time,
|
|
|
|
// so let it replace the framework name. This avoids creating
|
|
|
|
// a per-configuration Info.plist file.
|
|
|
|
this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
|
2019-02-18 14:54:51 +00:00
|
|
|
gtgt, "$(EXECUTABLE_NAME)", plist);
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("INFOPLIST_FILE",
|
|
|
|
this->CreateString(plist));
|
|
|
|
} else {
|
|
|
|
// Add the flags to create a shared library.
|
|
|
|
std::string createFlags = this->LookupFlags(
|
|
|
|
"CMAKE_SHARED_LIBRARY_CREATE_", llang, "_FLAGS", "-dynamiclib");
|
|
|
|
if (!createFlags.empty()) {
|
|
|
|
extraLinkOptions += " ";
|
|
|
|
extraLinkOptions += createFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildSettings->AddAttribute("LIBRARY_STYLE",
|
|
|
|
this->CreateString("DYNAMIC"));
|
|
|
|
break;
|
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::EXECUTABLE: {
|
2016-05-16 14:34:04 +00:00
|
|
|
// Add the flags to create an executable.
|
2007-08-14 15:45:15 +00:00
|
|
|
std::string createFlags =
|
2016-05-16 14:34:04 +00:00
|
|
|
this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
|
|
|
|
if (!createFlags.empty()) {
|
2007-08-14 15:45:15 +00:00
|
|
|
extraLinkOptions += " ";
|
|
|
|
extraLinkOptions += createFlags;
|
2006-02-24 18:13:14 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
// Handle bundles and normal executables separately.
|
|
|
|
if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
|
2016-06-19 18:30:00 +00:00
|
|
|
const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
|
|
|
|
if (ext) {
|
|
|
|
buildSettings->AddAttribute("WRAPPER_EXTENSION",
|
|
|
|
this->CreateString(ext));
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string plist = this->ComputeInfoPListLocation(gtgt);
|
|
|
|
// Xcode will create the final version of Info.plist at build time,
|
|
|
|
// so let it replace the executable name. This avoids creating
|
|
|
|
// a per-configuration Info.plist file.
|
|
|
|
this->CurrentLocalGenerator->GenerateAppleInfoPList(
|
2019-02-18 14:54:51 +00:00
|
|
|
gtgt, "$(EXECUTABLE_NAME)", plist);
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("INFOPLIST_FILE",
|
|
|
|
this->CreateString(plist));
|
|
|
|
}
|
|
|
|
} break;
|
2006-01-13 23:18:32 +00:00
|
|
|
default:
|
2005-02-02 22:16:07 +00:00
|
|
|
break;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-06-29 17:02:05 +00:00
|
|
|
|
2017-04-21 16:57:11 +00:00
|
|
|
BuildObjectListOrString dirs(this, true);
|
|
|
|
BuildObjectListOrString fdirs(this, true);
|
|
|
|
BuildObjectListOrString sysdirs(this, true);
|
|
|
|
BuildObjectListOrString sysfdirs(this, true);
|
2017-04-19 20:17:35 +00:00
|
|
|
const bool emitSystemIncludes = this->XcodeVersion >= 83;
|
|
|
|
|
2016-11-23 17:19:54 +00:00
|
|
|
std::vector<std::string> includes;
|
2018-01-11 19:32:13 +00:00
|
|
|
if (!langForPreprocessor.empty()) {
|
|
|
|
this->CurrentLocalGenerator->GetIncludeDirectories(
|
|
|
|
includes, gtgt, langForPreprocessor, configName);
|
|
|
|
}
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> emitted;
|
2007-03-30 14:53:02 +00:00
|
|
|
emitted.insert("/System/Library/Frameworks");
|
2015-08-31 20:33:37 +00:00
|
|
|
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& include : includes) {
|
|
|
|
if (this->NameResolvesToFramework(include)) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string frameworkDir = cmStrCat(include, "/../");
|
2016-11-23 17:19:54 +00:00
|
|
|
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
|
|
|
|
if (emitted.insert(frameworkDir).second) {
|
2017-04-19 20:17:35 +00:00
|
|
|
std::string incpath = this->XCodeEscapePath(frameworkDir);
|
|
|
|
if (emitSystemIncludes &&
|
2018-03-12 15:37:11 +00:00
|
|
|
gtgt->IsSystemIncludeDirectory(frameworkDir, configName,
|
|
|
|
langForPreprocessor)) {
|
2017-04-19 20:17:35 +00:00
|
|
|
sysfdirs.Add(incpath);
|
|
|
|
} else {
|
|
|
|
fdirs.Add(incpath);
|
|
|
|
}
|
2005-12-27 19:56:56 +00:00
|
|
|
}
|
2016-11-23 17:19:54 +00:00
|
|
|
} else {
|
2017-09-20 21:44:34 +00:00
|
|
|
std::string incpath = this->XCodeEscapePath(include);
|
2017-04-19 20:17:35 +00:00
|
|
|
if (emitSystemIncludes &&
|
2018-03-12 15:37:11 +00:00
|
|
|
gtgt->IsSystemIncludeDirectory(include, configName,
|
|
|
|
langForPreprocessor)) {
|
2017-04-19 20:17:35 +00:00
|
|
|
sysdirs.Add(incpath);
|
|
|
|
} else {
|
|
|
|
dirs.Add(incpath);
|
|
|
|
}
|
2005-12-27 19:56:56 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 13:49:40 +00:00
|
|
|
// Add framework search paths needed for linking.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) {
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& fwDir : cli->GetFrameworkPaths()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
if (emitted.insert(fwDir).second) {
|
|
|
|
std::string incpath = this->XCodeEscapePath(fwDir);
|
2017-04-19 20:17:35 +00:00
|
|
|
if (emitSystemIncludes &&
|
2018-03-12 15:37:11 +00:00
|
|
|
gtgt->IsSystemIncludeDirectory(fwDir, configName,
|
|
|
|
langForPreprocessor)) {
|
2017-04-19 20:17:35 +00:00
|
|
|
sysfdirs.Add(incpath);
|
|
|
|
} else {
|
|
|
|
fdirs.Add(incpath);
|
|
|
|
}
|
2005-12-27 19:56:56 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!fdirs.IsEmpty()) {
|
|
|
|
buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", fdirs.CreateList());
|
|
|
|
}
|
|
|
|
if (!dirs.IsEmpty()) {
|
|
|
|
buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList());
|
|
|
|
}
|
2017-04-19 20:17:35 +00:00
|
|
|
if (!sysfdirs.IsEmpty()) {
|
|
|
|
buildSettings->AddAttribute("SYSTEM_FRAMEWORK_SEARCH_PATHS",
|
|
|
|
sysfdirs.CreateList());
|
|
|
|
}
|
|
|
|
if (!sysdirs.IsEmpty()) {
|
|
|
|
buildSettings->AddAttribute("SYSTEM_HEADER_SEARCH_PATHS",
|
|
|
|
sysdirs.CreateList());
|
|
|
|
}
|
2015-02-06 16:01:48 +00:00
|
|
|
|
2017-04-19 20:17:35 +00:00
|
|
|
if (this->XcodeVersion >= 60 && !emitSystemIncludes) {
|
2016-12-27 21:18:30 +00:00
|
|
|
// Add those per-language flags in addition to HEADER_SEARCH_PATHS to gain
|
|
|
|
// system include directory awareness. We need to also keep on setting
|
|
|
|
// HEADER_SEARCH_PATHS to work around a missing compile options flag for
|
|
|
|
// GNU assembly files (#16449)
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& language : languages) {
|
2016-12-27 21:18:30 +00:00
|
|
|
std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags(
|
2017-09-20 21:44:34 +00:00
|
|
|
includes, gtgt, language, true, false, configName);
|
2016-12-27 21:18:30 +00:00
|
|
|
|
|
|
|
if (!includeFlags.empty()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
cflags[language] += " " + includeFlags;
|
2016-12-27 21:18:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-06 16:01:48 +00:00
|
|
|
bool same_gflags = true;
|
|
|
|
std::map<std::string, std::string> gflags;
|
2017-09-18 21:57:50 +00:00
|
|
|
std::string const* last_gflag = nullptr;
|
2015-10-18 19:53:12 +00:00
|
|
|
std::string optLevel = "0";
|
2015-02-06 16:01:48 +00:00
|
|
|
|
|
|
|
// Minimal map of flags to build settings.
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& language : languages) {
|
|
|
|
std::string& flags = cflags[language];
|
|
|
|
std::string& gflag = gflags[language];
|
2015-10-18 19:53:12 +00:00
|
|
|
std::string oflag =
|
|
|
|
this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (oflag.size() == 2) {
|
2015-10-18 19:53:12 +00:00
|
|
|
optLevel = "1";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (oflag.size() > 2) {
|
2015-10-18 19:53:12 +00:00
|
|
|
optLevel = oflag.substr(2);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-06 16:01:48 +00:00
|
|
|
gflag = this->ExtractFlag("-g", flags);
|
|
|
|
// put back gdwarf-2 if used since there is no way
|
|
|
|
// to represent it in the gui, but we still want debug yes
|
2016-05-16 14:34:04 +00:00
|
|
|
if (gflag == "-gdwarf-2") {
|
2015-02-06 16:01:48 +00:00
|
|
|
flags += " ";
|
|
|
|
flags += gflag;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (last_gflag && *last_gflag != gflag) {
|
2015-02-06 16:01:48 +00:00
|
|
|
same_gflags = false;
|
2006-10-13 15:53:12 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
last_gflag = &gflag;
|
|
|
|
}
|
2015-02-06 16:01:48 +00:00
|
|
|
|
2005-09-02 20:29:32 +00:00
|
|
|
const char* debugStr = "YES";
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!same_gflags) {
|
2015-02-06 16:01:48 +00:00
|
|
|
// We can't set the Xcode flag differently depending on the language,
|
|
|
|
// so put them back in this case.
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& language : languages) {
|
|
|
|
cflags[language] += " ";
|
|
|
|
cflags[language] += gflags[language];
|
2011-08-18 17:30:51 +00:00
|
|
|
}
|
2005-09-02 20:29:32 +00:00
|
|
|
debugStr = "NO";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0")) {
|
|
|
|
debugStr = "NO";
|
|
|
|
}
|
2007-09-10 14:22:19 +00:00
|
|
|
|
2019-02-05 13:23:31 +00:00
|
|
|
// extract C++ stdlib
|
|
|
|
for (auto const& language : languages) {
|
2019-11-09 12:45:18 +00:00
|
|
|
if (language != "CXX" && language != "OBJCXX") {
|
2019-02-05 13:23:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::string& flags = cflags[language];
|
|
|
|
|
|
|
|
auto stdlib =
|
|
|
|
this->ExtractFlagRegex("(^| )(-stdlib=[^ ]+)( |$)", 2, flags);
|
|
|
|
if (stdlib.size() > 8) {
|
|
|
|
const auto cxxLibrary = stdlib.substr(8);
|
2019-11-09 12:45:18 +00:00
|
|
|
if (language == "CXX" ||
|
|
|
|
!buildSettings->GetObject("CLANG_CXX_LIBRARY")) {
|
|
|
|
buildSettings->AddAttribute("CLANG_CXX_LIBRARY",
|
|
|
|
this->CreateString(cxxLibrary));
|
|
|
|
}
|
2019-02-05 13:23:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-26 16:36:22 +00:00
|
|
|
buildSettings->AddAttribute("COMBINE_HIDPI_IMAGES",
|
|
|
|
this->CreateString("YES"));
|
2005-09-02 20:29:32 +00:00
|
|
|
buildSettings->AddAttribute("GCC_GENERATE_DEBUGGING_SYMBOLS",
|
|
|
|
this->CreateString(debugStr));
|
2010-09-29 12:38:18 +00:00
|
|
|
buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL",
|
2005-09-02 20:29:32 +00:00
|
|
|
this->CreateString(optLevel));
|
2006-07-27 19:02:35 +00:00
|
|
|
buildSettings->AddAttribute("GCC_SYMBOLS_PRIVATE_EXTERN",
|
|
|
|
this->CreateString("NO"));
|
|
|
|
buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
|
|
|
|
this->CreateString("NO"));
|
2019-11-09 12:45:18 +00:00
|
|
|
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& language : languages) {
|
|
|
|
std::string flags = cflags[language] + " " + defFlags;
|
2019-11-09 12:45:18 +00:00
|
|
|
if (language == "CXX" || language == "OBJCXX") {
|
|
|
|
if (language == "CXX" ||
|
|
|
|
!buildSettings->GetObject("OTHER_CPLUSPLUSFLAGS")) {
|
|
|
|
buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
|
|
|
|
this->CreateString(flags));
|
|
|
|
}
|
2017-09-20 21:44:34 +00:00
|
|
|
} else if (language == "Fortran") {
|
2015-02-06 16:02:48 +00:00
|
|
|
buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(flags));
|
2019-11-09 12:45:18 +00:00
|
|
|
} else if (language == "C" || language == "OBJC") {
|
|
|
|
if (language == "C" || !buildSettings->GetObject("OTHER_CFLAGS")) {
|
|
|
|
buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
|
|
|
|
}
|
2017-09-20 21:44:34 +00:00
|
|
|
} else if (language == "Swift") {
|
2015-08-31 20:33:37 +00:00
|
|
|
buildSettings->AddAttribute("OTHER_SWIFT_FLAGS",
|
|
|
|
this->CreateString(flags));
|
2005-07-28 18:52:16 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-02-24 18:13:14 +00:00
|
|
|
|
2011-09-01 14:52:51 +00:00
|
|
|
// Add Fortran source format attribute if property is set.
|
2017-09-18 21:57:50 +00:00
|
|
|
const char* format = nullptr;
|
2015-10-21 18:36:59 +00:00
|
|
|
const char* tgtfmt = gtgt->GetProperty("Fortran_FORMAT");
|
2016-06-05 21:44:39 +00:00
|
|
|
switch (cmOutputConverter::GetFortranFormat(tgtfmt)) {
|
2016-05-19 21:11:40 +00:00
|
|
|
case cmOutputConverter::FortranFormatFixed:
|
2016-05-16 14:34:04 +00:00
|
|
|
format = "fixed";
|
|
|
|
break;
|
2016-05-19 21:11:40 +00:00
|
|
|
case cmOutputConverter::FortranFormatFree:
|
2016-05-16 14:34:04 +00:00
|
|
|
format = "free";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (format) {
|
2011-09-01 14:52:51 +00:00
|
|
|
buildSettings->AddAttribute("IFORT_LANG_SRCFMT",
|
|
|
|
this->CreateString(format));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-09-01 14:52:51 +00:00
|
|
|
|
2006-02-24 18:13:14 +00:00
|
|
|
// Create the INSTALL_PATH attribute.
|
|
|
|
std::string install_name_dir;
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) {
|
2006-10-11 16:41:17 +00:00
|
|
|
// Get the install_name directory for the build tree.
|
2015-08-04 17:19:47 +00:00
|
|
|
install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName);
|
2013-05-14 02:45:35 +00:00
|
|
|
// Xcode doesn't create the correct install_name in some cases.
|
|
|
|
// That is, if the INSTALL_PATH is empty, or if we have versioning
|
|
|
|
// of dylib libraries, we want to specify the install_name.
|
|
|
|
// This is done by adding a link flag to create an install_name
|
|
|
|
// with just the library soname.
|
|
|
|
std::string install_name;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!install_name_dir.empty()) {
|
2006-02-24 18:13:14 +00:00
|
|
|
// Convert to a path for the native build tool.
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(install_name_dir);
|
2013-05-14 02:45:35 +00:00
|
|
|
install_name += install_name_dir;
|
|
|
|
install_name += "/";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-08-04 17:19:41 +00:00
|
|
|
install_name += gtgt->GetSOName(configName);
|
2013-05-14 02:45:35 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if ((realName != soName) || install_name_dir.empty()) {
|
2013-05-14 02:45:35 +00:00
|
|
|
install_name_dir = "";
|
|
|
|
extraLinkOptions += " -install_name ";
|
2016-04-20 21:19:48 +00:00
|
|
|
extraLinkOptions += XCodeEscapePath(install_name);
|
2006-02-24 18:13:14 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-02-24 18:13:14 +00:00
|
|
|
buildSettings->AddAttribute("INSTALL_PATH",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(install_name_dir));
|
2006-02-24 18:13:14 +00:00
|
|
|
|
2013-05-01 12:27:48 +00:00
|
|
|
// Create the LD_RUNPATH_SEARCH_PATHS
|
2015-08-04 17:19:42 +00:00
|
|
|
cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (pcli) {
|
2013-05-01 12:27:48 +00:00
|
|
|
std::string search_paths;
|
|
|
|
std::vector<std::string> runtimeDirs;
|
|
|
|
pcli->GetRPath(runtimeDirs, false);
|
2014-02-02 04:18:04 +00:00
|
|
|
// runpath dirs needs to be unique to prevent corruption
|
|
|
|
std::set<std::string> unique_dirs;
|
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto runpath : runtimeDirs) {
|
2014-02-02 04:18:04 +00:00
|
|
|
runpath = this->ExpandCFGIntDir(runpath, configName);
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (unique_dirs.find(runpath) == unique_dirs.end()) {
|
2014-02-02 04:18:04 +00:00
|
|
|
unique_dirs.insert(runpath);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!search_paths.empty()) {
|
2014-02-02 04:18:04 +00:00
|
|
|
search_paths += " ";
|
2013-05-01 12:27:48 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
search_paths += this->XCodeEscapePath(runpath);
|
2013-05-01 12:27:48 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!search_paths.empty()) {
|
2013-05-01 12:27:48 +00:00
|
|
|
buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(search_paths));
|
2013-05-01 12:27:48 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-05-01 12:27:48 +00:00
|
|
|
|
2015-10-19 19:23:29 +00:00
|
|
|
buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(gtgt),
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(extraLinkOptions));
|
2016-05-16 14:34:04 +00:00
|
|
|
buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString(""));
|
|
|
|
buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString(""));
|
|
|
|
buildSettings->AddAttribute("USE_HEADERMAP", this->CreateString("NO"));
|
2017-04-21 16:57:11 +00:00
|
|
|
cmXCodeObject* group = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
group->AddObject(this->CreateString("$(inherited)"));
|
|
|
|
buildSettings->AddAttribute("WARNING_CFLAGS", group);
|
2008-07-09 14:09:46 +00:00
|
|
|
|
|
|
|
// Runtime version information.
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) {
|
2008-07-09 14:09:46 +00:00
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int patch;
|
|
|
|
|
2020-01-24 16:32:18 +00:00
|
|
|
// OSX_CURRENT_VERSION or VERSION -> current_version
|
|
|
|
gtgt->GetTargetVersionFallback("OSX_CURRENT_VERSION", "VERSION", major,
|
|
|
|
minor, patch);
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream v;
|
2009-10-26 14:05:46 +00:00
|
|
|
|
|
|
|
// Xcode always wants at least 1.0.0 or nothing
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!(major == 0 && minor == 0 && patch == 0)) {
|
2009-10-26 14:05:46 +00:00
|
|
|
v << major << "." << minor << "." << patch;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-07-09 14:09:46 +00:00
|
|
|
buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(v.str()));
|
2008-07-09 14:09:46 +00:00
|
|
|
|
2020-01-24 16:32:18 +00:00
|
|
|
// OSX_COMPATIBILITY_VERSION or SOVERSION -> compatibility_version
|
|
|
|
gtgt->GetTargetVersionFallback("OSX_COMPATIBILITY_VERSION", "SOVERSION",
|
|
|
|
major, minor, patch);
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream vso;
|
2009-10-26 14:05:46 +00:00
|
|
|
|
|
|
|
// Xcode always wants at least 1.0.0 or nothing
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!(major == 0 && minor == 0 && patch == 0)) {
|
2009-10-26 14:05:46 +00:00
|
|
|
vso << major << "." << minor << "." << patch;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-07-09 14:09:46 +00:00
|
|
|
buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(vso.str()));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2019-07-13 10:07:30 +00:00
|
|
|
|
|
|
|
// Precompile Headers
|
|
|
|
std::string pchHeader = gtgt->GetPchHeader(configName, llang);
|
|
|
|
if (!pchHeader.empty()) {
|
|
|
|
buildSettings->AddAttribute("GCC_PREFIX_HEADER",
|
|
|
|
this->CreateString(pchHeader));
|
|
|
|
buildSettings->AddAttribute("GCC_PRECOMPILE_PREFIX_HEADER",
|
|
|
|
this->CreateString("YES"));
|
|
|
|
}
|
|
|
|
|
2008-10-02 17:49:32 +00:00
|
|
|
// put this last so it can override existing settings
|
|
|
|
// Convert "XCODE_ATTRIBUTE_*" properties directly.
|
|
|
|
{
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& prop : gtgt->GetPropertyKeys()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
if (prop.find("XCODE_ATTRIBUTE_") == 0) {
|
|
|
|
std::string attribute = prop.substr(16);
|
2016-05-16 14:34:04 +00:00
|
|
|
this->FilterConfigurationAttribute(configName, attribute);
|
|
|
|
if (!attribute.empty()) {
|
2019-09-22 07:53:44 +00:00
|
|
|
std::string processed = cmGeneratorExpression::Evaluate(
|
|
|
|
gtgt->GetProperty(prop), this->CurrentLocalGenerator, configName);
|
2016-09-04 14:55:05 +00:00
|
|
|
buildSettings->AddAttribute(attribute,
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateString(processed));
|
2012-12-12 15:42:00 +00:00
|
|
|
}
|
2008-10-02 17:49:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-01 18:07:42 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
|
|
|
|
cmGeneratorTarget* gtgt)
|
2005-02-03 22:42:55 +00:00
|
|
|
{
|
|
|
|
cmXCodeObject* shellBuildPhase =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase);
|
2010-09-29 12:38:18 +00:00
|
|
|
shellBuildPhase->AddAttribute("buildActionMask",
|
2005-11-18 19:12:09 +00:00
|
|
|
this->CreateString("2147483647"));
|
2005-02-03 22:42:55 +00:00
|
|
|
cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
shellBuildPhase->AddAttribute("files", buildFiles);
|
|
|
|
cmXCodeObject* inputPaths = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
shellBuildPhase->AddAttribute("inputPaths", inputPaths);
|
|
|
|
cmXCodeObject* outputPaths = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
shellBuildPhase->AddAttribute("outputPaths", outputPaths);
|
|
|
|
shellBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
2005-11-18 19:12:09 +00:00
|
|
|
this->CreateString("0"));
|
2016-05-16 14:34:04 +00:00
|
|
|
shellBuildPhase->AddAttribute("shellPath", this->CreateString("/bin/sh"));
|
|
|
|
shellBuildPhase->AddAttribute(
|
|
|
|
"shellScript", this->CreateString("# shell script goes here\nexit 0"));
|
|
|
|
shellBuildPhase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
|
2011-10-17 11:47:19 +00:00
|
|
|
|
2010-09-29 12:38:18 +00:00
|
|
|
cmXCodeObject* target =
|
2005-02-03 22:42:55 +00:00
|
|
|
this->CreateObject(cmXCodeObject::PBXAggregateTarget);
|
2016-09-04 14:55:05 +00:00
|
|
|
target->SetComment(gtgt->GetName());
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2007-08-14 15:45:15 +00:00
|
|
|
std::vector<cmXCodeObject*> emptyContentVector;
|
2017-09-18 21:57:50 +00:00
|
|
|
this->CreateCustomCommands(buildPhases, nullptr, nullptr, nullptr,
|
|
|
|
emptyContentVector, nullptr, gtgt);
|
2005-02-03 22:42:55 +00:00
|
|
|
target->AddAttribute("buildPhases", buildPhases);
|
2017-04-21 16:57:11 +00:00
|
|
|
this->AddConfigurations(target, gtgt);
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2005-02-03 22:42:55 +00:00
|
|
|
target->AddAttribute("dependencies", dependencies);
|
2015-10-21 18:36:59 +00:00
|
|
|
target->AddAttribute("name", this->CreateString(gtgt->GetName()));
|
2016-05-16 14:34:04 +00:00
|
|
|
target->AddAttribute("productName", this->CreateString(gtgt->GetName()));
|
2015-10-19 19:23:29 +00:00
|
|
|
target->SetTarget(gtgt);
|
|
|
|
this->XCodeObjectMap[gtgt] = target;
|
2008-10-09 15:01:48 +00:00
|
|
|
|
|
|
|
// Add source files without build rules for editing convenience.
|
2017-10-30 17:39:40 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::UTILITY &&
|
|
|
|
gtgt->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
|
2013-07-14 16:22:57 +00:00
|
|
|
std::vector<cmSourceFile*> sources;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!gtgt->GetConfigCommonSourceFiles(sources)) {
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-02-13 16:25:00 +00:00
|
|
|
|
2017-10-18 17:30:09 +00:00
|
|
|
// Add CMakeLists.txt file for user convenience.
|
2018-04-13 12:49:37 +00:00
|
|
|
this->AddXCodeProjBuildRule(gtgt, sources);
|
2017-10-18 17:30:09 +00:00
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto sourceFile : sources) {
|
2019-02-01 15:40:25 +00:00
|
|
|
if (!sourceFile->GetIsGenerated()) {
|
2017-11-07 07:41:47 +00:00
|
|
|
this->CreateXCodeFileReference(sourceFile, gtgt);
|
2008-10-09 15:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-10-09 15:01:48 +00:00
|
|
|
|
2016-09-04 14:55:05 +00:00
|
|
|
target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()));
|
2011-08-23 22:22:33 +00:00
|
|
|
|
2005-02-03 22:42:55 +00:00
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2009-07-02 18:14:03 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
|
2015-10-19 19:23:29 +00:00
|
|
|
cmGeneratorTarget* gtgt)
|
2005-09-02 20:29:32 +00:00
|
|
|
{
|
2019-08-11 09:56:59 +00:00
|
|
|
std::vector<std::string> const configVector = cmExpandedList(
|
|
|
|
this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"));
|
2010-09-29 12:38:18 +00:00
|
|
|
cmXCodeObject* configlist =
|
2006-05-11 19:39:46 +00:00
|
|
|
this->CreateObject(cmXCodeObject::XCConfigurationList);
|
2005-09-02 20:29:32 +00:00
|
|
|
cmXCodeObject* buildConfigurations =
|
|
|
|
this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
configlist->AddAttribute("buildConfigurations", buildConfigurations);
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string comment = cmStrCat("Build configuration list for ",
|
|
|
|
cmXCodeObject::PBXTypeNames[target->GetIsA()],
|
|
|
|
" \"", gtgt->GetName(), '"');
|
2016-09-04 14:55:05 +00:00
|
|
|
configlist->SetComment(comment);
|
2010-09-29 12:38:18 +00:00
|
|
|
target->AddAttribute("buildConfigurationList",
|
2005-09-02 20:29:32 +00:00
|
|
|
this->CreateObjectReference(configlist));
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& i : configVector) {
|
2010-09-29 12:38:18 +00:00
|
|
|
cmXCodeObject* config =
|
2006-05-11 19:39:46 +00:00
|
|
|
this->CreateObject(cmXCodeObject::XCBuildConfiguration);
|
2005-09-02 20:29:32 +00:00
|
|
|
buildConfigurations->AddObject(config);
|
|
|
|
cmXCodeObject* buildSettings =
|
|
|
|
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
2017-09-20 21:44:34 +00:00
|
|
|
this->CreateBuildSettings(gtgt, buildSettings, i);
|
|
|
|
config->AddAttribute("name", this->CreateString(i));
|
|
|
|
config->SetComment(i);
|
2005-09-02 20:29:32 +00:00
|
|
|
config->AddAttribute("buildSettings", buildSettings);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!configVector.empty()) {
|
2010-09-29 12:38:18 +00:00
|
|
|
configlist->AddAttribute("defaultConfigurationName",
|
2016-04-20 21:11:17 +00:00
|
|
|
this->CreateString(configVector[0]));
|
2010-09-29 12:38:18 +00:00
|
|
|
configlist->AddAttribute("defaultConfigurationIsVisible",
|
2006-05-11 19:39:46 +00:00
|
|
|
this->CreateString("0"));
|
2009-07-02 18:14:03 +00:00
|
|
|
return configVector[0];
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-02 18:14:03 +00:00
|
|
|
return "";
|
2005-09-02 20:29:32 +00:00
|
|
|
}
|
|
|
|
|
2015-10-19 19:23:29 +00:00
|
|
|
const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorTarget const* target) const
|
2014-07-28 15:41:53 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->XcodeVersion >= 60 &&
|
2016-10-18 19:28:46 +00:00
|
|
|
(target->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
|
|
|
target->GetType() == cmStateEnums::OBJECT_LIBRARY)) {
|
2014-07-28 15:41:53 +00:00
|
|
|
return "OTHER_LIBTOOLFLAGS";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-09-19 14:19:31 +00:00
|
|
|
return "OTHER_LDFLAGS";
|
2014-07-28 15:41:53 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 13:20:23 +00:00
|
|
|
const char* cmGlobalXCodeGenerator::GetTargetFileType(
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorTarget* target)
|
2009-07-02 18:13:46 +00:00
|
|
|
{
|
2016-12-03 22:45:55 +00:00
|
|
|
if (const char* e = target->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (target->GetType()) {
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::OBJECT_LIBRARY:
|
2009-07-02 18:13:46 +00:00
|
|
|
return "archive.ar";
|
2016-12-26 17:07:24 +00:00
|
|
|
case cmStateEnums::STATIC_LIBRARY:
|
|
|
|
return (target->GetPropertyAsBool("FRAMEWORK") ? "wrapper.framework"
|
|
|
|
: "archive.ar");
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::MODULE_LIBRARY:
|
2017-09-20 21:53:14 +00:00
|
|
|
if (target->IsXCTestOnApple()) {
|
2015-02-25 20:07:43 +00:00
|
|
|
return "wrapper.cfbundle";
|
2017-09-20 21:53:14 +00:00
|
|
|
}
|
|
|
|
if (target->IsCFBundleOnApple()) {
|
2010-10-07 02:43:04 +00:00
|
|
|
return "wrapper.plug-in";
|
2017-09-20 21:53:14 +00:00
|
|
|
}
|
2017-09-19 14:19:31 +00:00
|
|
|
return "compiled.mach-o.executable";
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::SHARED_LIBRARY:
|
2016-05-16 14:34:04 +00:00
|
|
|
return (target->GetPropertyAsBool("FRAMEWORK")
|
|
|
|
? "wrapper.framework"
|
|
|
|
: "compiled.mach-o.dylib");
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::EXECUTABLE:
|
2009-07-02 18:13:46 +00:00
|
|
|
return "compiled.mach-o.executable";
|
2016-05-16 14:34:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2009-07-02 18:13:46 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 13:20:23 +00:00
|
|
|
const char* cmGlobalXCodeGenerator::GetTargetProductType(
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorTarget* target)
|
2009-07-02 18:13:46 +00:00
|
|
|
{
|
2016-12-03 22:46:15 +00:00
|
|
|
if (const char* e = target->GetProperty("XCODE_PRODUCT_TYPE")) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (target->GetType()) {
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::OBJECT_LIBRARY:
|
2009-07-02 18:13:46 +00:00
|
|
|
return "com.apple.product-type.library.static";
|
2016-12-26 17:07:24 +00:00
|
|
|
case cmStateEnums::STATIC_LIBRARY:
|
|
|
|
return (target->GetPropertyAsBool("FRAMEWORK")
|
|
|
|
? "com.apple.product-type.framework"
|
|
|
|
: "com.apple.product-type.library.static");
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::MODULE_LIBRARY:
|
2017-09-20 21:53:14 +00:00
|
|
|
if (target->IsXCTestOnApple()) {
|
2015-02-25 20:07:43 +00:00
|
|
|
return "com.apple.product-type.bundle.unit-test";
|
2017-09-20 21:53:14 +00:00
|
|
|
} else if (target->IsCFBundleOnApple()) {
|
2010-10-07 02:43:04 +00:00
|
|
|
return "com.apple.product-type.bundle";
|
2017-09-20 21:53:14 +00:00
|
|
|
} else {
|
2017-04-21 16:57:11 +00:00
|
|
|
return "com.apple.product-type.tool";
|
2017-09-20 21:53:14 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::SHARED_LIBRARY:
|
2016-05-16 14:34:04 +00:00
|
|
|
return (target->GetPropertyAsBool("FRAMEWORK")
|
|
|
|
? "com.apple.product-type.framework"
|
|
|
|
: "com.apple.product-type.library.dynamic");
|
2016-10-18 19:28:46 +00:00
|
|
|
case cmStateEnums::EXECUTABLE:
|
2016-05-16 14:34:04 +00:00
|
|
|
return (target->GetPropertyAsBool("MACOSX_BUNDLE")
|
|
|
|
? "com.apple.product-type.application"
|
|
|
|
: "com.apple.product-type.tool");
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2009-07-02 18:13:46 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
|
|
|
|
cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases)
|
2005-02-01 18:07:42 +00:00
|
|
|
{
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
|
2005-02-01 18:07:42 +00:00
|
|
|
target->AddAttribute("buildPhases", buildPhases);
|
|
|
|
cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
target->AddAttribute("buildRules", buildRules);
|
2009-07-02 18:14:03 +00:00
|
|
|
std::string defConfig;
|
2017-04-21 16:57:11 +00:00
|
|
|
defConfig = this->AddConfigurations(target, gtgt);
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2005-02-01 18:07:42 +00:00
|
|
|
target->AddAttribute("dependencies", dependencies);
|
2015-10-21 18:36:59 +00:00
|
|
|
target->AddAttribute("name", this->CreateString(gtgt->GetName()));
|
2016-05-16 14:34:04 +00:00
|
|
|
target->AddAttribute("productName", this->CreateString(gtgt->GetName()));
|
2015-10-17 13:20:23 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
|
|
|
|
if (const char* fileType = this->GetTargetFileType(gtgt)) {
|
2009-07-02 18:13:46 +00:00
|
|
|
fileRef->AddAttribute("explicitFileType", this->CreateString(fileType));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-03-15 18:31:32 +00:00
|
|
|
std::string fullName;
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
|
2019-08-22 14:34:40 +00:00
|
|
|
fullName = cmStrCat("lib", gtgt->GetName(), ".a");
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2016-09-04 14:55:05 +00:00
|
|
|
fullName = gtgt->GetFullName(defConfig);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-04-20 21:11:17 +00:00
|
|
|
fileRef->AddAttribute("path", this->CreateString(fullName));
|
2005-02-07 22:36:34 +00:00
|
|
|
fileRef->AddAttribute("sourceTree",
|
|
|
|
this->CreateString("BUILT_PRODUCTS_DIR"));
|
2016-09-04 14:55:05 +00:00
|
|
|
fileRef->SetComment(gtgt->GetName());
|
2010-09-29 12:38:18 +00:00
|
|
|
target->AddAttribute("productReference",
|
2005-02-07 22:36:34 +00:00
|
|
|
this->CreateObjectReference(fileRef));
|
2016-05-16 14:34:04 +00:00
|
|
|
if (const char* productType = this->GetTargetProductType(gtgt)) {
|
2009-07-02 18:13:46 +00:00
|
|
|
target->AddAttribute("productType", this->CreateString(productType));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-19 19:23:29 +00:00
|
|
|
target->SetTarget(gtgt);
|
|
|
|
this->XCodeObjectMap[gtgt] = target;
|
2016-09-04 14:55:05 +00:00
|
|
|
target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()));
|
2005-02-01 18:07:42 +00:00
|
|
|
return target;
|
|
|
|
}
|
2005-01-28 22:21:35 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(
|
|
|
|
cmGeneratorTarget const* t)
|
2005-02-03 22:42:55 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!t) {
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-12-01 17:56:46 +00:00
|
|
|
|
2019-09-04 20:17:22 +00:00
|
|
|
auto const i = this->XCodeObjectMap.find(t);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (i == this->XCodeObjectMap.end()) {
|
2017-09-18 21:57:50 +00:00
|
|
|
return nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-12-01 17:56:46 +00:00
|
|
|
return i->second;
|
2005-02-03 22:42:55 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 22:31:47 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
|
|
|
|
const std::string& id)
|
2011-08-23 22:22:33 +00:00
|
|
|
{
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
|
2011-08-23 22:22:33 +00:00
|
|
|
const char* storedGUID =
|
2016-09-04 14:55:05 +00:00
|
|
|
this->CMakeInstance->GetCacheDefinition(guidStoreName);
|
2011-08-23 22:22:33 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (storedGUID) {
|
2011-08-23 22:22:33 +00:00
|
|
|
return storedGUID;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-08-23 22:22:33 +00:00
|
|
|
|
2016-10-18 19:28:47 +00:00
|
|
|
this->CMakeInstance->AddCacheEntry(guidStoreName, id.c_str(),
|
|
|
|
"Stored Xcode object GUID",
|
|
|
|
cmStateEnums::INTERNAL);
|
2011-08-23 22:22:33 +00:00
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2005-02-03 22:42:55 +00:00
|
|
|
void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
|
|
|
|
cmXCodeObject* dependTarget)
|
|
|
|
{
|
2013-02-19 21:13:51 +00:00
|
|
|
// This is called once for every edge in the target dependency graph.
|
|
|
|
cmXCodeObject* container =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXContainerItemProxy);
|
|
|
|
container->SetComment("PBXContainerItemProxy");
|
|
|
|
container->AddAttribute("containerPortal",
|
|
|
|
this->CreateObjectReference(this->RootObject));
|
|
|
|
container->AddAttribute("proxyType", this->CreateString("1"));
|
|
|
|
container->AddAttribute("remoteGlobalIDString",
|
|
|
|
this->CreateObjectReference(dependTarget));
|
2016-05-16 14:34:04 +00:00
|
|
|
container->AddAttribute(
|
|
|
|
"remoteInfo", this->CreateString(dependTarget->GetTarget()->GetName()));
|
2013-02-19 21:13:51 +00:00
|
|
|
cmXCodeObject* targetdep =
|
|
|
|
this->CreateObject(cmXCodeObject::PBXTargetDependency);
|
|
|
|
targetdep->SetComment("PBXTargetDependency");
|
2016-05-16 14:34:04 +00:00
|
|
|
targetdep->AddAttribute("target", this->CreateObjectReference(dependTarget));
|
2013-02-19 21:13:51 +00:00
|
|
|
targetdep->AddAttribute("targetProxy",
|
|
|
|
this->CreateObjectReference(container));
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2005-02-03 22:42:55 +00:00
|
|
|
cmXCodeObject* depends = target->GetObject("dependencies");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!depends) {
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"target does not have dependencies attribute error..");
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2005-02-17 22:54:14 +00:00
|
|
|
depends->AddUniqueObject(targetdep);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-03 22:42:55 +00:00
|
|
|
}
|
|
|
|
|
2005-09-08 18:35:37 +00:00
|
|
|
void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
|
|
|
|
const char* attribute,
|
|
|
|
const char* value)
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (settings) {
|
2005-09-08 18:35:37 +00:00
|
|
|
cmXCodeObject* attr = settings->GetObject(attribute);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!attr) {
|
2005-09-08 18:35:37 +00:00
|
|
|
settings->AddAttribute(attribute, this->CreateString(value));
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string oldValue = cmStrCat(attr->GetString(), ' ', value);
|
2016-09-04 14:55:05 +00:00
|
|
|
attr->SetString(oldValue);
|
2005-09-08 18:35:37 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-09-08 18:35:37 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
|
|
|
|
cmXCodeObject* target, const char* attribute, const char* value,
|
|
|
|
const std::string& configName)
|
2005-09-02 20:29:32 +00:00
|
|
|
{
|
2017-04-21 16:57:11 +00:00
|
|
|
// There are multiple configurations. Add the setting to the
|
|
|
|
// buildSettings of the configuration name given.
|
|
|
|
cmXCodeObject* configurationList =
|
|
|
|
target->GetObject("buildConfigurationList")->GetObject();
|
|
|
|
cmXCodeObject* buildConfigs =
|
|
|
|
configurationList->GetObject("buildConfigurations");
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto obj : buildConfigs->GetObjectList()) {
|
|
|
|
if (configName.empty() ||
|
|
|
|
obj->GetObject("name")->GetString() == configName) {
|
|
|
|
cmXCodeObject* settings = obj->GetObject("buildSettings");
|
2017-04-21 16:57:11 +00:00
|
|
|
this->AppendOrAddBuildSetting(settings, attribute, value);
|
2005-09-02 20:29:32 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-09-02 20:29:32 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
|
2005-02-03 22:42:55 +00:00
|
|
|
{
|
2015-10-19 19:23:29 +00:00
|
|
|
cmGeneratorTarget* gt = target->GetTarget();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!gt) {
|
2015-10-21 19:14:00 +00:00
|
|
|
cmSystemTools::Error("Error no target on xobject\n");
|
2012-11-02 14:47:40 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
2005-02-03 22:42:55 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// Add dependencies on other CMake targets.
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& dep : this->GetTargetDirectDepends(gt)) {
|
2017-09-20 21:44:34 +00:00
|
|
|
if (cmXCodeObject* dptarget = this->FindXCodeTarget(dep)) {
|
2008-09-15 13:51:47 +00:00
|
|
|
this->AddDependTarget(target, dptarget);
|
2005-02-03 22:42:55 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// Loop over configuration types and set per-configuration info.
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& configName : this->CurrentConfigurationTypes) {
|
2019-02-10 10:22:38 +00:00
|
|
|
{
|
2013-10-02 15:52:18 +00:00
|
|
|
// Add object library contents as link flags.
|
|
|
|
std::string linkObjs;
|
|
|
|
const char* sep = "";
|
2017-04-12 19:11:57 +00:00
|
|
|
std::vector<cmSourceFile const*> objs;
|
2017-04-12 19:26:24 +00:00
|
|
|
gt->GetExternalObjects(objs, configName);
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto sourceFile : objs) {
|
|
|
|
if (sourceFile->GetObjectLibrary().empty()) {
|
2017-04-12 19:11:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-10-02 15:52:18 +00:00
|
|
|
linkObjs += sep;
|
|
|
|
sep = " ";
|
2017-11-07 07:41:47 +00:00
|
|
|
linkObjs += this->XCodeEscapePath(sourceFile->GetFullPath());
|
2013-10-02 15:52:18 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->AppendBuildSettingAttribute(
|
|
|
|
target, this->GetTargetLinkFlagsVar(gt), linkObjs.c_str(), configName);
|
|
|
|
}
|
2013-10-02 15:52:18 +00:00
|
|
|
|
|
|
|
// Skip link information for object libraries.
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
|
|
|
|
gt->GetType() == cmStateEnums::STATIC_LIBRARY) {
|
2013-10-02 15:52:18 +00:00
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-10-02 15:52:18 +00:00
|
|
|
|
2006-01-13 23:18:32 +00:00
|
|
|
// Compute the link library and directory information.
|
2015-10-21 18:36:59 +00:00
|
|
|
cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!pcli) {
|
2008-01-22 14:13:04 +00:00
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-01-29 20:07:33 +00:00
|
|
|
cmComputeLinkInformation& cli = *pcli;
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// Add dependencies directly on library files.
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& libDep : cli.GetDepends()) {
|
|
|
|
target->AddDependLibrary(configName, libDep);
|
2008-01-22 14:13:04 +00:00
|
|
|
}
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// add the library search paths
|
2008-01-22 14:13:04 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string linkDirs;
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& libDir : cli.GetDirectories()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
if (!libDir.empty() && libDir != "/usr/lib") {
|
2017-04-21 16:57:11 +00:00
|
|
|
// Now add the same one but append
|
|
|
|
// $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
|
|
|
|
linkDirs += " ";
|
|
|
|
linkDirs += this->XCodeEscapePath(
|
2017-09-20 21:44:34 +00:00
|
|
|
libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
|
2016-05-16 14:34:04 +00:00
|
|
|
linkDirs += " ";
|
2017-09-20 21:44:34 +00:00
|
|
|
linkDirs += this->XCodeEscapePath(libDir);
|
2006-01-13 23:18:32 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
|
|
|
|
linkDirs.c_str(), configName);
|
2008-01-22 14:13:04 +00:00
|
|
|
}
|
|
|
|
|
2006-01-13 23:18:32 +00:00
|
|
|
// now add the link libraries
|
2008-02-07 21:49:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string linkLibs;
|
|
|
|
const char* sep = "";
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& libName : cli.GetItems()) {
|
2016-05-16 14:34:04 +00:00
|
|
|
linkLibs += sep;
|
|
|
|
sep = " ";
|
2017-09-20 21:44:34 +00:00
|
|
|
if (libName.IsPath) {
|
|
|
|
linkLibs += this->XCodeEscapePath(libName.Value);
|
|
|
|
} else if (!libName.Target ||
|
|
|
|
libName.Target->GetType() !=
|
|
|
|
cmStateEnums::INTERFACE_LIBRARY) {
|
|
|
|
linkLibs += libName.Value;
|
2007-05-08 19:49:54 +00:00
|
|
|
}
|
2017-09-20 21:44:34 +00:00
|
|
|
if (libName.Target && !libName.Target->IsImported()) {
|
|
|
|
target->AddDependTarget(configName, libName.Target->GetName());
|
2011-06-06 21:34:43 +00:00
|
|
|
}
|
2006-01-13 23:18:32 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->AppendBuildSettingAttribute(
|
|
|
|
target, this->GetTargetLinkFlagsVar(gt), linkLibs.c_str(), configName);
|
2005-02-03 22:42:55 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-03 22:42:55 +00:00
|
|
|
}
|
2005-02-02 22:16:07 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmGlobalXCodeGenerator::CreateGroups(
|
2016-08-19 19:50:48 +00:00
|
|
|
std::vector<cmLocalGenerator*>& generators)
|
2005-03-17 20:35:44 +00:00
|
|
|
{
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& generator : generators) {
|
|
|
|
cmMakefile* mf = generator->GetMakefile();
|
2005-03-17 20:35:44 +00:00
|
|
|
std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
|
2019-11-07 17:52:06 +00:00
|
|
|
for (const auto& gtgt : generator->GetGeneratorTargets()) {
|
2007-08-14 15:45:15 +00:00
|
|
|
// Same skipping logic here as in CreateXCodeTargets so that we do not
|
2017-10-30 17:39:40 +00:00
|
|
|
// end up with (empty anyhow) ZERO_CHECK, install, or test source
|
2007-08-14 15:45:15 +00:00
|
|
|
// groups:
|
|
|
|
//
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
2007-08-14 15:45:15 +00:00
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
2012-11-02 14:47:40 +00:00
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-10-30 17:39:40 +00:00
|
|
|
if (gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2019-11-07 17:52:06 +00:00
|
|
|
auto addSourceToGroup = [this, mf, >gt,
|
2019-04-10 11:59:37 +00:00
|
|
|
&sourceGroups](std::string const& source) {
|
|
|
|
cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups);
|
2019-11-07 17:52:06 +00:00
|
|
|
cmXCodeObject* pbxgroup =
|
|
|
|
this->CreateOrGetPBXGroup(gtgt.get(), sourceGroup);
|
|
|
|
std::string key = GetGroupMapKeyFromPath(gtgt.get(), source);
|
2019-04-10 11:59:37 +00:00
|
|
|
this->GroupMap[key] = pbxgroup;
|
|
|
|
};
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2012-03-15 18:31:32 +00:00
|
|
|
// Put cmSourceFile instances in proper groups:
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& si : gtgt->GetAllConfigSources()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
cmSourceFile const* sf = si.Source;
|
2019-02-10 10:22:38 +00:00
|
|
|
if (!sf->GetObjectLibrary().empty()) {
|
2017-04-12 18:33:48 +00:00
|
|
|
// Object library files go on the link line instead.
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-10 11:59:37 +00:00
|
|
|
addSourceToGroup(sf->GetFullPath());
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-10-18 17:30:09 +00:00
|
|
|
|
|
|
|
// Add CMakeLists.txt file for user convenience.
|
|
|
|
{
|
|
|
|
std::string listfile =
|
2019-08-22 14:34:40 +00:00
|
|
|
cmStrCat(gtgt->GetLocalGenerator()->GetCurrentSourceDirectory(),
|
|
|
|
"/CMakeLists.txt");
|
2019-11-05 19:19:36 +00:00
|
|
|
cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
|
|
|
|
listfile, false, cmSourceFileLocationKind::Known);
|
2019-11-05 19:20:21 +00:00
|
|
|
addSourceToGroup(sf->ResolveFullPath());
|
2017-10-18 17:30:09 +00:00
|
|
|
}
|
2019-04-10 12:04:15 +00:00
|
|
|
|
|
|
|
// Add the Info.plist we are about to generate for an App Bundle.
|
|
|
|
if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
|
2019-11-07 17:52:06 +00:00
|
|
|
std::string plist = this->ComputeInfoPListLocation(gtgt.get());
|
2019-11-05 19:19:36 +00:00
|
|
|
cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
|
|
|
|
plist, true, cmSourceFileLocationKind::Known);
|
2019-11-05 19:20:21 +00:00
|
|
|
addSourceToGroup(sf->ResolveFullPath());
|
2017-10-18 17:30:09 +00:00
|
|
|
}
|
2010-09-29 12:38:18 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-01-19 13:27:15 +00:00
|
|
|
return true;
|
2005-03-17 20:35:44 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreatePBXGroup(cmXCodeObject* parent,
|
2017-09-19 13:54:08 +00:00
|
|
|
const std::string& name)
|
2011-02-15 13:34:14 +00:00
|
|
|
{
|
2017-09-18 21:57:50 +00:00
|
|
|
cmXCodeObject* parentChildren = nullptr;
|
2017-09-20 21:53:14 +00:00
|
|
|
if (parent) {
|
2011-02-15 13:34:14 +00:00
|
|
|
parentChildren = parent->GetObject("children");
|
2017-09-20 21:53:14 +00:00
|
|
|
}
|
2011-02-15 13:34:14 +00:00
|
|
|
cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
|
|
|
|
cmXCodeObject* groupChildren =
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2016-04-20 21:11:17 +00:00
|
|
|
group->AddAttribute("name", this->CreateString(name));
|
2011-02-15 13:34:14 +00:00
|
|
|
group->AddAttribute("children", groupChildren);
|
|
|
|
group->AddAttribute("sourceTree", this->CreateString("<group>"));
|
2017-09-20 21:53:14 +00:00
|
|
|
if (parentChildren) {
|
2011-02-15 13:34:14 +00:00
|
|
|
parentChildren->AddObject(group);
|
2017-09-20 21:53:14 +00:00
|
|
|
}
|
2011-02-15 13:34:14 +00:00
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
|
|
|
|
cmGeneratorTarget* gtgt, cmSourceGroup* sg)
|
2005-03-17 20:35:44 +00:00
|
|
|
{
|
2014-02-10 05:21:34 +00:00
|
|
|
std::string s;
|
|
|
|
std::string target;
|
2016-08-30 18:55:37 +00:00
|
|
|
const std::string targetFolder = gtgt->GetEffectiveFolderName();
|
|
|
|
if (!targetFolder.empty()) {
|
2019-08-22 14:34:40 +00:00
|
|
|
target = cmStrCat(targetFolder, '/');
|
2011-02-20 13:05:41 +00:00
|
|
|
}
|
2015-10-19 19:23:29 +00:00
|
|
|
target += gtgt->GetName();
|
2019-08-22 14:34:40 +00:00
|
|
|
s = cmStrCat(target, '/', sg->GetFullName());
|
2019-09-04 20:17:22 +00:00
|
|
|
auto it = this->GroupNameMap.find(s);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (it != this->GroupNameMap.end()) {
|
2011-02-20 13:05:41 +00:00
|
|
|
return it->second;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-02-20 13:05:41 +00:00
|
|
|
|
|
|
|
it = this->TargetGroup.find(target);
|
2017-09-18 21:57:50 +00:00
|
|
|
cmXCodeObject* tgroup = nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (it != this->TargetGroup.end()) {
|
2011-02-20 13:05:41 +00:00
|
|
|
tgroup = it->second;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2019-07-31 07:06:04 +00:00
|
|
|
std::vector<std::string> tgt_folders = cmTokenize(target, "/");
|
2014-02-10 05:21:34 +00:00
|
|
|
std::string curr_tgt_folder;
|
2016-05-16 14:34:04 +00:00
|
|
|
for (std::vector<std::string>::size_type i = 0; i < tgt_folders.size();
|
|
|
|
i++) {
|
|
|
|
if (i != 0) {
|
2013-12-02 14:09:22 +00:00
|
|
|
curr_tgt_folder += "/";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-12-02 14:09:22 +00:00
|
|
|
curr_tgt_folder += tgt_folders[i];
|
|
|
|
it = this->TargetGroup.find(curr_tgt_folder);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (it != this->TargetGroup.end()) {
|
2011-02-20 13:05:41 +00:00
|
|
|
tgroup = it->second;
|
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
tgroup = this->CreatePBXGroup(tgroup, tgt_folders[i]);
|
2013-12-02 14:09:22 +00:00
|
|
|
this->TargetGroup[curr_tgt_folder] = tgroup;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (i == 0) {
|
2017-04-29 17:37:32 +00:00
|
|
|
this->MainGroupChildren->AddObject(tgroup);
|
2005-11-16 18:13:39 +00:00
|
|
|
}
|
2005-03-17 20:35:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-02-20 13:05:41 +00:00
|
|
|
this->TargetGroup[target] = tgroup;
|
2007-08-14 15:45:15 +00:00
|
|
|
|
|
|
|
// If it's the default source group (empty name) then put the source file
|
|
|
|
// directly in the tgroup...
|
|
|
|
//
|
2017-11-15 15:32:01 +00:00
|
|
|
if (sg->GetFullName().empty()) {
|
2007-08-14 15:45:15 +00:00
|
|
|
this->GroupNameMap[s] = tgroup;
|
|
|
|
return tgroup;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
// It's a recursive folder structure, let's find the real parent group
|
2017-11-15 15:32:01 +00:00
|
|
|
if (sg->GetFullName() != sg->GetName()) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string curr_folder = cmStrCat(target, '/');
|
2019-07-31 07:06:04 +00:00
|
|
|
for (auto const& folder : cmTokenize(sg->GetFullName(), "\\")) {
|
2017-09-20 21:44:34 +00:00
|
|
|
curr_folder += folder;
|
2019-09-04 20:17:22 +00:00
|
|
|
auto const i_folder = this->GroupNameMap.find(curr_folder);
|
2016-05-16 14:34:04 +00:00
|
|
|
// Create new folder
|
|
|
|
if (i_folder == this->GroupNameMap.end()) {
|
2017-09-20 21:44:34 +00:00
|
|
|
cmXCodeObject* group = this->CreatePBXGroup(tgroup, folder);
|
2011-02-15 13:34:14 +00:00
|
|
|
this->GroupNameMap[curr_folder] = group;
|
|
|
|
tgroup = group;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2011-02-15 13:34:14 +00:00
|
|
|
tgroup = i_folder->second;
|
|
|
|
}
|
2019-08-03 11:20:31 +00:00
|
|
|
curr_folder += "\\";
|
2005-11-16 18:13:39 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return tgroup;
|
|
|
|
}
|
|
|
|
cmXCodeObject* group = this->CreatePBXGroup(tgroup, sg->GetName());
|
2006-03-15 16:02:08 +00:00
|
|
|
this->GroupNameMap[s] = group;
|
2005-03-17 20:35:44 +00:00
|
|
|
return group;
|
|
|
|
}
|
2005-02-02 22:16:07 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmGlobalXCodeGenerator::CreateXCodeObjects(
|
|
|
|
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2010-09-29 12:38:18 +00:00
|
|
|
this->ClearXCodeObjects();
|
2017-09-18 21:57:50 +00:00
|
|
|
this->RootObject = nullptr;
|
|
|
|
this->MainGroupChildren = nullptr;
|
2005-01-27 21:11:44 +00:00
|
|
|
cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
2005-01-25 20:26:57 +00:00
|
|
|
group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
|
2006-04-10 15:39:32 +00:00
|
|
|
cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2019-05-14 13:16:11 +00:00
|
|
|
for (const std::string& CurrentConfigurationType :
|
|
|
|
this->CurrentConfigurationTypes) {
|
2017-04-21 16:57:11 +00:00
|
|
|
cmXCodeObject* buildStyle =
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateObject(cmXCodeObject::PBXBuildStyle);
|
2019-05-14 13:16:11 +00:00
|
|
|
const std::string& name = CurrentConfigurationType;
|
2017-04-21 16:57:11 +00:00
|
|
|
buildStyle->AddAttribute("name", this->CreateString(name));
|
|
|
|
buildStyle->SetComment(name);
|
|
|
|
cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
|
|
|
sgroup->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
|
|
|
|
buildStyle->AddAttribute("buildSettings", sgroup);
|
|
|
|
listObjs->AddObject(buildStyle);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-09-02 20:29:32 +00:00
|
|
|
|
2005-01-28 21:00:10 +00:00
|
|
|
cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup);
|
2016-05-16 14:34:04 +00:00
|
|
|
this->MainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2006-03-15 16:02:08 +00:00
|
|
|
mainGroup->AddAttribute("children", this->MainGroupChildren);
|
2005-02-02 22:16:07 +00:00
|
|
|
mainGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
|
2005-01-28 21:00:10 +00:00
|
|
|
|
2010-09-29 12:38:18 +00:00
|
|
|
// now create the cmake groups
|
2016-08-19 19:50:48 +00:00
|
|
|
if (!this->CreateGroups(generators)) {
|
2015-01-19 13:27:15 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2007-08-14 15:45:15 +00:00
|
|
|
|
2005-02-04 22:58:58 +00:00
|
|
|
cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup);
|
|
|
|
productGroup->AddAttribute("name", this->CreateString("Products"));
|
|
|
|
productGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
|
2010-09-29 12:38:18 +00:00
|
|
|
cmXCodeObject* productGroupChildren =
|
2005-02-04 22:58:58 +00:00
|
|
|
this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
|
|
|
productGroup->AddAttribute("children", productGroupChildren);
|
2006-03-15 16:02:08 +00:00
|
|
|
this->MainGroupChildren->AddObject(productGroup);
|
2010-09-29 12:38:18 +00:00
|
|
|
|
2006-03-15 16:02:08 +00:00
|
|
|
this->RootObject = this->CreateObject(cmXCodeObject::PBXProject);
|
|
|
|
this->RootObject->SetComment("Project object");
|
2011-08-23 22:22:33 +00:00
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string project_id = cmStrCat("PROJECT_", root->GetProjectName());
|
2016-05-16 14:34:04 +00:00
|
|
|
this->RootObject->SetId(
|
2017-09-19 14:19:14 +00:00
|
|
|
this->GetOrCreateId(project_id, this->RootObject->GetId()));
|
2011-08-23 22:22:33 +00:00
|
|
|
|
2005-01-27 21:11:44 +00:00
|
|
|
group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
2010-09-29 12:38:18 +00:00
|
|
|
this->RootObject->AddAttribute("mainGroup",
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateObjectReference(mainGroup));
|
2006-03-15 16:02:08 +00:00
|
|
|
this->RootObject->AddAttribute("buildSettings", group);
|
|
|
|
this->RootObject->AddAttribute("buildStyles", listObjs);
|
|
|
|
this->RootObject->AddAttribute("hasScannedForEncodings",
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateString("0"));
|
2017-04-21 16:57:11 +00:00
|
|
|
group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
|
|
|
group->AddAttribute("BuildIndependentTargetsInParallel",
|
|
|
|
this->CreateString("YES"));
|
|
|
|
std::ostringstream v;
|
|
|
|
v << std::setfill('0') << std::setw(4) << XcodeVersion * 10;
|
|
|
|
group->AddAttribute("LastUpgradeCheck", this->CreateString(v.str()));
|
|
|
|
this->RootObject->AddAttribute("attributes", group);
|
2019-02-10 10:22:38 +00:00
|
|
|
this->RootObject->AddAttribute("compatibilityVersion",
|
|
|
|
this->CreateString("Xcode 3.2"));
|
2008-07-07 14:57:32 +00:00
|
|
|
// Point Xcode at the top of the source tree.
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string pdir =
|
2019-03-17 19:22:26 +00:00
|
|
|
this->RelativeToBinary(root->GetCurrentSourceDirectory());
|
2016-05-16 14:34:04 +00:00
|
|
|
this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir));
|
|
|
|
this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
|
2008-07-07 14:57:32 +00:00
|
|
|
}
|
2010-09-29 12:38:18 +00:00
|
|
|
cmXCodeObject* configlist =
|
2006-04-10 15:39:32 +00:00
|
|
|
this->CreateObject(cmXCodeObject::XCConfigurationList);
|
2005-09-02 20:29:32 +00:00
|
|
|
cmXCodeObject* buildConfigurations =
|
|
|
|
this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2019-09-04 16:03:01 +00:00
|
|
|
using Configs = std::vector<std::pair<std::string, cmXCodeObject*>>;
|
2016-01-03 10:58:52 +00:00
|
|
|
Configs configs;
|
2017-11-07 07:41:47 +00:00
|
|
|
std::string defaultConfigName;
|
|
|
|
for (const auto& name : this->CurrentConfigurationTypes) {
|
|
|
|
if (defaultConfigName.empty()) {
|
2017-04-21 16:57:11 +00:00
|
|
|
defaultConfigName = name;
|
2006-04-10 15:39:32 +00:00
|
|
|
}
|
2017-04-21 16:57:11 +00:00
|
|
|
cmXCodeObject* config =
|
|
|
|
this->CreateObject(cmXCodeObject::XCBuildConfiguration);
|
|
|
|
config->AddAttribute("name", this->CreateString(name));
|
|
|
|
configs.push_back(std::make_pair(name, config));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-11-07 07:41:47 +00:00
|
|
|
if (defaultConfigName.empty()) {
|
|
|
|
defaultConfigName = "Debug";
|
|
|
|
}
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& config : configs) {
|
|
|
|
buildConfigurations->AddObject(config.second);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-09-02 20:29:32 +00:00
|
|
|
configlist->AddAttribute("buildConfigurations", buildConfigurations);
|
2006-04-10 15:39:32 +00:00
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string comment = cmStrCat("Build configuration list for PBXProject \"",
|
|
|
|
this->CurrentProject, '"');
|
2016-09-04 14:55:05 +00:00
|
|
|
configlist->SetComment(comment);
|
2010-09-29 12:38:18 +00:00
|
|
|
configlist->AddAttribute("defaultConfigurationIsVisible",
|
2006-05-11 19:39:46 +00:00
|
|
|
this->CreateString("0"));
|
2010-09-29 12:38:18 +00:00
|
|
|
configlist->AddAttribute("defaultConfigurationName",
|
2012-04-02 19:50:37 +00:00
|
|
|
this->CreateString(defaultConfigName));
|
2005-09-02 20:29:32 +00:00
|
|
|
cmXCodeObject* buildSettings =
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
|
2010-09-29 12:38:18 +00:00
|
|
|
const char* sysroot =
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
2010-09-29 12:38:18 +00:00
|
|
|
const char* deploymentTarget =
|
2009-01-27 15:30:55 +00:00
|
|
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (sysroot) {
|
|
|
|
buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot));
|
|
|
|
}
|
2017-04-05 17:33:37 +00:00
|
|
|
// recompute this as it may have been changed since enable language
|
|
|
|
this->ComputeArchitectures(this->CurrentMakefile);
|
|
|
|
std::string const archs = cmJoin(this->Architectures, " ");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (archs.empty()) {
|
2015-03-27 14:46:11 +00:00
|
|
|
// Tell Xcode to use NATIVE_ARCH instead of ARCHS.
|
|
|
|
buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES"));
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2015-03-27 14:46:11 +00:00
|
|
|
// Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO).
|
2016-04-20 21:11:17 +00:00
|
|
|
buildSettings->AddAttribute("ARCHS", this->CreateString(archs));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (deploymentTarget && *deploymentTarget) {
|
2017-11-04 14:27:48 +00:00
|
|
|
buildSettings->AddAttribute(GetDeploymentPlatform(root->GetMakefile()),
|
2009-01-27 15:30:55 +00:00
|
|
|
this->CreateString(deploymentTarget));
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!this->GeneratorToolset.empty()) {
|
2012-12-20 15:16:57 +00:00
|
|
|
buildSettings->AddAttribute("GCC_VERSION",
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateString(this->GeneratorToolset));
|
|
|
|
}
|
2016-09-23 15:43:08 +00:00
|
|
|
if (this->GetLanguageEnabled("Swift")) {
|
2017-03-28 14:04:02 +00:00
|
|
|
std::string swiftVersion;
|
2016-09-23 17:25:35 +00:00
|
|
|
if (const char* vers = this->CurrentMakefile->GetDefinition(
|
|
|
|
"CMAKE_Swift_LANGUAGE_VERSION")) {
|
|
|
|
swiftVersion = vers;
|
2019-02-04 17:05:08 +00:00
|
|
|
} else if (this->XcodeVersion >= 102) {
|
|
|
|
swiftVersion = "4.0";
|
2017-03-28 14:04:02 +00:00
|
|
|
} else if (this->XcodeVersion >= 83) {
|
|
|
|
swiftVersion = "3.0";
|
|
|
|
} else {
|
|
|
|
swiftVersion = "2.3";
|
2016-09-23 17:25:35 +00:00
|
|
|
}
|
|
|
|
buildSettings->AddAttribute("SWIFT_VERSION",
|
|
|
|
this->CreateString(swiftVersion));
|
2016-09-23 15:43:08 +00:00
|
|
|
}
|
2009-07-24 19:58:23 +00:00
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string symroot = cmStrCat(root->GetCurrentBinaryDirectory(), "/build");
|
2016-04-20 21:11:17 +00:00
|
|
|
buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot));
|
2009-07-24 19:58:23 +00:00
|
|
|
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& config : configs) {
|
2016-01-03 10:55:50 +00:00
|
|
|
cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings);
|
|
|
|
|
|
|
|
// Put this last so it can override existing settings
|
|
|
|
// Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& var : this->CurrentMakefile->GetDefinitions()) {
|
|
|
|
if (var.find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
|
|
|
|
std::string attribute = var.substr(22);
|
2017-09-20 21:44:34 +00:00
|
|
|
this->FilterConfigurationAttribute(config.first, attribute);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!attribute.empty()) {
|
2019-09-22 07:53:44 +00:00
|
|
|
std::string processed = cmGeneratorExpression::Evaluate(
|
|
|
|
this->CurrentMakefile->GetDefinition(var),
|
|
|
|
this->CurrentLocalGenerator, config.first);
|
2016-01-03 10:55:50 +00:00
|
|
|
buildSettingsForCfg->AddAttribute(attribute,
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateString(processed));
|
2016-01-03 10:55:50 +00:00
|
|
|
}
|
2010-02-12 19:09:54 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-01-03 10:55:50 +00:00
|
|
|
// store per-config buildSettings into configuration object
|
2017-09-20 21:44:34 +00:00
|
|
|
config.second->AddAttribute("buildSettings", buildSettingsForCfg);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-24 19:58:23 +00:00
|
|
|
|
2010-09-29 12:38:18 +00:00
|
|
|
this->RootObject->AddAttribute("buildConfigurationList",
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CreateObjectReference(configlist));
|
2005-09-02 20:29:32 +00:00
|
|
|
|
2005-01-27 21:11:44 +00:00
|
|
|
std::vector<cmXCodeObject*> targets;
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto& generator : generators) {
|
|
|
|
if (!this->CreateXCodeTargets(generator, targets)) {
|
2016-08-19 19:50:48 +00:00
|
|
|
return false;
|
2005-01-27 21:11:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-02-17 22:54:14 +00:00
|
|
|
// loop over all targets and add link and depend info
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto t : targets) {
|
2005-02-03 22:42:55 +00:00
|
|
|
this->AddDependAndLinkInformation(t);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-02-18 17:41:03 +00:00
|
|
|
this->CreateXCodeDependHackTarget(targets);
|
2005-02-17 22:54:14 +00:00
|
|
|
// now add all targets to the root object
|
|
|
|
cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto t : targets) {
|
2005-02-03 22:42:55 +00:00
|
|
|
allTargets->AddObject(t);
|
2005-02-04 22:58:58 +00:00
|
|
|
cmXCodeObject* productRef = t->GetObject("productReference");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (productRef) {
|
2005-02-07 22:36:34 +00:00
|
|
|
productGroupChildren->AddObject(productRef->GetObject());
|
2005-01-27 21:11:44 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-03-15 16:02:08 +00:00
|
|
|
this->RootObject->AddAttribute("targets", allTargets);
|
2015-01-19 13:27:15 +00:00
|
|
|
return true;
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2019-01-30 14:33:35 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::GetObjectsDirectory(
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& projName, const std::string& configName,
|
2019-01-30 14:33:35 +00:00
|
|
|
const cmGeneratorTarget* t, const std::string& variant) const
|
2012-03-14 21:46:56 +00:00
|
|
|
{
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string dir = cmStrCat(
|
|
|
|
t->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/', projName,
|
|
|
|
".build/", configName, '/', t->GetName(), ".build/", variant);
|
2012-03-14 21:46:56 +00:00
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2017-04-05 17:33:37 +00:00
|
|
|
void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf)
|
|
|
|
{
|
|
|
|
this->Architectures.clear();
|
|
|
|
const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
|
|
|
|
const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT");
|
|
|
|
if (osxArch && sysroot) {
|
2019-08-11 09:56:59 +00:00
|
|
|
cmExpandList(std::string(osxArch), this->Architectures);
|
2017-04-05 17:33:37 +00:00
|
|
|
}
|
2017-04-05 18:14:13 +00:00
|
|
|
|
|
|
|
if (this->Architectures.empty()) {
|
|
|
|
// With no ARCHS we use ONLY_ACTIVE_ARCH.
|
|
|
|
// Look up the arch that Xcode chooses in this case.
|
2018-06-18 17:39:23 +00:00
|
|
|
if (const char* arch = mf->GetDefinition("CMAKE_XCODE_ARCHS")) {
|
2017-04-05 18:14:13 +00:00
|
|
|
this->ObjectDirArchDefault = arch;
|
2018-06-18 17:39:23 +00:00
|
|
|
// We expect only one arch but choose the first just in case.
|
|
|
|
std::string::size_type pos = this->ObjectDirArchDefault.find(';');
|
|
|
|
if (pos != std::string::npos) {
|
|
|
|
this->ObjectDirArchDefault = this->ObjectDirArchDefault.substr(0, pos);
|
|
|
|
}
|
2017-04-05 18:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-29 12:19:23 +00:00
|
|
|
this->ComputeObjectDirArch(mf);
|
2017-04-05 17:33:37 +00:00
|
|
|
}
|
|
|
|
|
2017-06-29 12:19:23 +00:00
|
|
|
void cmGlobalXCodeGenerator::ComputeObjectDirArch(cmMakefile* mf)
|
2017-04-05 18:00:27 +00:00
|
|
|
{
|
2017-06-29 12:19:23 +00:00
|
|
|
if (this->Architectures.size() > 1 || this->UseEffectivePlatformName(mf)) {
|
2017-04-21 16:57:11 +00:00
|
|
|
this->ObjectDirArch = "$(CURRENT_ARCH)";
|
|
|
|
} else if (!this->Architectures.empty()) {
|
|
|
|
this->ObjectDirArch = this->Architectures[0];
|
2017-04-05 18:00:27 +00:00
|
|
|
} else {
|
2017-04-21 16:57:11 +00:00
|
|
|
this->ObjectDirArch = this->ObjectDirArchDefault;
|
2017-04-05 18:00:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
|
2005-02-17 22:54:14 +00:00
|
|
|
std::vector<cmXCodeObject*>& targets)
|
2010-09-29 12:38:18 +00:00
|
|
|
{
|
2018-11-27 18:19:45 +00:00
|
|
|
cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!makefileStream) {
|
2019-05-14 13:16:11 +00:00
|
|
|
cmSystemTools::Error("Could not create " + this->CurrentXCodeHackMakefile);
|
2005-02-17 22:54:14 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-12-21 20:45:55 +00:00
|
|
|
makefileStream.SetCopyIfDifferent(true);
|
2005-02-17 22:54:14 +00:00
|
|
|
// one more pass for external depend information not handled
|
|
|
|
// correctly by xcode
|
2016-05-06 18:19:04 +00:00
|
|
|
/* clang-format off */
|
2005-02-17 22:54:14 +00:00
|
|
|
makefileStream << "# DO NOT EDIT\n";
|
2007-10-10 15:06:15 +00:00
|
|
|
makefileStream << "# This makefile makes sure all linkable targets are\n";
|
2011-06-06 21:34:43 +00:00
|
|
|
makefileStream << "# up-to-date with anything they link to\n"
|
|
|
|
"default:\n"
|
|
|
|
"\techo \"Do not invoke directly\"\n"
|
|
|
|
"\n";
|
2016-05-06 18:19:04 +00:00
|
|
|
/* clang-format on */
|
2017-02-18 17:23:59 +00:00
|
|
|
|
|
|
|
std::set<std::string> dummyRules;
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// Write rules to help Xcode relink things at the right time.
|
2016-05-06 18:19:04 +00:00
|
|
|
/* clang-format off */
|
2010-09-29 12:38:18 +00:00
|
|
|
makefileStream <<
|
2006-01-13 23:18:32 +00:00
|
|
|
"# Rules to remove targets that are older than anything to which they\n"
|
|
|
|
"# link. This forces Xcode to relink the targets from scratch. It\n"
|
2010-09-29 12:38:18 +00:00
|
|
|
"# does not seem to check these dependencies itself.\n";
|
2016-05-06 18:19:04 +00:00
|
|
|
/* clang-format on */
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& configName : this->CurrentConfigurationTypes) {
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto target : targets) {
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorTarget* gt = target->GetTarget();
|
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gt->GetType() == cmStateEnums::EXECUTABLE ||
|
2017-02-18 17:41:03 +00:00
|
|
|
gt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
|
2016-10-18 19:28:46 +00:00
|
|
|
gt->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
|
|
|
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
|
|
|
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
2011-06-06 21:34:43 +00:00
|
|
|
// Declare an entry point for the target post-build phase.
|
2017-11-07 07:41:47 +00:00
|
|
|
makefileStream << this->PostBuildMakeTarget(gt->GetName(), configName)
|
2011-06-06 21:34:43 +00:00
|
|
|
<< ":\n";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-06-06 21:34:43 +00:00
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gt->GetType() == cmStateEnums::EXECUTABLE ||
|
2017-02-18 17:41:03 +00:00
|
|
|
gt->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
2016-10-18 19:28:46 +00:00
|
|
|
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
|
|
|
|
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
2012-10-06 16:30:43 +00:00
|
|
|
std::string tfull = gt->GetFullPath(configName);
|
2018-02-14 15:50:14 +00:00
|
|
|
std::string trel = this->ConvertToRelativeForMake(tfull);
|
2011-06-06 21:34:43 +00:00
|
|
|
|
|
|
|
// Add this target to the post-build phases of its dependencies.
|
2019-09-04 20:17:22 +00:00
|
|
|
auto const y = target->GetDependTargets().find(configName);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (y != target->GetDependTargets().end()) {
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& deptgt : y->second) {
|
|
|
|
makefileStream << this->PostBuildMakeTarget(deptgt, configName)
|
|
|
|
<< ": " << trel << "\n";
|
2011-06-06 21:34:43 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2011-06-06 21:34:43 +00:00
|
|
|
|
2017-02-18 17:41:03 +00:00
|
|
|
std::vector<cmGeneratorTarget*> objlibs;
|
|
|
|
gt->GetObjectLibrariesCMP0026(objlibs);
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto objLib : objlibs) {
|
|
|
|
makefileStream << this->PostBuildMakeTarget(objLib->GetName(),
|
|
|
|
configName)
|
2017-02-18 17:41:03 +00:00
|
|
|
<< ": " << trel << "\n";
|
|
|
|
}
|
|
|
|
|
2011-06-06 21:34:43 +00:00
|
|
|
// Create a rule for this target.
|
|
|
|
makefileStream << trel << ":";
|
2006-01-13 23:18:32 +00:00
|
|
|
|
|
|
|
// List dependencies if any exist.
|
2019-09-04 20:17:22 +00:00
|
|
|
auto const x = target->GetDependLibraries().find(configName);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (x != target->GetDependLibraries().end()) {
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto const& deplib : x->second) {
|
2018-02-14 15:50:14 +00:00
|
|
|
std::string file = this->ConvertToRelativeForMake(deplib);
|
2017-02-18 17:23:59 +00:00
|
|
|
makefileStream << "\\\n\t" << file;
|
|
|
|
dummyRules.insert(file);
|
2006-01-13 23:18:32 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-02-18 17:41:03 +00:00
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto objLib : objlibs) {
|
2017-02-18 17:41:03 +00:00
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
const std::string objLibName = objLib->GetName();
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string d = cmStrCat(
|
2019-01-30 14:33:35 +00:00
|
|
|
this->GetObjectsDirectory(this->CurrentProject, configName, objLib,
|
2019-08-22 14:34:40 +00:00
|
|
|
OBJECT_LIBRARY_ARTIFACT_DIR),
|
|
|
|
"lib", objLibName, ".a");
|
2017-02-18 17:41:03 +00:00
|
|
|
|
2018-02-14 15:50:14 +00:00
|
|
|
std::string dependency = this->ConvertToRelativeForMake(d);
|
2017-02-18 17:41:03 +00:00
|
|
|
makefileStream << "\\\n\t" << dependency;
|
|
|
|
dummyRules.insert(dependency);
|
|
|
|
}
|
|
|
|
|
2006-01-13 23:18:32 +00:00
|
|
|
// Write the action to remove the target if it is out of date.
|
|
|
|
makefileStream << "\n";
|
|
|
|
makefileStream << "\t/bin/rm -f "
|
2018-02-14 15:50:14 +00:00
|
|
|
<< this->ConvertToRelativeForMake(tfull) << "\n";
|
2006-05-16 13:54:49 +00:00
|
|
|
// if building for more than one architecture
|
2018-01-03 12:09:54 +00:00
|
|
|
// then remove those executables as well
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Architectures.size() > 1) {
|
2019-01-30 14:33:35 +00:00
|
|
|
std::string universal = this->GetObjectsDirectory(
|
2019-01-30 14:42:02 +00:00
|
|
|
this->CurrentProject, configName, gt, "$(OBJDIR)/");
|
2017-11-07 07:41:47 +00:00
|
|
|
for (const auto& architecture : this->Architectures) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string universalFile = cmStrCat(universal, architecture, '/',
|
|
|
|
gt->GetFullName(configName));
|
2006-05-16 13:54:49 +00:00
|
|
|
makefileStream << "\t/bin/rm -f "
|
2018-02-14 15:50:14 +00:00
|
|
|
<< this->ConvertToRelativeForMake(universalFile)
|
2006-05-16 13:54:49 +00:00
|
|
|
<< "\n";
|
|
|
|
}
|
2005-02-17 22:54:14 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
makefileStream << "\n\n";
|
2005-02-17 22:54:14 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-02-18 17:23:59 +00:00
|
|
|
|
|
|
|
makefileStream << "\n\n"
|
|
|
|
<< "# For each target create a dummy rule"
|
|
|
|
<< "so the target does not have to exist\n";
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& dummyRule : dummyRules) {
|
|
|
|
makefileStream << dummyRule << ":\n";
|
2017-02-18 17:23:59 +00:00
|
|
|
}
|
2005-02-17 22:54:14 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::OutputXCodeProject(
|
|
|
|
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2017-09-20 20:50:20 +00:00
|
|
|
if (generators.empty()) {
|
2005-01-24 22:35:54 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!this->CreateXCodeObjects(root, generators)) {
|
2015-01-19 13:27:15 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string xcodeDir = cmStrCat(root->GetCurrentBinaryDirectory(), '/',
|
|
|
|
root->GetProjectName(), ".xcodeproj");
|
2019-05-14 13:16:11 +00:00
|
|
|
cmSystemTools::MakeDirectory(xcodeDir);
|
2005-11-16 18:13:39 +00:00
|
|
|
std::string xcodeProjFile = xcodeDir + "/project.pbxproj";
|
2018-11-27 18:19:45 +00:00
|
|
|
cmGeneratedFileStream fout(xcodeProjFile);
|
2005-01-24 22:35:54 +00:00
|
|
|
fout.SetCopyIfDifferent(true);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!fout) {
|
2005-01-24 22:35:54 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2005-01-24 22:35:54 +00:00
|
|
|
this->WriteXCodePBXProj(fout, root, generators);
|
2017-01-18 14:20:09 +00:00
|
|
|
|
2019-03-11 12:57:39 +00:00
|
|
|
bool hasGeneratedSchemes = this->OutputXCodeSharedSchemes(xcodeDir, root);
|
|
|
|
this->OutputXCodeWorkspaceSettings(xcodeDir, hasGeneratedSchemes);
|
2017-01-18 14:20:09 +00:00
|
|
|
|
2005-01-24 22:35:54 +00:00
|
|
|
this->ClearXCodeObjects();
|
2011-08-23 22:22:33 +00:00
|
|
|
|
|
|
|
// Since this call may have created new cache entries, save the cache:
|
|
|
|
//
|
2015-04-04 22:07:04 +00:00
|
|
|
root->GetMakefile()->GetCMakeInstance()->SaveCache(
|
2015-10-06 23:17:48 +00:00
|
|
|
root->GetBinaryDirectory());
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 12:57:39 +00:00
|
|
|
bool cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
|
|
|
|
const std::string& xcProjDir, cmLocalGenerator* root)
|
2017-01-18 14:20:09 +00:00
|
|
|
{
|
2017-06-28 20:21:01 +00:00
|
|
|
// collect all tests for the targets
|
|
|
|
std::map<std::string, cmXCodeScheme::TestObjects> testables;
|
|
|
|
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto obj : this->XCodeObjects) {
|
2017-06-28 20:21:01 +00:00
|
|
|
if (obj->GetType() != cmXCodeObject::OBJECT ||
|
|
|
|
obj->GetIsA() != cmXCodeObject::PBXNativeTarget) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!obj->GetTarget()->IsXCTestOnApple()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* testee = obj->GetTarget()->GetProperty("XCTEST_TESTEE");
|
|
|
|
if (!testee) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
testables[testee].push_back(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate scheme
|
2019-03-11 12:57:39 +00:00
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
// Since the lowest available Xcode version for testing was 6.4,
|
|
|
|
// I'm setting this as a limit then
|
|
|
|
if (this->XcodeVersion >= 64) {
|
|
|
|
for (auto obj : this->XCodeObjects) {
|
|
|
|
if (obj->GetType() == cmXCodeObject::OBJECT &&
|
|
|
|
(obj->GetIsA() == cmXCodeObject::PBXNativeTarget ||
|
|
|
|
obj->GetIsA() == cmXCodeObject::PBXAggregateTarget) &&
|
|
|
|
(root->GetMakefile()->GetCMakeInstance()->GetIsInTryCompile() ||
|
|
|
|
obj->GetTarget()->GetPropertyAsBool("XCODE_GENERATE_SCHEME"))) {
|
|
|
|
const std::string& targetName = obj->GetTarget()->GetName();
|
2019-11-18 21:01:04 +00:00
|
|
|
cmXCodeScheme schm(root, obj, testables[targetName],
|
2019-03-11 12:57:39 +00:00
|
|
|
this->CurrentConfigurationTypes,
|
|
|
|
this->XcodeVersion);
|
|
|
|
schm.WriteXCodeSharedScheme(xcProjDir,
|
|
|
|
this->RelativeToSource(xcProjDir));
|
|
|
|
ret = true;
|
|
|
|
}
|
2017-01-18 14:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-11 12:57:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2017-01-18 14:20:09 +00:00
|
|
|
}
|
|
|
|
|
2017-02-24 15:19:14 +00:00
|
|
|
void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings(
|
2019-03-11 12:57:39 +00:00
|
|
|
const std::string& xcProjDir, bool hasGeneratedSchemes)
|
2017-02-24 15:19:14 +00:00
|
|
|
{
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string xcodeSharedDataDir =
|
|
|
|
cmStrCat(xcProjDir, "/project.xcworkspace/xcshareddata");
|
2017-02-24 15:19:14 +00:00
|
|
|
cmSystemTools::MakeDirectory(xcodeSharedDataDir);
|
|
|
|
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string workspaceSettingsFile =
|
|
|
|
cmStrCat(xcodeSharedDataDir, "/WorkspaceSettings.xcsettings");
|
2017-02-24 15:19:14 +00:00
|
|
|
|
2018-11-27 18:19:45 +00:00
|
|
|
cmGeneratedFileStream fout(workspaceSettingsFile);
|
2017-02-24 15:19:14 +00:00
|
|
|
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");
|
2018-06-18 11:58:37 +00:00
|
|
|
if (this->XcodeVersion >= 100) {
|
|
|
|
xout.Element("key", "BuildSystemType");
|
|
|
|
xout.Element("string", "Original");
|
|
|
|
}
|
2019-03-11 12:57:39 +00:00
|
|
|
if (hasGeneratedSchemes) {
|
2018-06-18 11:58:37 +00:00
|
|
|
xout.Element("key",
|
|
|
|
"IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
|
|
|
|
xout.Element("false");
|
|
|
|
}
|
2017-02-24 15:19:14 +00:00
|
|
|
xout.EndElement(); // dict
|
|
|
|
xout.EndElement(); // plist
|
|
|
|
xout.EndDocument();
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
|
|
|
|
cmLocalGenerator*,
|
|
|
|
std::vector<cmLocalGenerator*>&)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2015-04-07 17:14:52 +00:00
|
|
|
SortXCodeObjects();
|
|
|
|
|
2005-01-24 22:35:54 +00:00
|
|
|
fout << "// !$*UTF8*$!\n";
|
|
|
|
fout << "{\n";
|
|
|
|
cmXCodeObject::Indent(1, fout);
|
|
|
|
fout << "archiveVersion = 1;\n";
|
|
|
|
cmXCodeObject::Indent(1, fout);
|
|
|
|
fout << "classes = {\n";
|
|
|
|
cmXCodeObject::Indent(1, fout);
|
|
|
|
fout << "};\n";
|
|
|
|
cmXCodeObject::Indent(1, fout);
|
2019-02-10 10:22:38 +00:00
|
|
|
fout << "objectVersion = 46;\n";
|
2017-04-21 16:57:11 +00:00
|
|
|
cmXCode21Object::PrintList(this->XCodeObjects, fout);
|
2005-01-24 22:35:54 +00:00
|
|
|
cmXCodeObject::Indent(1, fout);
|
2015-04-07 17:19:00 +00:00
|
|
|
fout << "rootObject = " << this->RootObject->GetId()
|
|
|
|
<< " /* Project object */;\n";
|
2005-01-24 22:35:54 +00:00
|
|
|
fout << "}\n";
|
|
|
|
}
|
|
|
|
|
2012-03-08 21:18:55 +00:00
|
|
|
const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const
|
2009-09-19 16:00:09 +00:00
|
|
|
{
|
2017-04-21 16:57:11 +00:00
|
|
|
return "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
2009-09-19 16:00:09 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::ExpandCFGIntDir(
|
|
|
|
const std::string& str, const std::string& config) const
|
2014-02-02 04:18:04 +00:00
|
|
|
{
|
|
|
|
std::string replace1 = "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
|
|
|
std::string replace2 = "$(CONFIGURATION)";
|
|
|
|
|
|
|
|
std::string tmp = str;
|
2016-05-16 14:34:04 +00:00
|
|
|
for (std::string::size_type i = tmp.find(replace1); i != std::string::npos;
|
|
|
|
i = tmp.find(replace1, i)) {
|
2014-02-02 04:18:04 +00:00
|
|
|
tmp.replace(i, replace1.size(), config);
|
|
|
|
i += config.size();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
for (std::string::size_type i = tmp.find(replace2); i != std::string::npos;
|
|
|
|
i = tmp.find(replace2, i)) {
|
2014-02-02 04:18:04 +00:00
|
|
|
tmp.replace(i, replace2.size(), config);
|
|
|
|
i += config.size();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-02-02 04:18:04 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2005-02-11 19:25:05 +00:00
|
|
|
void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry)
|
2005-01-24 22:35:54 +00:00
|
|
|
{
|
2012-11-19 15:42:24 +00:00
|
|
|
entry.Name = cmGlobalXCodeGenerator::GetActualName();
|
2011-05-27 22:12:14 +00:00
|
|
|
entry.Brief = "Generate Xcode project files.";
|
2005-01-24 22:35:54 +00:00
|
|
|
}
|
2005-02-18 18:32:51 +00:00
|
|
|
|
2018-01-31 15:20:02 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(
|
|
|
|
std::string const& p)
|
2005-02-18 18:32:51 +00:00
|
|
|
{
|
2015-06-01 17:56:46 +00:00
|
|
|
return cmSystemTools::ConvertToOutputPath(p);
|
2005-02-24 22:46:49 +00:00
|
|
|
}
|
|
|
|
|
2019-03-17 19:22:26 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
|
2009-09-22 20:18:31 +00:00
|
|
|
{
|
|
|
|
// We force conversion because Xcode breakpoints do not work unless
|
|
|
|
// they are in a file named relative to the source tree.
|
2018-11-23 01:38:29 +00:00
|
|
|
return cmSystemTools::ForceToRelativePath(
|
2016-09-19 20:54:38 +00:00
|
|
|
cmSystemTools::JoinPath(this->ProjectSourceDirectoryComponents), p);
|
2009-09-22 20:18:31 +00:00
|
|
|
}
|
|
|
|
|
2019-03-17 19:22:26 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
|
2009-09-22 20:18:31 +00:00
|
|
|
{
|
2018-11-23 18:52:26 +00:00
|
|
|
return this->CurrentLocalGenerator->MaybeConvertToRelativePath(
|
2016-09-19 20:54:38 +00:00
|
|
|
cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p);
|
2009-09-22 20:18:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-20 21:19:48 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
|
2005-02-24 20:34:14 +00:00
|
|
|
{
|
2017-05-30 19:37:46 +00:00
|
|
|
if (p.find(' ') != std::string::npos) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string t = cmStrCat('"', p, '"');
|
2016-04-20 21:19:48 +00:00
|
|
|
return t;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-04-20 21:19:48 +00:00
|
|
|
return p;
|
2005-02-24 20:34:14 +00:00
|
|
|
}
|
2006-02-03 16:36:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::AppendDirectoryForConfig(
|
|
|
|
const std::string& prefix, const std::string& config,
|
|
|
|
const std::string& suffix, std::string& dir)
|
2006-02-03 16:36:11 +00:00
|
|
|
{
|
2017-04-21 16:57:11 +00:00
|
|
|
if (!config.empty()) {
|
|
|
|
dir += prefix;
|
|
|
|
dir += config;
|
|
|
|
dir += suffix;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-02-03 16:36:11 +00:00
|
|
|
}
|
2006-02-24 18:13:14 +00:00
|
|
|
|
2014-02-04 02:20:56 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::LookupFlags(
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& varNamePrefix, const std::string& varNameLang,
|
|
|
|
const std::string& varNameSuffix, const std::string& default_flags)
|
2006-02-24 18:13:14 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!varNameLang.empty()) {
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string varName = cmStrCat(varNamePrefix, varNameLang, varNameSuffix);
|
2016-09-04 14:55:05 +00:00
|
|
|
if (const char* varValue = this->CurrentMakefile->GetDefinition(varName)) {
|
2016-05-16 14:34:04 +00:00
|
|
|
if (*varValue) {
|
2006-02-24 18:13:14 +00:00
|
|
|
return varValue;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2006-02-24 18:13:14 +00:00
|
|
|
return default_flags;
|
|
|
|
}
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2009-06-29 17:02:05 +00:00
|
|
|
void cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
|
2008-01-14 14:20:58 +00:00
|
|
|
const char* defines_list,
|
|
|
|
bool dflag)
|
|
|
|
{
|
|
|
|
// Skip this if there are no definitions.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!defines_list) {
|
2008-01-14 14:20:58 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-01-14 14:20:58 +00:00
|
|
|
|
|
|
|
// Expand the list of definitions.
|
2019-08-23 14:17:39 +00:00
|
|
|
std::vector<std::string> defines = cmExpandedList(defines_list);
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2009-07-29 20:40:07 +00:00
|
|
|
// Store the definitions in the string.
|
|
|
|
this->AppendDefines(defs, defines, dflag);
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::AppendDefines(
|
|
|
|
BuildObjectListOrString& defs, std::vector<std::string> const& defines,
|
|
|
|
bool dflag)
|
2009-07-29 20:40:07 +00:00
|
|
|
{
|
2008-01-14 14:20:58 +00:00
|
|
|
// GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions.
|
2009-07-29 20:40:07 +00:00
|
|
|
std::string def;
|
2017-09-20 21:44:34 +00:00
|
|
|
for (auto const& define : defines) {
|
2009-07-29 20:40:07 +00:00
|
|
|
// Start with -D if requested.
|
2019-08-22 14:34:40 +00:00
|
|
|
def = cmStrCat(dflag ? "-D" : "", define);
|
2009-07-29 20:40:07 +00:00
|
|
|
|
|
|
|
// Append the flag with needed escapes.
|
|
|
|
std::string tmp;
|
|
|
|
this->AppendFlag(tmp, def);
|
2016-04-20 21:14:52 +00:00
|
|
|
defs.Add(tmp);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-29 20:40:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
|
2017-12-15 10:00:52 +00:00
|
|
|
std::string const& flag) const
|
2009-07-29 20:40:07 +00:00
|
|
|
{
|
|
|
|
// Short-circuit for an empty flag.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (flag.empty()) {
|
2009-07-29 20:40:07 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-29 20:40:07 +00:00
|
|
|
|
|
|
|
// Separate from previous flags.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!flags.empty()) {
|
2009-07-29 20:40:07 +00:00
|
|
|
flags += " ";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-07-29 20:40:07 +00:00
|
|
|
|
|
|
|
// Check if the flag needs quoting.
|
|
|
|
bool quoteFlag =
|
2017-05-30 19:37:46 +00:00
|
|
|
flag.find_first_of("`~!@#$%^&*()+={}[]|:;\"'<>,.? ") != std::string::npos;
|
2009-07-29 20:40:07 +00:00
|
|
|
|
|
|
|
// We escape a flag as follows:
|
|
|
|
// - Place each flag in single quotes ''
|
2015-12-27 15:33:46 +00:00
|
|
|
// - Escape a single quote as \'
|
|
|
|
// - Escape a backslash as \\ since it itself is an escape
|
2008-01-14 14:20:58 +00:00
|
|
|
// Note that in the code below we need one more level of escapes for
|
|
|
|
// C string syntax in this source file.
|
2009-07-29 20:40:07 +00:00
|
|
|
//
|
|
|
|
// The final level of escaping is done when the string is stored
|
|
|
|
// into the project file by cmXCodeObject::PrintString.
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (quoteFlag) {
|
2008-01-14 14:20:58 +00:00
|
|
|
// Open single quote.
|
2009-07-29 20:40:07 +00:00
|
|
|
flags += "'";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2009-07-29 20:40:07 +00:00
|
|
|
// Flag value with escaped quotes and backslashes.
|
2017-11-07 07:41:47 +00:00
|
|
|
for (auto c : flag) {
|
|
|
|
if (c == '\'') {
|
2019-02-10 10:22:38 +00:00
|
|
|
flags += "'\\''";
|
2017-11-07 07:41:47 +00:00
|
|
|
} else if (c == '\\') {
|
2015-12-27 15:33:46 +00:00
|
|
|
flags += "\\\\";
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2017-11-07 07:41:47 +00:00
|
|
|
flags += c;
|
2009-07-29 20:40:07 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-01-14 14:20:58 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (quoteFlag) {
|
2008-01-14 14:20:58 +00:00
|
|
|
// Close single quote.
|
2009-07-29 20:40:07 +00:00
|
|
|
flags += "'";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-01-14 14:20:58 +00:00
|
|
|
}
|
2008-07-03 17:28:54 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation(
|
|
|
|
cmGeneratorTarget* target)
|
2008-07-03 17:28:54 +00:00
|
|
|
{
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string plist =
|
|
|
|
cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
|
|
|
|
"/CMakeFiles/", target->GetName(), ".dir/Info.plist");
|
2008-07-03 17:28:54 +00:00
|
|
|
return plist;
|
|
|
|
}
|
2009-12-04 17:09:01 +00:00
|
|
|
|
|
|
|
// Return true if the generated build tree may contain multiple builds.
|
|
|
|
// i.e. "Can I build Debug and Release in the same tree?"
|
2016-05-31 11:53:19 +00:00
|
|
|
bool cmGlobalXCodeGenerator::IsMultiConfig() const
|
2009-12-04 17:09:01 +00:00
|
|
|
{
|
|
|
|
// Newer Xcode versions are multi config:
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-13 20:41:28 +00:00
|
|
|
|
2017-04-11 18:08:19 +00:00
|
|
|
bool cmGlobalXCodeGenerator::HasKnownObjectFileLocation(
|
|
|
|
std::string* reason) const
|
|
|
|
{
|
|
|
|
if (this->ObjectDirArch.find('$') != std::string::npos) {
|
2017-08-22 21:42:36 +00:00
|
|
|
if (reason != nullptr) {
|
2017-04-11 18:08:19 +00:00
|
|
|
*reason = " under Xcode with multiple architectures";
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-15 22:23:31 +00:00
|
|
|
bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const
|
|
|
|
{
|
|
|
|
const char* epnValue =
|
|
|
|
this->GetCMakeInstance()->GetState()->GetGlobalProperty(
|
|
|
|
"XCODE_EMIT_EFFECTIVE_PLATFORM_NAME");
|
|
|
|
|
|
|
|
if (!epnValue) {
|
2017-11-04 12:29:25 +00:00
|
|
|
return mf->PlatformIsAppleEmbedded();
|
2017-01-15 22:23:31 +00:00
|
|
|
}
|
|
|
|
|
2019-08-17 09:04:11 +00:00
|
|
|
return cmIsOn(epnValue);
|
2017-01-15 22:23:31 +00:00
|
|
|
}
|
|
|
|
|
2017-03-22 21:49:38 +00:00
|
|
|
bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const
|
|
|
|
{
|
|
|
|
// Xcode determines Resource location itself
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
|
|
|
|
cmGeneratorTarget* gt) const
|
2014-03-12 20:09:20 +00:00
|
|
|
{
|
2014-06-05 13:11:00 +00:00
|
|
|
std::string configName = this->GetCMakeCFGIntDir();
|
2019-08-22 14:34:40 +00:00
|
|
|
std::string dir =
|
|
|
|
cmStrCat(this->GetObjectsDirectory("$(PROJECT_NAME)", configName, gt,
|
|
|
|
"$(OBJECT_FILE_DIR_normal:base)/"),
|
|
|
|
this->ObjectDirArch, '/');
|
2012-03-13 20:41:28 +00:00
|
|
|
gt->ObjectDirectory = dir;
|
|
|
|
}
|
2017-11-04 14:27:48 +00:00
|
|
|
|
|
|
|
std::string cmGlobalXCodeGenerator::GetDeploymentPlatform(const cmMakefile* mf)
|
|
|
|
{
|
|
|
|
switch (mf->GetAppleSDKType()) {
|
|
|
|
case cmMakefile::AppleSDK::AppleTVOS:
|
|
|
|
case cmMakefile::AppleSDK::AppleTVSimulator:
|
|
|
|
return "TVOS_DEPLOYMENT_TARGET";
|
|
|
|
|
|
|
|
case cmMakefile::AppleSDK::IPhoneOS:
|
|
|
|
case cmMakefile::AppleSDK::IPhoneSimulator:
|
|
|
|
return "IPHONEOS_DEPLOYMENT_TARGET";
|
|
|
|
|
|
|
|
case cmMakefile::AppleSDK::WatchOS:
|
|
|
|
case cmMakefile::AppleSDK::WatchSimulator:
|
|
|
|
return "WATCHOS_DEPLOYMENT_TARGET";
|
|
|
|
|
|
|
|
case cmMakefile::AppleSDK::MacOS:
|
|
|
|
default:
|
|
|
|
return "MACOSX_DEPLOYMENT_TARGET";
|
|
|
|
}
|
|
|
|
}
|