cmGeneratorTarget: Move GetDirectory from cmTarget.

This commit is contained in:
Stephen Kelly 2014-10-20 20:31:47 +02:00
parent e0261a1e20
commit 8b0168863e
15 changed files with 76 additions and 68 deletions

View File

@ -1586,7 +1586,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
"SHARED libraries.");
return std::string();
}
std::string result = target->Target->GetDirectory(context->Config);
std::string result = target->GetDirectory(context->Config);
result += "/";
result += target->GetSOName(context->Config);
return result;

View File

@ -748,7 +748,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
}
// Now handle the deprecated build-time configuration location.
location = this->Target->GetDirectory();
location = this->GetDirectory();
const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
if(cfgid && strcmp(cfgid, ".") != 0)
{
@ -1434,7 +1434,7 @@ cmGeneratorTarget::GetInstallNameDirForBuildTree(
}
else
{
dir = this->Target->GetDirectory(config);
dir = this->GetDirectory(config);
}
dir += "/";
return dir;
@ -1735,7 +1735,7 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config,
bool implib) const
{
// Start with the output directory for the target.
std::string fpath = this->Target->GetDirectory(config, implib);
std::string fpath = this->GetDirectory(config, implib);
fpath += "/";
bool contentOnly = true;
if(this->Target->IsFrameworkOnApple())
@ -2860,7 +2860,7 @@ void cmGeneratorTarget::ComputeTargetManifest(
}
// Get the directory.
std::string dir = this->Target->GetDirectory(config, false);
std::string dir = this->GetDirectory(config, false);
// Add each name.
std::string f;
@ -2894,7 +2894,7 @@ void cmGeneratorTarget::ComputeTargetManifest(
}
if(!impName.empty())
{
f = this->Target->GetDirectory(config, true);
f = this->GetDirectory(config, true);
f += "/";
f += impName;
gg->AddToManifest(f);
@ -2919,7 +2919,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
bool implib,
bool realname) const
{
std::string fpath = this->Target->GetDirectory(config, implib);
std::string fpath = this->GetDirectory(config, implib);
fpath += "/";
if(this->Target->IsAppBundleOnApple())
{
@ -4453,6 +4453,26 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config,
return iface.Exists? &iface : 0;
}
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetDirectory(const std::string& config,
bool implib) const
{
if (this->Target->IsImported())
{
// Return the directory from which the target is imported.
return
cmSystemTools::GetFilenamePath(
this->Target->ImportedGetFullPath(config, implib));
}
else if(cmTarget::OutputInfo const* info =
this->Target->GetOutputInfo(config))
{
// Return the directory in which the target will be built.
return implib? info->ImpDir : info->OutDir;
}
return "";
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::ComputeLinkInterfaceLibraries(

View File

@ -268,6 +268,13 @@ public:
*/
void TraceDependencies();
/** Get the directory in which this target will be built. If the
configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical
output directory is given. */
std::string GetDirectory(const std::string& config = "",
bool implib = false) const;
/** Get the directory in which to place the target compiler .pdb file.
If the configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical

View File

@ -1977,7 +1977,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
if(!target.UsesDefaultOutputDir(configName, false))
{
std::string pncdir = target.GetDirectory(configName);
std::string pncdir = gtgt->GetDirectory(configName);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
this->CreateString(pncdir.c_str()));
}
@ -1986,7 +1986,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
buildSettings->AddAttribute("OBJROOT",
this->CreateString(pndir.c_str()));
pndir = target.GetDirectory(configName);
pndir = gtgt->GetDirectory(configName);
}
if(target.IsFrameworkOnApple() || target.IsCFBundleOnApple())

View File

@ -83,7 +83,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
else
{
fromDirConfig =
this->Target->Target->GetDirectory(config, this->ImportLibrary);
this->Target->GetDirectory(config, this->ImportLibrary);
fromDirConfig += "/";
}
std::string toDir =

View File

@ -805,7 +805,11 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
// VS6 forgets to create the output directory for archives if it
// differs from the intermediate directory.
if(target.GetType() != cmTarget::STATIC_LIBRARY) { return pcc; }
std::string outDir = target.GetDirectory(config, false);
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
std::string outDir = gt->GetDirectory(config, false);
// Add a pre-link event to create the directory.
cmCustomCommandLine command;
@ -1363,20 +1367,20 @@ void cmLocalVisualStudio6Generator
#ifdef CM_USE_OLD_VS6
outputDirOld =
removeQuotes(this->ConvertToOutputFormat
(target.GetDirectory().c_str(), SHELL));
(gt->GetDirectory().c_str(), SHELL));
#endif
outputDirDebug =
removeQuotes(this->ConvertToOutputFormat(
target.GetDirectory("Debug").c_str(), SHELL));
gt->GetDirectory("Debug").c_str(), SHELL));
outputDirRelease =
removeQuotes(this->ConvertToOutputFormat(
target.GetDirectory("Release").c_str(), SHELL));
gt->GetDirectory("Release").c_str(), SHELL));
outputDirMinSizeRel =
removeQuotes(this->ConvertToOutputFormat(
target.GetDirectory("MinSizeRel").c_str(), SHELL));
gt->GetDirectory("MinSizeRel").c_str(), SHELL));
outputDirRelWithDebInfo =
removeQuotes(this->ConvertToOutputFormat(
target.GetDirectory("RelWithDebInfo").c_str(), SHELL));
gt->GetDirectory("RelWithDebInfo").c_str(), SHELL));
}
else if(target.GetType() == cmTarget::OBJECT_LIBRARY)
{
@ -1424,12 +1428,12 @@ void cmLocalVisualStudio6Generator
target.GetType() == cmTarget::MODULE_LIBRARY ||
target.GetType() == cmTarget::EXECUTABLE)
{
std::string fullPathImpDebug = target.GetDirectory("Debug", true);
std::string fullPathImpRelease = target.GetDirectory("Release", true);
std::string fullPathImpDebug = gt->GetDirectory("Debug", true);
std::string fullPathImpRelease = gt->GetDirectory("Release", true);
std::string fullPathImpMinSizeRel =
target.GetDirectory("MinSizeRel", true);
gt->GetDirectory("MinSizeRel", true);
std::string fullPathImpRelWithDebInfo =
target.GetDirectory("RelWithDebInfo", true);
gt->GetDirectory("RelWithDebInfo", true);
fullPathImpDebug += "/";
fullPathImpRelease += "/";
fullPathImpMinSizeRel += "/";

View File

@ -792,7 +792,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
{
std::string const& outDir =
target.GetType() == cmTarget::OBJECT_LIBRARY?
intermediateDir : target.GetDirectory(configName);
intermediateDir : gt->GetDirectory(configName);
fout << "\t\t\tOutputDirectory=\""
<< this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n";
}
@ -1004,7 +1004,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// Check if we need the FAT32 workaround.
// Check the filesystem type where the target will be written.
if (cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
if (cmLVS6G_IsFAT(gt->GetDirectory(configName).c_str()))
{
// Add a flag telling the manifest tool to use a workaround
// for FAT32 file systems, which can cause an empty manifest
@ -1130,7 +1130,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
case cmTarget::STATIC_LIBRARY:
{
std::string targetNameFull = gt->GetFullName(configName);
std::string libpath = target.GetDirectory(configName);
std::string libpath = gt->GetDirectory(configName);
libpath += "/";
libpath += targetNameFull;
const char* tool = "VCLibrarianTool";
@ -1210,7 +1210,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << " ";
this->Internal->OutputLibraries(fout, cli.GetItems());
fout << "\"\n";
temp = target.GetDirectory(configName);
temp = gt->GetDirectory(configName);
temp += "/";
temp += targetNameFull;
fout << "\t\t\t\tOutputFile=\""
@ -1248,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
}
temp = target.GetDirectory(configName, true);
temp = gt->GetDirectory(configName, true);
temp += "/";
temp += targetNameImport;
fout << "\t\t\t\tImportLibrary=\""
@ -1309,7 +1309,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << " ";
this->Internal->OutputLibraries(fout, cli.GetItems());
fout << "\"\n";
temp = target.GetDirectory(configName);
temp = gt->GetDirectory(configName);
temp += "/";
temp += targetNameFull;
fout << "\t\t\t\tOutputFile=\""
@ -1367,7 +1367,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
}
temp = target.GetDirectory(configName, true);
temp = gt->GetDirectory(configName, true);
temp += "/";
temp += targetNameImport;
fout << "\t\t\t\tImportLibrary=\""

View File

@ -92,8 +92,10 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
if(target.GetType() != cmTarget::EXECUTABLE &&
!(isFortran && target.GetType() == cmTarget::SHARED_LIBRARY))
{ return pcc; }
std::string outDir = target.GetDirectory(config, false);
std::string impDir = target.GetDirectory(config, true);
cmGeneratorTarget* gt =
this->GetGlobalGenerator()->GetGeneratorTarget(&target);
std::string outDir = gt->GetDirectory(config, false);
std::string impDir = gt->GetDirectory(config, true);
if(impDir == outDir) { return pcc; }
// Add a pre-build event to create the directory.

View File

@ -99,7 +99,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->ConfigName);
// Construct the full path version of the names.
std::string outpath = this->Target->GetDirectory(this->ConfigName);
std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
if(this->Target->IsAppBundleOnApple())
{
this->OSXBundleGenerator->CreateAppBundle(targetName, outpath);
@ -123,7 +123,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
cmSystemTools::MakeDirectory(outpath.c_str());
if(!targetNameImport.empty())
{
outpathImp = this->Target->GetDirectory(this->ConfigName, true);
outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true);
cmSystemTools::MakeDirectory(outpathImp.c_str());
outpathImp += "/";
}

View File

@ -275,13 +275,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string outpathImp;
if(this->Target->IsFrameworkOnApple())
{
outpath = this->Target->GetDirectory(this->ConfigName);
outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
this->OSXBundleGenerator->CreateFramework(targetName, outpath);
outpath += "/";
}
else if(this->Target->IsCFBundleOnApple())
{
outpath = this->Target->GetDirectory(this->ConfigName);
outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
this->OSXBundleGenerator->CreateCFBundle(targetName, outpath);
outpath += "/";
}
@ -299,12 +299,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
else
{
outpath = this->Target->GetDirectory(this->ConfigName);
outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
cmSystemTools::MakeDirectory(outpath.c_str());
outpath += "/";
if(!targetNameImport.empty())
{
outpathImp = this->Target->GetDirectory(this->ConfigName, true);
outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true);
cmSystemTools::MakeDirectory(outpathImp.c_str());
outpathImp += "/";
}

View File

@ -59,7 +59,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
{
// on Windows the output dir is already needed at compile time
// ensure the directory exists (OutDir test)
EnsureDirectoryExists(target->Target->GetDirectory(this->GetConfigName()));
EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
}
this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
@ -413,7 +413,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
if (target.IsAppBundleOnApple())
{
// Create the app bundle
std::string outpath = target.GetDirectory(cfgName);
std::string outpath = gt.GetDirectory(cfgName);
this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
// Calculate the output path
@ -430,13 +430,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
{
// Create the library framework.
this->OSXBundleGenerator->CreateFramework(this->TargetNameOut,
target.GetDirectory(cfgName));
gt.GetDirectory(cfgName));
}
else if(target.IsCFBundleOnApple())
{
// Create the core foundation bundle.
this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut,
target.GetDirectory(cfgName));
gt.GetDirectory(cfgName));
}
// Write comments.

View File

@ -254,7 +254,7 @@ cmNinjaTargetGenerator
std::string cmNinjaTargetGenerator::GetTargetOutputDir() const
{
std::string dir = this->Target->GetDirectory(this->GetConfigName());
std::string dir = this->GeneratorTarget->GetDirectory(this->GetConfigName());
return ConvertToNinjaPath(dir);
}

View File

@ -1770,25 +1770,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(
return &i->second;
}
//----------------------------------------------------------------------------
std::string cmTarget::GetDirectory(const std::string& config,
bool implib) const
{
if (this->IsImported())
{
// Return the directory from which the target is imported.
return
cmSystemTools::GetFilenamePath(
this->ImportedGetFullPath(config, implib));
}
else if(OutputInfo const* info = this->GetOutputInfo(config))
{
// Return the directory in which the target will be built.
return implib? info->ImpDir : info->OutDir;
}
return "";
}
//----------------------------------------------------------------------------
std::string cmTarget::GetPDBDirectory(const std::string& config) const
{

View File

@ -231,13 +231,6 @@ public:
the link dependencies of this target. */
std::string CheckCMP0004(std::string const& item) const;
/** Get the directory in which this target will be built. If the
configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical
output directory is given. */
std::string GetDirectory(const std::string& config = "",
bool implib = false) const;
/** Get the directory in which this targets .pdb files will be placed.
If the configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical

View File

@ -1780,7 +1780,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
}
else
{
outDir = this->Target->GetDirectory(config->c_str()) + "/";
outDir = this->GeneratorTarget->GetDirectory(config->c_str()) + "/";
targetNameFull = this->GeneratorTarget->GetFullName(config->c_str());
}
this->ConvertToWindowsSlash(intermediateDir);
@ -2584,7 +2584,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
std::string pdb = this->Target->GetPDBDirectory(config.c_str());
pdb += "/";
pdb += targetNamePDB;
std::string imLib = this->Target->GetDirectory(config.c_str(), true);
std::string imLib =
this->GeneratorTarget->GetDirectory(config.c_str(), true);
imLib += "/";
imLib += targetNameImport;