mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 17:31:57 +08:00
cmTarget: Extract GetLocation method
This commit is contained in:
@@ -1043,6 +1043,9 @@ private:
|
|||||||
static const char* ComputeLocationForBuild(cmTarget const* tgt);
|
static const char* ComputeLocationForBuild(cmTarget const* tgt);
|
||||||
static const char* ComputeLocation(cmTarget const* tgt,
|
static const char* ComputeLocation(cmTarget const* tgt,
|
||||||
std::string const& config);
|
std::string const& config);
|
||||||
|
static const char* GetLocation(cmTarget const* tgt,
|
||||||
|
std::string const& config,
|
||||||
|
cmMakefile* context);
|
||||||
|
|
||||||
static const char* GetSources(cmTarget const* tgt, cmMakefile* context);
|
static const char* GetSources(cmTarget const* tgt, cmMakefile* context);
|
||||||
};
|
};
|
||||||
@@ -1114,6 +1117,52 @@ const char* cmTargetPropertyComputer::ComputeLocation(
|
|||||||
return loc.c_str();
|
return loc.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cmTargetPropertyComputer::GetLocation(cmTarget const* tgt,
|
||||||
|
const std::string& prop,
|
||||||
|
cmMakefile* context)
|
||||||
|
{
|
||||||
|
// Watch for special "computed" properties that are dependent on
|
||||||
|
// other properties or variables. Always recompute them.
|
||||||
|
if (tgt->GetType() == cmState::EXECUTABLE ||
|
||||||
|
tgt->GetType() == cmState::STATIC_LIBRARY ||
|
||||||
|
tgt->GetType() == cmState::SHARED_LIBRARY ||
|
||||||
|
tgt->GetType() == cmState::MODULE_LIBRARY ||
|
||||||
|
tgt->GetType() == cmState::UNKNOWN_LIBRARY) {
|
||||||
|
static const std::string propLOCATION = "LOCATION";
|
||||||
|
if (prop == propLOCATION) {
|
||||||
|
if (!tgt->IsImported() &&
|
||||||
|
!HandleLocationPropertyPolicy(tgt->GetName(), context)) {
|
||||||
|
return CM_NULLPTR;
|
||||||
|
}
|
||||||
|
return ComputeLocationForBuild(tgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support "LOCATION_<CONFIG>".
|
||||||
|
else if (cmHasLiteralPrefix(prop, "LOCATION_")) {
|
||||||
|
if (!tgt->IsImported() &&
|
||||||
|
!HandleLocationPropertyPolicy(tgt->GetName(), context)) {
|
||||||
|
return CM_NULLPTR;
|
||||||
|
}
|
||||||
|
const char* configName = prop.c_str() + 9;
|
||||||
|
return ComputeLocation(tgt, configName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support "<CONFIG>_LOCATION".
|
||||||
|
else if (cmHasLiteralSuffix(prop, "_LOCATION") &&
|
||||||
|
!cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) {
|
||||||
|
std::string configName(prop.c_str(), prop.size() - 9);
|
||||||
|
if (configName != "IMPORTED") {
|
||||||
|
if (!tgt->IsImported() &&
|
||||||
|
!HandleLocationPropertyPolicy(tgt->GetName(), context)) {
|
||||||
|
return CM_NULLPTR;
|
||||||
|
}
|
||||||
|
return ComputeLocation(tgt, configName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CM_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
const char* cmTargetPropertyComputer::GetSources(cmTarget const* tgt,
|
const char* cmTargetPropertyComputer::GetSources(cmTarget const* tgt,
|
||||||
cmMakefile* context)
|
cmMakefile* context)
|
||||||
{
|
{
|
||||||
@@ -1207,44 +1256,11 @@ const char* cmTargetPropertyComputer::GetProperty(cmTarget const* tgt,
|
|||||||
const std::string& prop,
|
const std::string& prop,
|
||||||
cmMakefile* context)
|
cmMakefile* context)
|
||||||
{
|
{
|
||||||
// Watch for special "computed" properties that are dependent on
|
if (const char* loc = GetLocation(tgt, prop, context)) {
|
||||||
// other properties or variables. Always recompute them.
|
return loc;
|
||||||
if (tgt->GetType() == cmState::EXECUTABLE ||
|
}
|
||||||
tgt->GetType() == cmState::STATIC_LIBRARY ||
|
if (cmSystemTools::GetFatalErrorOccured()) {
|
||||||
tgt->GetType() == cmState::SHARED_LIBRARY ||
|
return CM_NULLPTR;
|
||||||
tgt->GetType() == cmState::MODULE_LIBRARY ||
|
|
||||||
tgt->GetType() == cmState::UNKNOWN_LIBRARY) {
|
|
||||||
static const std::string propLOCATION = "LOCATION";
|
|
||||||
if (prop == propLOCATION) {
|
|
||||||
if (!tgt->IsImported() &&
|
|
||||||
!HandleLocationPropertyPolicy(tgt->GetName(), context)) {
|
|
||||||
return CM_NULLPTR;
|
|
||||||
}
|
|
||||||
return ComputeLocationForBuild(tgt);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Support "LOCATION_<CONFIG>".
|
|
||||||
else if (cmHasLiteralPrefix(prop, "LOCATION_")) {
|
|
||||||
if (!tgt->IsImported() &&
|
|
||||||
!HandleLocationPropertyPolicy(tgt->GetName(), context)) {
|
|
||||||
return CM_NULLPTR;
|
|
||||||
}
|
|
||||||
const char* configName = prop.c_str() + 9;
|
|
||||||
return ComputeLocation(tgt, configName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Support "<CONFIG>_LOCATION".
|
|
||||||
else if (cmHasLiteralSuffix(prop, "_LOCATION") &&
|
|
||||||
!cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) {
|
|
||||||
std::string configName(prop.c_str(), prop.size() - 9);
|
|
||||||
if (configName != "IMPORTED") {
|
|
||||||
if (!tgt->IsImported() &&
|
|
||||||
!HandleLocationPropertyPolicy(tgt->GetName(), context)) {
|
|
||||||
return CM_NULLPTR;
|
|
||||||
}
|
|
||||||
return ComputeLocation(tgt, configName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (prop == "SOURCES") {
|
if (prop == "SOURCES") {
|
||||||
return GetSources(tgt, context);
|
return GetSources(tgt, context);
|
||||||
|
Reference in New Issue
Block a user