ENH: Improve framework support in the makefile generator to match the support just added to the Xcode generator. BUG: Remove spurious warning and eliminate empty Libraries subdir inside built framework.
This commit is contained in:
parent
a33e059e41
commit
0e96f06954
|
@ -89,7 +89,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
|
||||||
this->CloseFileStreams();
|
this->CloseFileStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||||
{
|
{
|
||||||
|
@ -219,7 +218,6 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
|
||||||
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
|
this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::CreateFrameworkLinksAndDirs(
|
void cmMakefileLibraryTargetGenerator::CreateFrameworkLinksAndDirs(
|
||||||
std::string& targetName,
|
std::string& targetName,
|
||||||
|
@ -255,113 +253,87 @@ void cmMakefileLibraryTargetGenerator::CreateFrameworkLinksAndDirs(
|
||||||
cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
||||||
this->Makefile->AddCMakeOutputFile((outpath + "Resources").c_str());
|
this->Makefile->AddCMakeOutputFile((outpath + "Resources").c_str());
|
||||||
// Libraries -> Versions/Current/Libraries
|
// Libraries -> Versions/Current/Libraries
|
||||||
symlink = "Versions/Current/Libraries";
|
//symlink = "Versions/Current/Libraries";
|
||||||
symlink2 = "Libraries";
|
//symlink2 = "Libraries";
|
||||||
cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
//cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
||||||
this->Makefile->AddCMakeOutputFile((outpath + "Libraries").c_str());
|
//this->Makefile->AddCMakeOutputFile((outpath + "Libraries").c_str());
|
||||||
// Headers -> Versions/Current/Headers
|
// Headers -> Versions/Current/Headers
|
||||||
symlink = "Versions/Current/Headers";
|
symlink = "Versions/Current/Headers";
|
||||||
symlink2 = "Headers";
|
symlink2 = "Headers";
|
||||||
cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
||||||
this->Makefile->AddCMakeOutputFile((outpath + "Headers").c_str());
|
this->Makefile->AddCMakeOutputFile((outpath + "Headers").c_str());
|
||||||
|
symlink = "Versions/Current/PrivateHeaders";
|
||||||
|
symlink2 = "PrivateHeaders";
|
||||||
|
cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
|
||||||
|
this->Makefile->AddCMakeOutputFile((outpath + "PrivateHeaders").c_str());
|
||||||
// go back to where we were
|
// go back to where we were
|
||||||
cmSystemTools::ChangeDirectory(cwd.c_str());
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmMakefileLibraryTargetGenerator::CopyFrameworkPublicHeaders(
|
void cmMakefileLibraryTargetGenerator::CopyFrameworkSources(
|
||||||
std::string& targetName,
|
std::string& targetName,
|
||||||
std::string& outpath,
|
std::string& outpath,
|
||||||
const char* /*version*/)
|
const char* /*version*/ ,
|
||||||
|
const char* propertyName,
|
||||||
|
const char* subdir)
|
||||||
{
|
{
|
||||||
std::string fullOutput= outpath + targetName;
|
std::string fullOutput= outpath + targetName;
|
||||||
const char* headers = this->Target->GetProperty("FRAMEWORK_PUBLIC_HEADERS");
|
|
||||||
if(!headers)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::vector<std::string> headersVec;
|
|
||||||
cmSystemTools::ExpandListArgument(headers,
|
|
||||||
headersVec);
|
|
||||||
cmCustomCommandLines commandLines;
|
cmCustomCommandLines commandLines;
|
||||||
std::vector<std::string> depends;
|
std::vector<std::string> depends;
|
||||||
for(std::vector<std::string>::iterator i = headersVec.begin();
|
const std::vector<cmSourceFile*>& sources =
|
||||||
i != headersVec.end(); ++i)
|
this->Target->GetSourceFiles();
|
||||||
{
|
|
||||||
cmCustomCommandLine line;
|
|
||||||
cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
|
|
||||||
std::string dest = outpath + "Headers/";
|
|
||||||
dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
|
|
||||||
line.push_back("$(CMAKE_COMMAND)");
|
|
||||||
line.push_back("-E");
|
|
||||||
line.push_back("copy_if_different");
|
|
||||||
line.push_back(sf->GetFullPath());
|
|
||||||
depends.push_back(sf->GetFullPath());
|
|
||||||
line.push_back(dest);
|
|
||||||
commandLines.push_back(line);
|
|
||||||
// make sure the target gets rebuilt if any of the headers is removed
|
|
||||||
this->GenerateExtraOutput(dest.c_str(),
|
|
||||||
fullOutput.c_str());
|
|
||||||
}
|
|
||||||
// add a set of prebuild commands to run on the target
|
|
||||||
this->Makefile->
|
|
||||||
AddCustomCommandToTarget(this->Target->GetName(),
|
|
||||||
depends,
|
|
||||||
commandLines,
|
|
||||||
cmTarget::PRE_BUILD,
|
|
||||||
"copy files",
|
|
||||||
this->Makefile->GetCurrentOutputDirectory());
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
|
||||||
void cmMakefileLibraryTargetGenerator::CopyFrameworkResources(
|
i != sources.end(); ++i)
|
||||||
std::string& targetName,
|
|
||||||
std::string& outpath,
|
|
||||||
const char* /*version*/)
|
|
||||||
{
|
|
||||||
std::string fullOutput= outpath + targetName;
|
|
||||||
const char* resources = this->Target->GetProperty("FRAMEWORK_RESOURCES");
|
|
||||||
if(!resources)
|
|
||||||
{
|
{
|
||||||
return;
|
cmSourceFile* sf = *i;
|
||||||
}
|
|
||||||
std::vector<std::string> resourcesVec;
|
|
||||||
cmSystemTools::ExpandListArgument(resources,
|
|
||||||
resourcesVec);
|
|
||||||
cmCustomCommandLines commandLines;
|
|
||||||
std::vector<std::string> depends;
|
|
||||||
for(std::vector<std::string>::iterator i = resourcesVec.begin();
|
|
||||||
i != resourcesVec.end(); ++i)
|
|
||||||
{
|
|
||||||
cmCustomCommandLine line;
|
|
||||||
cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
|
|
||||||
if(!sf)
|
if(!sf)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error(
|
cmSystemTools::Error(
|
||||||
"could not find resource file.", i->c_str());
|
"could not find framework source file", "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string dest = outpath + "Resources/";
|
|
||||||
dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
|
// If processing public headers, skip headers also marked with the private
|
||||||
line.push_back("$(CMAKE_COMMAND)");
|
// property. Private wins.
|
||||||
line.push_back("-E");
|
//
|
||||||
line.push_back("copy_if_different");
|
if((std::string(propertyName) == "FRAMEWORK_PUBLIC_HEADER") &&
|
||||||
line.push_back(sf->GetFullPath());
|
sf->GetPropertyAsBool("FRAMEWORK_PRIVATE_HEADER"))
|
||||||
depends.push_back(sf->GetFullPath());
|
{
|
||||||
line.push_back(dest);
|
continue;
|
||||||
commandLines.push_back(line);
|
}
|
||||||
// make sure the target gets rebuilt if any of the resources is removed
|
|
||||||
this->GenerateExtraOutput(dest.c_str(),
|
if(sf->GetPropertyAsBool(propertyName))
|
||||||
fullOutput.c_str());
|
{
|
||||||
|
cmCustomCommandLine line;
|
||||||
|
std::string dest = outpath + subdir + "/";
|
||||||
|
dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
|
||||||
|
line.push_back("$(CMAKE_COMMAND)");
|
||||||
|
line.push_back("-E");
|
||||||
|
line.push_back("copy_if_different");
|
||||||
|
line.push_back(sf->GetFullPath());
|
||||||
|
depends.push_back(sf->GetFullPath());
|
||||||
|
line.push_back(dest);
|
||||||
|
commandLines.push_back(line);
|
||||||
|
// make sure the target gets rebuilt if any of the headers is removed
|
||||||
|
this->GenerateExtraOutput(dest.c_str(),
|
||||||
|
fullOutput.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a set of prebuild commands to run on the target
|
// add a set of prebuild commands to run on the target
|
||||||
this->Makefile->
|
if(!commandLines.empty())
|
||||||
AddCustomCommandToTarget(this->Target->GetName(),
|
{
|
||||||
depends,
|
this->Makefile->
|
||||||
commandLines,
|
AddCustomCommandToTarget(this->Target->GetName(),
|
||||||
cmTarget::PRE_BUILD,
|
depends,
|
||||||
"copy files",
|
commandLines,
|
||||||
this->Makefile->GetCurrentOutputDirectory());
|
cmTarget::PRE_BUILD,
|
||||||
|
"copy files",
|
||||||
|
this->Makefile->GetCurrentOutputDirectory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -374,11 +346,11 @@ void cmMakefileLibraryTargetGenerator::CreateFramework(
|
||||||
if(!version)
|
if(!version)
|
||||||
{
|
{
|
||||||
version = "A";
|
version = "A";
|
||||||
std::string message =
|
//std::string message =
|
||||||
"Warning: FRAMEWORK_VERSION property not found on ";
|
// "Warning: FRAMEWORK_VERSION property not found on ";
|
||||||
message += targetName;
|
//message += targetName;
|
||||||
message += ". Default to verison A.";
|
//message += ". Default to version A.";
|
||||||
cmSystemTools::Message(message.c_str());
|
//cmSystemTools::Message(message.c_str());
|
||||||
}
|
}
|
||||||
// create the symbolic links and directories
|
// create the symbolic links and directories
|
||||||
this->CreateFrameworkLinksAndDirs(targetName,
|
this->CreateFrameworkLinksAndDirs(targetName,
|
||||||
|
@ -391,7 +363,7 @@ void cmMakefileLibraryTargetGenerator::CreateFramework(
|
||||||
outpath += version;
|
outpath += version;
|
||||||
outpath += "/";
|
outpath += "/";
|
||||||
|
|
||||||
cmSystemTools::MakeDirectory((macdir + "Libraries").c_str());
|
//cmSystemTools::MakeDirectory((macdir + "Libraries").c_str());
|
||||||
cmSystemTools::MakeDirectory((macdir + "Headers").c_str());
|
cmSystemTools::MakeDirectory((macdir + "Headers").c_str());
|
||||||
// Configure the Info.plist file. Note that it needs the executable name
|
// Configure the Info.plist file. Note that it needs the executable name
|
||||||
// to be set
|
// to be set
|
||||||
|
@ -409,12 +381,15 @@ void cmMakefileLibraryTargetGenerator::CreateFramework(
|
||||||
std::string f2 = rsrcDir + "Info.plist";
|
std::string f2 = rsrcDir + "Info.plist";
|
||||||
this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(),
|
this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(),
|
||||||
false, false, false);
|
false, false, false);
|
||||||
this->CopyFrameworkPublicHeaders(targetName,
|
|
||||||
outpath,
|
this->CopyFrameworkSources(targetName, outpath, version,
|
||||||
version);
|
"FRAMEWORK_PRIVATE_HEADER", "PrivateHeaders");
|
||||||
this->CopyFrameworkResources(targetName,
|
|
||||||
outpath,
|
this->CopyFrameworkSources(targetName, outpath, version,
|
||||||
version);
|
"FRAMEWORK_PUBLIC_HEADER", "Headers");
|
||||||
|
|
||||||
|
this->CopyFrameworkSources(targetName, outpath, version,
|
||||||
|
"FRAMEWORK_RESOURCE", "Resources");
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -38,16 +38,15 @@ protected:
|
||||||
// MacOSX Framework support methods
|
// MacOSX Framework support methods
|
||||||
void WriteFrameworkRules(bool relink);
|
void WriteFrameworkRules(bool relink);
|
||||||
void CreateFramework(std::string& targetName,
|
void CreateFramework(std::string& targetName,
|
||||||
std::string& outpath);
|
std::string& outpath);
|
||||||
void CreateFrameworkLinksAndDirs(std::string& targetName,
|
void CreateFrameworkLinksAndDirs(std::string& targetName,
|
||||||
std::string& outpath,
|
std::string& outpath,
|
||||||
const char* version);
|
const char* version);
|
||||||
void CopyFrameworkPublicHeaders(std::string& targetName,
|
void CopyFrameworkSources(std::string& targetName,
|
||||||
std::string& outpath,
|
std::string& outpath,
|
||||||
const char* version);
|
const char* version,
|
||||||
void CopyFrameworkResources(std::string& targetName,
|
const char* propertyName,
|
||||||
std::string& outpath,
|
const char* subdir);
|
||||||
const char* version);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue