mirror of
https://github.com/reactos/CMake.git
synced 2024-12-14 07:09:22 +00:00
86578eccf2
Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
226 lines
6.8 KiB
C++
226 lines
6.8 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
#include "cmOSXBundleGenerator.h"
|
|
|
|
#include <cmConfigure.h>
|
|
|
|
#include "cmGeneratorTarget.h"
|
|
#include "cmLocalGenerator.h"
|
|
#include "cmMakefile.h"
|
|
#include "cmSystemTools.h"
|
|
#include "cmTarget.h"
|
|
|
|
#include <cassert>
|
|
|
|
class cmSourceFile;
|
|
|
|
cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target,
|
|
const std::string& configName)
|
|
: GT(target)
|
|
, Makefile(target->Target->GetMakefile())
|
|
, LocalGenerator(target->GetLocalGenerator())
|
|
, ConfigName(configName)
|
|
, MacContentFolders(CM_NULLPTR)
|
|
{
|
|
if (this->MustSkip()) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
bool cmOSXBundleGenerator::MustSkip()
|
|
{
|
|
return !this->GT->HaveWellDefinedOutputFiles();
|
|
}
|
|
|
|
void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
|
|
std::string& outpath)
|
|
{
|
|
if (this->MustSkip()) {
|
|
return;
|
|
}
|
|
|
|
// Compute bundle directory names.
|
|
std::string out = outpath;
|
|
out += "/";
|
|
out += this->GT->GetAppBundleDirectory(this->ConfigName, false);
|
|
cmSystemTools::MakeDirectory(out.c_str());
|
|
this->Makefile->AddCMakeOutputFile(out);
|
|
|
|
std::string newoutpath = out;
|
|
|
|
// Configure the Info.plist file. Note that it needs the executable name
|
|
// to be set.
|
|
std::string plist = outpath;
|
|
plist += "/";
|
|
plist += this->GT->GetAppBundleDirectory(this->ConfigName, true);
|
|
plist += "/Info.plist";
|
|
this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName,
|
|
plist.c_str());
|
|
this->Makefile->AddCMakeOutputFile(plist);
|
|
outpath = newoutpath;
|
|
}
|
|
|
|
void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
|
|
const std::string& outpath)
|
|
{
|
|
if (this->MustSkip()) {
|
|
return;
|
|
}
|
|
|
|
assert(this->MacContentFolders);
|
|
|
|
// Compute the location of the top-level foo.framework directory.
|
|
std::string contentdir =
|
|
outpath + "/" + this->GT->GetFrameworkDirectory(this->ConfigName, true);
|
|
contentdir += "/";
|
|
|
|
std::string newoutpath =
|
|
outpath + "/" + this->GT->GetFrameworkDirectory(this->ConfigName, false);
|
|
|
|
std::string frameworkVersion = this->GT->GetFrameworkVersion();
|
|
|
|
// Configure the Info.plist file
|
|
std::string plist = newoutpath;
|
|
if (!this->Makefile->PlatformIsAppleIos()) {
|
|
// Put the Info.plist file into the Resources directory.
|
|
this->MacContentFolders->insert("Resources");
|
|
plist += "/Resources";
|
|
}
|
|
plist += "/Info.plist";
|
|
std::string name = cmSystemTools::GetFilenameName(targetName);
|
|
this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name,
|
|
plist.c_str());
|
|
|
|
// Generate Versions directory only for MacOSX frameworks
|
|
if (this->Makefile->PlatformIsAppleIos()) {
|
|
return;
|
|
}
|
|
|
|
// TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
|
|
// drive rules to create these files at build time.
|
|
std::string oldName;
|
|
std::string newName;
|
|
|
|
// Make foo.framework/Versions
|
|
std::string versions = contentdir;
|
|
versions += "Versions";
|
|
cmSystemTools::MakeDirectory(versions.c_str());
|
|
|
|
// Make foo.framework/Versions/version
|
|
cmSystemTools::MakeDirectory(newoutpath.c_str());
|
|
|
|
// Current -> version
|
|
oldName = frameworkVersion;
|
|
newName = versions;
|
|
newName += "/Current";
|
|
cmSystemTools::RemoveFile(newName);
|
|
cmSystemTools::CreateSymlink(oldName, newName);
|
|
this->Makefile->AddCMakeOutputFile(newName);
|
|
|
|
// foo -> Versions/Current/foo
|
|
oldName = "Versions/Current/";
|
|
oldName += name;
|
|
newName = contentdir;
|
|
newName += name;
|
|
cmSystemTools::RemoveFile(newName);
|
|
cmSystemTools::CreateSymlink(oldName, newName);
|
|
this->Makefile->AddCMakeOutputFile(newName);
|
|
|
|
// Resources -> Versions/Current/Resources
|
|
if (this->MacContentFolders->find("Resources") !=
|
|
this->MacContentFolders->end()) {
|
|
oldName = "Versions/Current/Resources";
|
|
newName = contentdir;
|
|
newName += "Resources";
|
|
cmSystemTools::RemoveFile(newName);
|
|
cmSystemTools::CreateSymlink(oldName, newName);
|
|
this->Makefile->AddCMakeOutputFile(newName);
|
|
}
|
|
|
|
// Headers -> Versions/Current/Headers
|
|
if (this->MacContentFolders->find("Headers") !=
|
|
this->MacContentFolders->end()) {
|
|
oldName = "Versions/Current/Headers";
|
|
newName = contentdir;
|
|
newName += "Headers";
|
|
cmSystemTools::RemoveFile(newName);
|
|
cmSystemTools::CreateSymlink(oldName, newName);
|
|
this->Makefile->AddCMakeOutputFile(newName);
|
|
}
|
|
|
|
// PrivateHeaders -> Versions/Current/PrivateHeaders
|
|
if (this->MacContentFolders->find("PrivateHeaders") !=
|
|
this->MacContentFolders->end()) {
|
|
oldName = "Versions/Current/PrivateHeaders";
|
|
newName = contentdir;
|
|
newName += "PrivateHeaders";
|
|
cmSystemTools::RemoveFile(newName);
|
|
cmSystemTools::CreateSymlink(oldName, newName);
|
|
this->Makefile->AddCMakeOutputFile(newName);
|
|
}
|
|
}
|
|
|
|
void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
|
|
const std::string& root)
|
|
{
|
|
if (this->MustSkip()) {
|
|
return;
|
|
}
|
|
|
|
// Compute bundle directory names.
|
|
std::string out = root;
|
|
out += "/";
|
|
out += this->GT->GetCFBundleDirectory(this->ConfigName, false);
|
|
cmSystemTools::MakeDirectory(out.c_str());
|
|
this->Makefile->AddCMakeOutputFile(out);
|
|
|
|
// Configure the Info.plist file. Note that it needs the executable name
|
|
// to be set.
|
|
std::string plist =
|
|
root + "/" + this->GT->GetCFBundleDirectory(this->ConfigName, true);
|
|
plist += "/Info.plist";
|
|
std::string name = cmSystemTools::GetFilenameName(targetName);
|
|
this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str());
|
|
this->Makefile->AddCMakeOutputFile(plist);
|
|
}
|
|
|
|
void cmOSXBundleGenerator::GenerateMacOSXContentStatements(
|
|
std::vector<cmSourceFile const*> const& sources,
|
|
MacOSXContentGeneratorType* generator)
|
|
{
|
|
if (this->MustSkip()) {
|
|
return;
|
|
}
|
|
|
|
for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin();
|
|
si != sources.end(); ++si) {
|
|
cmGeneratorTarget::SourceFileFlags tsFlags =
|
|
this->GT->GetTargetSourceFileFlags(*si);
|
|
if (tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal) {
|
|
(*generator)(**si, tsFlags.MacFolder);
|
|
}
|
|
}
|
|
}
|
|
|
|
std::string cmOSXBundleGenerator::InitMacOSXContentDirectory(
|
|
const char* pkgloc)
|
|
{
|
|
// Construct the full path to the content subdirectory.
|
|
|
|
std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName,
|
|
/*implib*/ false);
|
|
macdir += "/";
|
|
macdir += pkgloc;
|
|
cmSystemTools::MakeDirectory(macdir.c_str());
|
|
|
|
// Record use of this content location. Only the first level
|
|
// directory is needed.
|
|
{
|
|
std::string loc = pkgloc;
|
|
loc = loc.substr(0, loc.find('/'));
|
|
this->MacContentFolders->insert(loc);
|
|
}
|
|
|
|
return macdir;
|
|
}
|