From 1d1f1eeb6a52d464d476eb0a46eb75c452e3dfbc Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Nov 2016 16:10:31 -0400 Subject: 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. --- Source/cmTarget.cxx | 12 +++++++----- 1 file 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) { -- cgit v0.12