summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorJens Weggemann <jensweh@gmail.com>2016-10-19 01:39:51 (GMT)
committerBrad King <brad.king@kitware.com>2016-10-20 15:51:10 (GMT)
commit149d49ea7c009f9965d9be91cdac8ee6cd2cfb91 (patch)
tree6c30032dfb6c819563174121df090cea9a007258 /Source/cmTarget.cxx
parent60d73393a50944c1e81472d7e80a458bcb898554 (diff)
downloadCMake-149d49ea7c009f9965d9be91cdac8ee6cd2cfb91.zip
CMake-149d49ea7c009f9965d9be91cdac8ee6cd2cfb91.tar.gz
CMake-149d49ea7c009f9965d9be91cdac8ee6cd2cfb91.tar.bz2
Teach MAP_IMPORTED_CONFIG_<CONFIG> to support configuration-less import
If this property has an empty list entry, check for `IMPORTED_LOCATION` instead of `IMPORTED_LOCATION_<CONFIG>`. This allows custom imported targets to have some configurations mapped and others fall back to a default location. Closes: #16280
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx41
1 files changed, 27 insertions, 14 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 3a22309..de30f98 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1395,7 +1395,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
std::string mapProp = "MAP_IMPORTED_CONFIG_";
mapProp += desired_config;
if (const char* mapValue = this->GetProperty(mapProp)) {
- cmSystemTools::ExpandListArgument(mapValue, mappedConfigs);
+ cmSystemTools::ExpandListArgument(mapValue, mappedConfigs, true);
}
}
@@ -1408,20 +1408,33 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
for (std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
!*loc && !*imp && mci != mappedConfigs.end(); ++mci) {
// Look for this configuration.
- std::string mcUpper = cmSystemTools::UpperCase(*mci);
- std::string locProp = "IMPORTED_LOCATION_";
- locProp += mcUpper;
- *loc = this->GetProperty(locProp);
- if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB_";
- impProp += mcUpper;
- *imp = this->GetProperty(impProp);
- }
+ if (mci->empty()) {
+ // An empty string in the mapping has a special meaning:
+ // look up the config-less properties.
+ *loc = this->GetProperty("IMPORTED_LOCATION");
+ if (allowImp) {
+ *imp = this->GetProperty("IMPORTED_IMPLIB");
+ }
+ // If it was found, set the suffix.
+ if (*loc || *imp) {
+ suffix = "";
+ }
+ } else {
+ std::string mcUpper = cmSystemTools::UpperCase(*mci);
+ std::string locProp = "IMPORTED_LOCATION_";
+ locProp += mcUpper;
+ *loc = this->GetProperty(locProp);
+ if (allowImp) {
+ std::string impProp = "IMPORTED_IMPLIB_";
+ impProp += mcUpper;
+ *imp = this->GetProperty(impProp);
+ }
- // If it was found, use it for all properties below.
- if (*loc || *imp) {
- suffix = "_";
- suffix += mcUpper;
+ // If it was found, use it for all properties below.
+ if (*loc || *imp) {
+ suffix = "_";
+ suffix += mcUpper;
+ }
}
}