Pārlūkot izejas kodu

Merge topic 'fix-config-selection'

a40896c0e4 cmTarget: Fix (new) configuration selection
702b7fda49 cmTarget: Improve code style

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !11122
Brad King 1 mēnesi atpakaļ
vecāks
revīzija
1dfe9898e6

+ 18 - 18
Source/cmTarget.cxx

@@ -3210,7 +3210,7 @@ bool cmTargetInternals::CheckImportedLibName(std::string const& prop,
   return true;
   return true;
 }
 }
 
 
-bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc,
+bool cmTarget::GetMappedConfig(std::string const& desiredConfig, cmValue& loc,
                                cmValue& imp, std::string& suffix) const
                                cmValue& imp, std::string& suffix) const
 {
 {
   switch (this->GetPolicyStatusCMP0200()) {
   switch (this->GetPolicyStatusCMP0200()) {
@@ -3221,9 +3221,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc,
       }
       }
       CM_FALLTHROUGH;
       CM_FALLTHROUGH;
     case cmPolicies::OLD:
     case cmPolicies::OLD:
-      return this->GetMappedConfigOld(desired_config, loc, imp, suffix);
+      return this->GetMappedConfigOld(desiredConfig, loc, imp, suffix);
     case cmPolicies::NEW:
     case cmPolicies::NEW:
-      return this->GetMappedConfigNew(desired_config, loc, imp, suffix);
+      return this->GetMappedConfigNew(desiredConfig, loc, imp, suffix);
   }
   }
 
 
   cmValue newLoc;
   cmValue newLoc;
@@ -3231,9 +3231,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc,
   std::string newSuffix;
   std::string newSuffix;
 
 
   bool const newResult =
   bool const newResult =
