summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-02-22 19:30:58 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-02-22 19:30:58 (GMT)
commit64d997a78c1f2a24a8fd1978856a2b5f4a97a0f9 (patch)
treea3b002c20c5717e463455b985c031e02b12b861f /Source
parent6ec1ae2108afb8d9a72783fe945ad2410f08b4c1 (diff)
parentcabc407912bb3bc0bb954e317a999cb2ee64de57 (diff)
downloadCMake-64d997a78c1f2a24a8fd1978856a2b5f4a97a0f9.zip
CMake-64d997a78c1f2a24a8fd1978856a2b5f4a97a0f9.tar.gz
CMake-64d997a78c1f2a24a8fd1978856a2b5f4a97a0f9.tar.bz2
Merge topic 'fix-11295-support-plugin-bundles-on-mac'
cabc407 CFBundle Test: Add PATHS for finding Rez (#11295) 5457b82 Add support for CFBundle targets on the Mac (#11295)
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportFileGenerator.cxx6
-rw-r--r--Source/cmExportInstallFileGenerator.cxx14
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx55
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx49
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h1
-rw-r--r--Source/cmSourceFile.cxx6
-rw-r--r--Source/cmTarget.cxx24
-rw-r--r--Source/cmTarget.h3
8 files changed, 150 insertions, 8 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index e2a6035..9e5c91e 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -325,6 +325,12 @@ cmExportFileGenerator
os << "SET_PROPERTY(TARGET " << targetName
<< " PROPERTY MACOSX_BUNDLE 1)\n";
}
+
+ if (target->IsCFBundleOnApple())
+ {
+ os << "SET_PROPERTY(TARGET " << targetName
+ << " PROPERTY BUNDLE 1)\n";
+ }
os << "\n";
}
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 717571c..23ff5fb 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -263,6 +263,20 @@ cmExportInstallFileGenerator
value += ".framework/";
value += itgen->GetInstallFilename(target, config);
}
+ else if(target->IsCFBundleOnApple())
+ {
+ const char *ext = target->GetProperty("BUNDLE_EXTENSION");
+ if (!ext)
+ {
+ ext = "bundle";
+ }
+
+ value += itgen->GetInstallFilename(target, config);
+ value += ".";
+ value += ext;
+ value += "/";
+ value += itgen->GetInstallFilename(target, config);
+ }
else if(target->IsAppBundleOnApple())
{
value += itgen->GetInstallFilename(target, config);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 358721f..df679ea 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -578,6 +578,12 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
}
}
+ if(cmtarget.IsCFBundleOnApple())
+ {
+ cmtarget.SetProperty("PREFIX", "");
+ cmtarget.SetProperty("SUFFIX", "");
+ }
+
// Add the fileRef to the top level Resources group/folder if it is not
// already there.
//
@@ -812,6 +818,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// some build phases only apply to bundles and/or frameworks
bool isFrameworkTarget = cmtarget.IsFrameworkOnApple();
bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE");
+ bool isCFBundleTarget = cmtarget.IsCFBundleOnApple();
cmXCodeObject* buildFiles = 0;
@@ -857,7 +864,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// create resource build phase - only for framework or bundle targets
cmXCodeObject* resourceBuildPhase = 0;
- if (!resourceFiles.empty() && (isFrameworkTarget || isBundleTarget))
+ if (!resourceFiles.empty() &&
+ (isFrameworkTarget || isBundleTarget || isCFBundleTarget))
{
resourceBuildPhase =
this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
@@ -878,7 +886,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// create vector of "non-resource content file" build phases - only for
// framework or bundle targets
std::vector<cmXCodeObject*> contentBuildPhases;
- if (isFrameworkTarget || isBundleTarget)
+ if (isFrameworkTarget || isBundleTarget || isCFBundleTarget)
{
typedef std::map<cmStdString, std::vector<cmSourceFile*> >
mapOfVectorOfSourceFiles;
@@ -1605,7 +1613,33 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
buildSettings->AddAttribute("LIBRARY_STYLE",
this->CreateString("BUNDLE"));
- if(this->XcodeVersion >= 22)
+ if (target.GetPropertyAsBool("BUNDLE"))
+ {
+ // 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_", lang, "_FLAGS",
+ "-bundle");
+ if(!createFlags.empty())
+ {
+ extraLinkOptions += " ";
+ extraLinkOptions += createFlags;
+ }
+ std::string plist = this->ComputeInfoPListLocation(target);
+ // 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(&target, "$(EXECUTABLE_NAME)",
+ plist.c_str());
+ std::string path =
+ this->ConvertToRelativeForXCode(plist.c_str());
+ buildSettings->AddAttribute("INFOPLIST_FILE",
+ this->CreateString(path.c_str()));
+ }
+ else if(this->XcodeVersion >= 22)
{
buildSettings->AddAttribute("MACH_O_TYPE",
this->CreateString("mh_bundle"));
@@ -1644,7 +1678,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
std::string plist = this->ComputeInfoPListLocation(target);
// Xcode will create the final version of Info.plist at build time,
- // so let it replace the framework name. This avoids creating
+ // so let it replace the framework name. This avoids creating
// a per-configuration Info.plist file.
this->CurrentLocalGenerator
->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)",
@@ -2043,7 +2077,10 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget)
case cmTarget::STATIC_LIBRARY:
return "archive.ar";
case cmTarget::MODULE_LIBRARY:
- return ((this->XcodeVersion >= 22)?
+ if (cmtarget.IsCFBundleOnApple())
+ return "wrapper.plug-in";
+ else
+ return ((this->XcodeVersion >= 22)?
"compiled.mach-o.executable" : "compiled.mach-o.dylib");
case cmTarget::SHARED_LIBRARY:
return (cmtarget.GetPropertyAsBool("FRAMEWORK")?
@@ -2063,8 +2100,12 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget)
case cmTarget::STATIC_LIBRARY:
return "com.apple.product-type.library.static";
case cmTarget::MODULE_LIBRARY:
- return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" :
- "com.apple.product-type.library.dynamic");
+ if (cmtarget.IsCFBundleOnApple())
+ return "com.apple.product-type.bundle";
+ else
+ return ((this->XcodeVersion >= 22)?
+ "com.apple.product-type.tool" :
+ "com.apple.product-type.library.dynamic");
case cmTarget::SHARED_LIBRARY:
return (cmtarget.GetPropertyAsBool("FRAMEWORK")?
"com.apple.product-type.framework" :
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 049a338..1e9a670 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -26,6 +26,12 @@ cmMakefileLibraryTargetGenerator
::cmMakefileLibraryTargetGenerator(cmTarget* target):
cmMakefileTargetGenerator(target)
{
+ if(this->Target->IsCFBundleOnApple())
+ {
+ target->SetProperty("PREFIX", "");
+ target->SetProperty("SUFFIX", "");
+ }
+
this->CustomCommandDriver = OnDepends;
this->Target->GetLibraryNames(
this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
@@ -41,6 +47,20 @@ cmMakefileLibraryTargetGenerator
this->MacContentDirectory += this->FrameworkVersion;
this->MacContentDirectory += "/";
}
+ else if(this->Target->IsCFBundleOnApple())
+ {
+ this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
+ this->MacContentDirectory += "/";
+ this->MacContentDirectory += this->TargetNameOut;
+ this->MacContentDirectory += ".";
+ const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
+ if (!ext)
+ {
+ ext = "bundle";
+ }
+ this->MacContentDirectory += ext;
+ this->MacContentDirectory += "/Contents/";
+ }
}
//----------------------------------------------------------------------------
@@ -301,6 +321,27 @@ cmMakefileLibraryTargetGenerator
}
//----------------------------------------------------------------------------
+void
+cmMakefileLibraryTargetGenerator::CreateCFBundle(std::string& targetName,
+ std::string& outpath)
+{
+ // Compute bundle directory names.
+ outpath = this->MacContentDirectory;
+ outpath += "MacOS";
+ cmSystemTools::MakeDirectory(outpath.c_str());
+ this->Makefile->AddCMakeOutputFile(outpath.c_str());
+ outpath += "/";
+
+ // Configure the Info.plist file. Note that it needs the executable name
+ // to be set.
+ std::string plist = this->MacContentDirectory + "Info.plist";
+ this->LocalGenerator->GenerateAppleInfoPList(this->Target,
+ targetName.c_str(),
+ plist.c_str());
+ this->Makefile->AddCMakeOutputFile(plist.c_str());
+}
+
+//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteLibraryRules
(const char* linkRuleVar, const char* extraFlags, bool relink)
{
@@ -354,6 +395,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
outpath = this->MacContentDirectory;
this->CreateFramework(targetName);
}
+ else if(this->Target->IsCFBundleOnApple())
+ {
+ outpath = this->Target->GetDirectory(this->ConfigName);
+ outpath += "/";
+ this->CreateCFBundle(targetName, outpath);
+ }
else if(relink)
{
outpath = this->Makefile->GetStartOutputDirectory();
@@ -417,6 +464,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
buildEcho += " shared library ";
break;
case cmTarget::MODULE_LIBRARY:
+ if (this->Target->IsCFBundleOnApple())
+ buildEcho += " CFBundle";
buildEcho += " shared module ";
break;
default:
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 2f085ad..f3c47db 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -33,6 +33,7 @@ protected:
// MacOSX Framework support methods
void WriteFrameworkRules(bool relink);
void CreateFramework(std::string const& targetName);
+ void CreateCFBundle(std::string& targetName, std::string& outpath);
// Store the computd framework version for OS X Frameworks.
std::string FrameworkVersion;
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index ed1da7b..42d3f06 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -482,17 +482,21 @@ void cmSourceFile::DefineProperties(cmake *cm)
cm->DefineProperty
("MACOSX_PACKAGE_LOCATION", cmProperty::SOURCE_FILE,
- "Place a source file inside a Mac OS X bundle or framework.",
+ "Place a source file inside a Mac OS X bundle, CFBundle, or framework.",
"Executable targets with the MACOSX_BUNDLE property set are built "
"as Mac OS X application bundles on Apple platforms. "
"Shared library targets with the FRAMEWORK property set are built "
"as Mac OS X frameworks on Apple platforms. "
+ "Module library targets with the BUNDLE property set are built "
+ "as Mac OS X CFBundle bundles on Apple platforms. "
"Source files listed in the target with this property set will "
"be copied to a directory inside the bundle or framework content "
"folder specified by the property value. "
"For bundles the content folder is \"<name>.app/Contents\". "
"For frameworks the content folder is "
"\"<name>.framework/Versions/<version>\". "
+ "For cfbundles the content folder is "
+ "\"<name>.bundle/Contents\" (unless the extension is changed). "
"See the PUBLIC_HEADER, PRIVATE_HEADER, and RESOURCE target "
"properties for specifying files meant for Headers, PrivateHeaders, "
"or Resources directories.");
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 72efce3..75ff712 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -188,6 +188,22 @@ void cmTarget::DefineProperties(cmake *cm)
"the target is built.");
cm->DefineProperty
+ ("BUNDLE", cmProperty::TARGET,
+ "This target is a CFBundle on the Mac.",
+ "If a module library target has this property set to true it will "
+ "be built as a CFBundle when built on the mac. It will have the "
+ "directory structure required for a CFBundle and will be suitable "
+ "to be used for creating Browser Plugins or other application "
+ "resources.");
+
+ cm->DefineProperty
+ ("BUNDLE_EXTENSION", cmProperty::TARGET,
+ "The file extension used to name a BUNDLE target on the Mac.",
+ "The default value is \"bundle\" - you can also use \"plugin\" or "
+ "whatever file extension is required by the host app for your "
+ "bundle.");
+
+ cm->DefineProperty
("FRAMEWORK", cmProperty::TARGET,
"This target is a framework on the Mac.",
"If a shared library target has this property set to true it will "
@@ -1211,6 +1227,14 @@ bool cmTarget::IsAppBundleOnApple()
}
//----------------------------------------------------------------------------
+bool cmTarget::IsCFBundleOnApple()
+{
+ return (this->GetType() == cmTarget::MODULE_LIBRARY &&
+ this->Makefile->IsOn("APPLE") &&
+ this->GetPropertyAsBool("BUNDLE"));
+}
+
+//----------------------------------------------------------------------------
class cmTargetTraceDependencies
{
public:
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index f2b7d61..b0e20ba 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -430,6 +430,9 @@ public:
Apple. */
bool IsFrameworkOnApple();
+ /** Return whether this target is a CFBundle (plugin) on Apple. */
+ bool IsCFBundleOnApple();
+
/** Return whether this target is an executable Bundle on Apple. */
bool IsAppBundleOnApple();