1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 00:02:21 +08:00

cmTarget: Extract GetSources method

This commit is contained in:
Stephen Kelly
2016-10-13 00:18:23 +02:00
parent 7d57c1a2c9
commit 8096682e4e

View File

@@ -1043,6 +1043,8 @@ private:
static const char* ComputeLocationForBuild(cmTarget const* tgt);
static const char* ComputeLocation(cmTarget const* tgt,
std::string const& config);
static const char* GetSources(cmTarget const* tgt, cmMakefile* context);
};
bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
@@ -1112,51 +1114,11 @@ const char* cmTargetPropertyComputer::ComputeLocation(
return loc.c_str();
}
const char* cmTargetPropertyComputer::GetProperty(cmTarget const* tgt,
const std::string& prop,
const char* cmTargetPropertyComputer::GetSources(cmTarget const* tgt,
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);
}
}
}
if (prop == "SOURCES") {
cmStringRange entries = tgt->GetSourceEntries();
if (entries.empty()) {
return CM_NULLPTR;
}
@@ -1239,6 +1201,53 @@ const char* cmTargetPropertyComputer::GetProperty(cmTarget const* tgt,
static std::string srcs;
srcs = ss.str();
return srcs.c_str();
}
const char* cmTargetPropertyComputer::GetProperty(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);
}
}
}
if (prop == "SOURCES") {
return GetSources(tgt, context);
}
return CM_NULLPTR;
}