-    this->GetMappedConfigNew(desired_config, newLoc, newImp, newSuffix);
+    this->GetMappedConfigNew(desiredConfig, newLoc, newImp, newSuffix);
 
 
-  if (!this->GetMappedConfigOld(desired_config, loc, imp, suffix)) {
+  if (!this->GetMappedConfigOld(desiredConfig, loc, imp, suffix)) {
     if (newResult) {
     if (newResult) {
       // NEW policy found a configuration, OLD did not.
       // NEW policy found a configuration, OLD did not.
       auto newConfig = cm::string_view{ newSuffix }.substr(1);
       auto newConfig = cm::string_view{ newSuffix }.substr(1);
@@ -3416,8 +3416,7 @@ cmValue cmTarget::GetLocation(std::string const& base,
 bool cmTarget::GetLocation(std::string const& config, cmValue& loc,
 bool cmTarget::GetLocation(std::string const& config, cmValue& loc,
                            cmValue& imp, std::string& suffix) const
                            cmValue& imp, std::string& suffix) const
 {
 {
-  suffix = (config.empty() ? std::string{}
-                           : cmStrCat('_', cmSystemTools::UpperCase(config)));
+  suffix = (config.empty() ? std::string{} : cmStrCat('_', config));
 
 
   // There may be only IMPORTED_IMPLIB for a shared library or an executable
   // There may be only IMPORTED_IMPLIB for a shared library or an executable
   // with exports.
   // with exports.
@@ -3446,23 +3445,24 @@ bool cmTarget::GetLocation(std::string const& config, cmValue& loc,
   return loc || imp || (this->GetType() == cmStateEnums::INTERFACE_LIBRARY);
   return loc || imp || (this->GetType() == cmStateEnums::INTERFACE_LIBRARY);
 }
 }
 
 
-bool cmTarget::GetMappedConfigNew(std::string const& desired_config,
-                                  cmValue& loc, cmValue& imp,
-                                  std::string& suffix) const
+bool cmTarget::GetMappedConfigNew(std::string desiredConfig, cmValue& loc,
+                                  cmValue& imp, std::string& suffix) const
 {
 {
+  desiredConfig = cmSystemTools::UpperCase(desiredConfig);
+
   // Get configuration mapping, if present.
   // Get configuration mapping, if present.
   cmList mappedConfigs;
   cmList mappedConfigs;
-  if (!desired_config.empty()) {
-    std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_",
-                                   cmSystemTools::UpperCase(desired_config));
+  if (!desiredConfig.empty()) {
+    std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", desiredConfig);
     if (cmValue mapValue = this->GetProperty(mapProp)) {
     if (cmValue mapValue = this->GetProperty(mapProp)) {
-      mappedConfigs.assign(*mapValue, cmList::EmptyElements::Yes);
+      mappedConfigs.assign(cmSystemTools::UpperCase(*mapValue),
+                           cmList::EmptyElements::Yes);
     }
     }
   }
   }
 
 
   // Get imported configurations, if specified.
   // Get imported configurations, if specified.
   if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
   if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
-    cmList const availableConfigs{ iconfigs };
+    cmList const availableConfigs{ cmSystemTools::UpperCase(*iconfigs) };
 
 
     if (!mappedConfigs.empty()) {
     if (!mappedConfigs.empty()) {
       for (auto const& c : mappedConfigs) {
       for (auto const& c : mappedConfigs) {
@@ -3478,8 +3478,8 @@ bool cmTarget::GetMappedConfigNew(std::string const& desired_config,
     }
     }
 
 
     // There is no mapping; try the requested configuration first.
     // There is no mapping; try the requested configuration first.
-    if (cm::contains(availableConfigs, desired_config)) {
-      this->GetLocation(desired_config, loc, imp, suffix);
+    if (cm::contains(availableConfigs, desiredConfig)) {
+      this->GetLocation(desiredConfig, loc, imp, suffix);
       return true;
       return true;
     }
     }
 
 
@@ -3504,7 +3504,7 @@ bool cmTarget::GetMappedConfigNew(std::string const& desired_config,
 
 
   // There is no mapping and no explicit list of configurations; the only
   // There is no mapping and no explicit list of configurations; the only
   // configuration left to try is the requested configuration.
   // configuration left to try is the requested configuration.
-  if (this->GetLocation(desired_config, loc, imp, suffix)) {
+  if (this->GetLocation(desiredConfig, loc, imp, suffix)) {
     return true;
     return true;
   }
   }
 
 

+ 2 - 2
Source/cmTarget.h

@@ -234,7 +234,7 @@ public:
   bool IsRuntimeBinary() const;
   bool IsRuntimeBinary() const;
   bool CanCompileSources() const;
   bool CanCompileSources() const;
 
 
-  bool GetMappedConfig(std::string const& desired_config, cmValue& loc,
+  bool GetMappedConfig(std::string const& desiredConfig, cmValue& loc,
                        cmValue& imp, std::string& suffix) const;
                        cmValue& imp, std::string& suffix) const;
 
 
   //! Return whether this target is an executable with symbol exports enabled.
   //! Return whether this target is an executable with symbol exports enabled.
@@ -352,7 +352,7 @@ private:
 
 
   bool GetMappedConfigOld(std::string const& desired_config, cmValue& loc,
   bool GetMappedConfigOld(std::string const& desired_config, cmValue& loc,
                           cmValue& imp, std::string& suffix) const;
                           cmValue& imp, std::string& suffix) const;
-  bool GetMappedConfigNew(std::string const& desired_config, cmValue& loc,
+  bool GetMappedConfigNew(std::string desiredConfig, cmValue& loc,
                           cmValue& imp, std::string& suffix) const;
                           cmValue& imp, std::string& suffix) const;
   cmValue GetLocation(std::string const& base,
   cmValue GetLocation(std::string const& base,
                       std::string const& suffix) const;
                       std::string const& suffix) const;

+ 2 - 2
Tests/RunCMake/GeneratorExpression/CMP0200-cases.cmake

@@ -7,9 +7,9 @@
 function(do_match_config_test)
 function(do_match_config_test)
   add_library(lib_match INTERFACE IMPORTED)
   add_library(lib_match INTERFACE IMPORTED)
   set_target_properties(lib_match PROPERTIES
   set_target_properties(lib_match PROPERTIES
-    IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+    IMPORTED_CONFIGURATIONS "TEST;RELEASE;DEBUG"
     INTERFACE_COMPILE_DEFINITIONS
     INTERFACE_COMPILE_DEFINITIONS
-      "$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>"
+      "$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>;$<$<CONFIG:test>:TEST>"
   )
   )
 
 
   add_executable(exe_match configtest.c)
   add_executable(exe_match configtest.c)