summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-03 20:10:31 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-03 20:10:35 (GMT)
commit1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc (patch)
tree7b7591334a25a08f3041676835c664d024ff2ce4 /Source/cmTarget.cxx
parent479932fa32115b666be1deea42862673a0c4b608 (diff)
downloadCMake-1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc.zip
CMake-1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc.tar.gz
CMake-1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc.tar.bz2
cmTarget: Refactor GetMappedConfig to choose location property up front
Store the `IMPORTED_LOCATION` property name in a variable up front to avoid duplicating the string literal.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 3289a84..e37a9f8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1387,6 +1387,8 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
return true;
}
+ std::string const locPropBase = "IMPORTED_LOCATION";
+
// Track the configuration-specific property suffix.
suffix = "_";
suffix += desired_config;
@@ -1412,7 +1414,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
if (mci->empty()) {
// An empty string in the mapping has a special meaning:
// look up the config-less properties.
- *loc = this->GetProperty("IMPORTED_LOCATION");
+ *loc = this->GetProperty(locPropBase);
if (allowImp) {
*imp = this->GetProperty("IMPORTED_IMPLIB");
}
@@ -1422,7 +1424,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
}
} else {
std::string mcUpper = cmSystemTools::UpperCase(*mci);
- std::string locProp = "IMPORTED_LOCATION_";
+ std::string locProp = locPropBase + "_";
locProp += mcUpper;
*loc = this->GetProperty(locProp);
if (allowImp) {
@@ -1449,7 +1451,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
// If we have not yet found it then there are no mapped
// configurations. Look for an exact-match.
if (!*loc && !*imp) {
- std::string locProp = "IMPORTED_LOCATION";
+ std::string locProp = locPropBase;
locProp += suffix;
*loc = this->GetProperty(locProp);
if (allowImp) {
@@ -1467,7 +1469,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
// Look for a configuration-less location. This may be set by
// manually-written code.
- *loc = this->GetProperty("IMPORTED_LOCATION");
+ *loc = this->GetProperty(locPropBase);
if (allowImp) {
*imp = this->GetProperty("IMPORTED_IMPLIB");
}
@@ -1485,7 +1487,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
!*loc && !*imp && aci != availableConfigs.end(); ++aci) {
suffix = "_";
suffix += cmSystemTools::UpperCase(*aci);
- std::string locProp = "IMPORTED_LOCATION";
+ std::string locProp = locPropBase;
locProp += suffix;
*loc = this->GetProperty(locProp);
if (allowImp) {