cmTarget: Refactor GetLocation API
When given a non-NULL configuration the GetLocation returned the location for the given configuration. When given a NULL configuration the GetLocation method returned a location with the build-system placeholder for the configuration name. Split the latter use case out into a separate GetLocationForBuild method and update call sites accordingly.
This commit is contained in:
parent
cfc2cf9559
commit
f154475b65
|
@ -742,7 +742,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
|
||||||
{
|
{
|
||||||
// This is really only for compatibility so we do not need to
|
// This is really only for compatibility so we do not need to
|
||||||
// worry about configuration names and output names.
|
// worry about configuration names and output names.
|
||||||
std::string tLocation = t->GetLocation(0);
|
std::string tLocation = t->GetLocationForBuild();
|
||||||
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
||||||
std::string depLocation = cmSystemTools::GetFilenamePath(dep);
|
std::string depLocation = cmSystemTools::GetFilenamePath(dep);
|
||||||
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
||||||
|
|
|
@ -76,7 +76,7 @@ void cmGlobalKdevelopGenerator::Generate()
|
||||||
{
|
{
|
||||||
if (ti->second.GetType()==cmTarget::EXECUTABLE)
|
if (ti->second.GetType()==cmTarget::EXECUTABLE)
|
||||||
{
|
{
|
||||||
executable = ti->second.GetLocation(0);
|
executable = ti->second.GetLocation("");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,7 +610,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
|
||||||
autogenTargetName.c_str());
|
autogenTargetName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0));
|
makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(""));
|
||||||
}
|
}
|
||||||
else if (strcmp(qtVersion, "4") == 0)
|
else if (strcmp(qtVersion, "4") == 0)
|
||||||
{
|
{
|
||||||
|
@ -621,7 +621,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
|
||||||
autogenTargetName.c_str());
|
autogenTargetName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0));
|
makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(""));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -782,7 +782,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0));
|
makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(qtVersion, "4") == 0)
|
else if (strcmp(qtVersion, "4") == 0)
|
||||||
|
@ -794,7 +794,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
|
||||||
targetName.c_str());
|
targetName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0));
|
makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(""));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -931,7 +931,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
|
||||||
targetName.c_str());
|
targetName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0));
|
makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(""));
|
||||||
}
|
}
|
||||||
else if (strcmp(qtVersion, "4") == 0)
|
else if (strcmp(qtVersion, "4") == 0)
|
||||||
{
|
{
|
||||||
|
@ -942,7 +942,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
|
||||||
targetName.c_str());
|
targetName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0));
|
makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(""));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2458,32 +2458,25 @@ std::string cmTarget::GetCompilePDBDirectory(const char* config) const
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmTarget::GetLocation(const char* config) const
|
const char* cmTarget::GetLocation(const char* config) const
|
||||||
{
|
{
|
||||||
|
static std::string location;
|
||||||
if (this->IsImported())
|
if (this->IsImported())
|
||||||
{
|
{
|
||||||
return this->ImportedGetLocation(config);
|
location = this->ImportedGetFullPath(config, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return this->NormalGetLocation(config);
|
location = this->GetFullPath(config, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* cmTarget::ImportedGetLocation(const char* config) const
|
|
||||||
{
|
|
||||||
static std::string location;
|
|
||||||
location = this->ImportedGetFullPath(config, false);
|
|
||||||
return location.c_str();
|
return location.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmTarget::NormalGetLocation(const char* config) const
|
const char* cmTarget::GetLocationForBuild() const
|
||||||
{
|
{
|
||||||
static std::string location;
|
static std::string location;
|
||||||
// Handle the configuration-specific case first.
|
if(this->IsImported())
|
||||||
if(config)
|
|
||||||
{
|
{
|
||||||
location = this->GetFullPath(config, false);
|
location = this->ImportedGetFullPath("", false);
|
||||||
return location.c_str();
|
return location.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2503,7 +2496,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const
|
||||||
|
|
||||||
if(this->IsAppBundleOnApple())
|
if(this->IsAppBundleOnApple())
|
||||||
{
|
{
|
||||||
std::string macdir = this->BuildMacContentDirectory("", config, false);
|
std::string macdir = this->BuildMacContentDirectory("", "", false);
|
||||||
if(!macdir.empty())
|
if(!macdir.empty())
|
||||||
{
|
{
|
||||||
location += "/";
|
location += "/";
|
||||||
|
@ -2511,7 +2504,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
location += "/";
|
location += "/";
|
||||||
location += this->GetFullName(config, false);
|
location += this->GetFullName("", false);
|
||||||
return location.c_str();
|
return location.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2659,7 +2652,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
|
||||||
// cannot take into account the per-configuration name of the
|
// cannot take into account the per-configuration name of the
|
||||||
// target because the configuration type may not be known at
|
// target because the configuration type may not be known at
|
||||||
// CMake time.
|
// CMake time.
|
||||||
this->Properties.SetProperty("LOCATION", this->GetLocation(0),
|
this->Properties.SetProperty("LOCATION", this->GetLocationForBuild(),
|
||||||
cmProperty::TARGET);
|
cmProperty::TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,10 +331,14 @@ public:
|
||||||
std::string GetCompilePDBDirectory(const char* config = 0) const;
|
std::string GetCompilePDBDirectory(const char* config = 0) const;
|
||||||
|
|
||||||
/** Get the location of the target in the build tree for the given
|
/** Get the location of the target in the build tree for the given
|
||||||
configuration. This location is suitable for use as the LOCATION
|
configuration. */
|
||||||
target property. */
|
|
||||||
const char* GetLocation(const char* config) const;
|
const char* GetLocation(const char* config) const;
|
||||||
|
|
||||||
|
/** Get the location of the target in the build tree with a placeholder
|
||||||
|
referencing the configuration in the native build system. This
|
||||||
|
location is suitable for use as the LOCATION target property. */
|
||||||
|
const char* GetLocationForBuild() const;
|
||||||
|
|
||||||
/** Get the target major and minor version numbers interpreted from
|
/** Get the target major and minor version numbers interpreted from
|
||||||
the VERSION property. Version 0 is returned if the property is
|
the VERSION property. Version 0 is returned if the property is
|
||||||
not set or cannot be parsed. */
|
not set or cannot be parsed. */
|
||||||
|
@ -643,9 +647,6 @@ private:
|
||||||
// Get the target base name.
|
// Get the target base name.
|
||||||
std::string GetOutputName(const char* config, bool implib) const;
|
std::string GetOutputName(const char* config, bool implib) const;
|
||||||
|
|
||||||
const char* ImportedGetLocation(const char* config) const;
|
|
||||||
const char* NormalGetLocation(const char* config) const;
|
|
||||||
|
|
||||||
std::string GetFullNameImported(const char* config, bool implib) const;
|
std::string GetFullNameImported(const char* config, bool implib) const;
|
||||||
|
|
||||||
std::string ImportedGetFullPath(const char* config, bool implib) const;
|
std::string ImportedGetFullPath(const char* config, bool implib) const;
|
||||||
|
|
Loading…
Reference in New Issue