summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx165
1 files changed, 90 insertions, 75 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 4ff612d..8424ded 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -182,7 +182,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
#endif
}
-void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
+bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
{
// The Xcode generator knows how to lookup its build tool
// directly instead of needing a helper module to do it, so we
@@ -191,6 +191,7 @@ void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
mf->AddDefinition("CMAKE_MAKE_PROGRAM",
this->GetXcodeBuildCommand().c_str());
}
+ return true;
}
std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
@@ -220,6 +221,19 @@ bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
cmMakefile* mf)
{
if (this->XcodeVersion >= 30) {
+ if (ts.find_first_of(",=") != ts.npos) {
+ 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 */
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
this->GeneratorToolset = ts;
if (!this->GeneratorToolset.empty()) {
mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
@@ -244,7 +258,7 @@ void cmGlobalXCodeGenerator::EnableLanguage(
"Semicolon separated list of supported configuration types, "
"only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
"anything else will be ignored.",
- cmState::STRING);
+ cmStateEnums::STRING);
}
}
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
@@ -431,7 +445,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
l != tgts.end(); l++) {
cmGeneratorTarget* target = *l;
- if (target->GetType() == cmState::GLOBAL_TARGET) {
+ if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
@@ -446,12 +460,12 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// this will make sure that when the next target is built
// things are up-to-date
if (!makeHelper.empty() &&
- (target->GetType() == cmState::EXECUTABLE ||
+ (target->GetType() == cmStateEnums::EXECUTABLE ||
// Nope - no post-build for OBJECT_LIRBRARY
- // target->GetType() == cmState::OBJECT_LIBRARY ||
- target->GetType() == cmState::STATIC_LIBRARY ||
- target->GetType() == cmState::SHARED_LIBRARY ||
- target->GetType() == cmState::MODULE_LIBRARY)) {
+ // target->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ target->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ target->GetType() == cmStateEnums::MODULE_LIBRARY)) {
makeHelper[makeHelper.size() - 1] = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
cmCustomCommandLines commandLines;
@@ -462,7 +476,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str());
}
- if (target->GetType() != cmState::INTERFACE_LIBRARY &&
+ if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
!target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
allbuild->AddUtility(target->GetName());
}
@@ -942,12 +956,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
continue;
}
- if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- if (gtgt->GetType() == cmState::UTILITY ||
- gtgt->GetType() == cmState::GLOBAL_TARGET) {
+ if (gtgt->GetType() == cmStateEnums::UTILITY ||
+ gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
cmXCodeObject* t = this->CreateUtilityTarget(gtgt);
if (!t) {
return false;
@@ -1175,9 +1189,9 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguages()
void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
{
// This matters only for targets that link.
- if (gtgt->GetType() != cmState::EXECUTABLE &&
- gtgt->GetType() != cmState::SHARED_LIBRARY &&
- gtgt->GetType() != cmState::MODULE_LIBRARY) {
+ if (gtgt->GetType() != cmStateEnums::EXECUTABLE &&
+ gtgt->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ gtgt->GetType() != cmStateEnums::MODULE_LIBRARY) {
return;
}
@@ -1255,7 +1269,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
std::vector<cmCustomCommand> const& prelink = gtgt->GetPreLinkCommands();
std::vector<cmCustomCommand> postbuild = gtgt->GetPostBuildCommands();
- if (gtgt->GetType() == cmState::SHARED_LIBRARY &&
+ if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY &&
!gtgt->IsFrameworkOnApple()) {
cmCustomCommandLines cmd;
cmd.resize(1);
@@ -1577,16 +1591,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
cmXCodeObject* buildSettings,
const std::string& configName)
{
- if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return;
}
std::string defFlags;
- bool shared = ((gtgt->GetType() == cmState::SHARED_LIBRARY) ||
- (gtgt->GetType() == cmState::MODULE_LIBRARY));
- bool binary = ((gtgt->GetType() == cmState::OBJECT_LIBRARY) ||
- (gtgt->GetType() == cmState::STATIC_LIBRARY) ||
- (gtgt->GetType() == cmState::EXECUTABLE) || shared);
+ 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);
// Compute the compilation flags for each language.
std::set<std::string> languages;
@@ -1640,11 +1654,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string extraLinkOptionsVar;
std::string extraLinkOptions;
- if (gtgt->GetType() == cmState::EXECUTABLE) {
+ if (gtgt->GetType() == cmStateEnums::EXECUTABLE) {
extraLinkOptionsVar = "CMAKE_EXE_LINKER_FLAGS";
- } else if (gtgt->GetType() == cmState::SHARED_LIBRARY) {
+ } else if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) {
extraLinkOptionsVar = "CMAKE_SHARED_LINKER_FLAGS";
- } else if (gtgt->GetType() == cmState::MODULE_LIBRARY) {
+ } else if (gtgt->GetType() == cmStateEnums::MODULE_LIBRARY) {
extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS";
}
if (!extraLinkOptionsVar.empty()) {
@@ -1652,8 +1666,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
extraLinkOptions, extraLinkOptionsVar, configName);
}
- if (gtgt->GetType() == cmState::OBJECT_LIBRARY ||
- gtgt->GetType() == cmState::STATIC_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) {
this->CurrentLocalGenerator->GetStaticLibraryFlags(
extraLinkOptions, cmSystemTools::UpperCase(configName), gtgt);
} else {
@@ -1723,10 +1737,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Set attributes to specify the proper name for the target.
std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
- if (gtgt->GetType() == cmState::STATIC_LIBRARY ||
- gtgt->GetType() == cmState::SHARED_LIBRARY ||
- gtgt->GetType() == cmState::MODULE_LIBRARY ||
- gtgt->GetType() == cmState::EXECUTABLE) {
+ if (gtgt->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ gtgt->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ gtgt->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ gtgt->GetType() == cmStateEnums::EXECUTABLE) {
if (this->XcodeVersion >= 21) {
if (!gtgt->UsesDefaultOutputDir(configName, false)) {
std::string pncdir = gtgt->GetDirectory(configName);
@@ -1746,7 +1760,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CreateString(pnprefix));
buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
this->CreateString(pnsuffix));
- } else if (gtgt->GetType() == cmState::OBJECT_LIBRARY) {
+ } else if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
pnprefix = "lib";
pnbase = gtgt->GetName();
pnsuffix = ".a";
@@ -1769,14 +1783,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Handle settings for each target type.
switch (gtgt->GetType()) {
- case cmState::OBJECT_LIBRARY:
- case cmState::STATIC_LIBRARY: {
+ case cmStateEnums::OBJECT_LIBRARY:
+ case cmStateEnums::STATIC_LIBRARY: {
buildSettings->AddAttribute("LIBRARY_STYLE",
this->CreateString("STATIC"));
break;
}
- case cmState::MODULE_LIBRARY: {
+ case cmStateEnums::MODULE_LIBRARY: {
buildSettings->AddAttribute("LIBRARY_STYLE",
this->CreateString("BUNDLE"));
if (gtgt->IsCFBundleOnApple()) {
@@ -1826,7 +1840,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
}
break;
}
- case cmState::SHARED_LIBRARY: {
+ case cmStateEnums::SHARED_LIBRARY: {
if (gtgt->GetPropertyAsBool("FRAMEWORK")) {
std::string fw_version = gtgt->GetFrameworkVersion();
buildSettings->AddAttribute("FRAMEWORK_VERSION",
@@ -1859,7 +1873,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CreateString("DYNAMIC"));
break;
}
- case cmState::EXECUTABLE: {
+ case cmStateEnums::EXECUTABLE: {
// Add the flags to create an executable.
std::string createFlags =
this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
@@ -2038,7 +2052,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Create the INSTALL_PATH attribute.
std::string install_name_dir;
- if (gtgt->GetType() == cmState::SHARED_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) {
// Get the install_name directory for the build tree.
install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName);
// Xcode doesn't create the correct install_name in some cases.
@@ -2111,7 +2125,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
}
// Runtime version information.
- if (gtgt->GetType() == cmState::SHARED_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) {
int major;
int minor;
int patch;
@@ -2206,7 +2220,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
this->XCodeObjectMap[gtgt] = target;
// Add source files without build rules for editing convenience.
- if (gtgt->GetType() == cmState::UTILITY) {
+ if (gtgt->GetType() == cmStateEnums::UTILITY) {
std::vector<cmSourceFile*> sources;
if (!gtgt->GetConfigCommonSourceFiles(sources)) {
return 0;
@@ -2272,8 +2286,8 @@ const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
cmGeneratorTarget const* target) const
{
if (this->XcodeVersion >= 60 &&
- (target->GetType() == cmState::STATIC_LIBRARY ||
- target->GetType() == cmState::OBJECT_LIBRARY)) {
+ (target->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ target->GetType() == cmStateEnums::OBJECT_LIBRARY)) {
return "OTHER_LIBTOOLFLAGS";
} else {
return "OTHER_LDFLAGS";
@@ -2284,10 +2298,10 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
cmGeneratorTarget* target)
{
switch (target->GetType()) {
- case cmState::OBJECT_LIBRARY:
- case cmState::STATIC_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ case cmStateEnums::STATIC_LIBRARY:
return "archive.ar";
- case cmState::MODULE_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
if (target->IsXCTestOnApple())
return "wrapper.cfbundle";
else if (target->IsCFBundleOnApple())
@@ -2295,11 +2309,11 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
else
return ((this->XcodeVersion >= 22) ? "compiled.mach-o.executable"
: "compiled.mach-o.dylib");
- case cmState::SHARED_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
return (target->GetPropertyAsBool("FRAMEWORK")
? "wrapper.framework"
: "compiled.mach-o.dylib");
- case cmState::EXECUTABLE:
+ case cmStateEnums::EXECUTABLE:
return "compiled.mach-o.executable";
default:
break;
@@ -2311,10 +2325,10 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
cmGeneratorTarget* target)
{
switch (target->GetType()) {
- case cmState::OBJECT_LIBRARY:
- case cmState::STATIC_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ case cmStateEnums::STATIC_LIBRARY:
return "com.apple.product-type.library.static";
- case cmState::MODULE_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
if (target->IsXCTestOnApple())
return "com.apple.product-type.bundle.unit-test";
else if (target->IsCFBundleOnApple())
@@ -2323,11 +2337,11 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
return ((this->XcodeVersion >= 22)
? "com.apple.product-type.tool"
: "com.apple.product-type.library.dynamic");
- case cmState::SHARED_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
return (target->GetPropertyAsBool("FRAMEWORK")
? "com.apple.product-type.framework"
: "com.apple.product-type.library.dynamic");
- case cmState::EXECUTABLE:
+ case cmStateEnums::EXECUTABLE:
return (target->GetPropertyAsBool("MACOSX_BUNDLE")
? "com.apple.product-type.application"
: "com.apple.product-type.tool");
@@ -2340,7 +2354,7 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases)
{
- if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return 0;
}
cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
@@ -2367,7 +2381,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
fileRef->AddAttribute("explicitFileType", this->CreateString(fileType));
}
std::string fullName;
- if (gtgt->GetType() == cmState::OBJECT_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
fullName = "lib";
fullName += gtgt->GetName();
fullName += ".a";
@@ -2419,8 +2433,9 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
return storedGUID;
}
- this->CMakeInstance->AddCacheEntry(
- guidStoreName, id.c_str(), "Stored Xcode object GUID", cmState::INTERNAL);
+ this->CMakeInstance->AddCacheEntry(guidStoreName, id.c_str(),
+ "Stored Xcode object GUID",
+ cmStateEnums::INTERNAL);
return id;
}
@@ -2514,7 +2529,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
cmSystemTools::Error("Error no target on xobject\n");
return;
}
- if (gt->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return;
}
@@ -2551,8 +2566,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
}
// Skip link information for object libraries.
- if (gt->GetType() == cmState::OBJECT_LIBRARY ||
- gt->GetType() == cmState::STATIC_LIBRARY) {
+ if (gt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ gt->GetType() == cmStateEnums::STATIC_LIBRARY) {
continue;
}
@@ -2607,7 +2622,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
if (li->IsPath) {
linkLibs += this->XCodeEscapePath(li->Value);
} else if (!li->Target ||
- li->Target->GetType() != cmState::INTERFACE_LIBRARY) {
+ li->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
linkLibs += li->Value;
}
if (li->Target && !li->Target->IsImported()) {
@@ -2636,10 +2651,10 @@ bool cmGlobalXCodeGenerator::CreateGroups(
// end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source
// groups:
//
- if (gtgt->GetType() == cmState::GLOBAL_TARGET) {
+ if (gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
- if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
+ if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -2710,8 +2725,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
{
std::string s;
std::string target;
- const char* targetFolder = gtgt->GetProperty("FOLDER");
- if (targetFolder) {
+ const std::string targetFolder = gtgt->GetEffectiveFolderName();
+ if (!targetFolder.empty()) {
target = targetFolder;
target += "/";
}
@@ -3136,20 +3151,20 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
cmXCodeObject* target = *i;
cmGeneratorTarget* gt = target->GetTarget();
- if (gt->GetType() == cmState::EXECUTABLE ||
+ if (gt->GetType() == cmStateEnums::EXECUTABLE ||
// Nope - no post-build for OBJECT_LIRBRARY
- // gt->GetType() == cmState::OBJECT_LIBRARY ||
- gt->GetType() == cmState::STATIC_LIBRARY ||
- gt->GetType() == cmState::SHARED_LIBRARY ||
- gt->GetType() == cmState::MODULE_LIBRARY) {
+ // gt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
+ gt->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
// Declare an entry point for the target post-build phase.
makefileStream << this->PostBuildMakeTarget(gt->GetName(), *ct)
<< ":\n";
}
- if (gt->GetType() == cmState::EXECUTABLE ||
- gt->GetType() == cmState::SHARED_LIBRARY ||
- gt->GetType() == cmState::MODULE_LIBRARY) {
+ if (gt->GetType() == cmStateEnums::EXECUTABLE ||
+ gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
std::string tfull = gt->GetFullPath(configName);
std::string trel = this->ConvertToRelativeForMake(tfull.c_str());
@@ -3325,14 +3340,14 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p)
{
// We force conversion because Xcode breakpoints do not work unless
// they are in a file named relative to the source tree.
- return this->CurrentLocalGenerator->ConvertToRelativePath(
- this->ProjectSourceDirectoryComponents, p, true);
+ return cmOutputConverter::ForceToRelativePath(
+ cmSystemTools::JoinPath(this->ProjectSourceDirectoryComponents), p);
}
std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
{
return this->CurrentLocalGenerator->ConvertToRelativePath(
- this->ProjectOutputDirectoryComponents, p);
+ cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p);
}
std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)