cmTarget: Fix (new) configuration selection

The recently introduced CMP0200 improved configuration selection, but
did not correctly implement case-insensitivity. Add some additional case
smashing to ensure that matching is not case sensitive. Improve the test
which was passing due to falling back to the first listed configuration
rather than selecting a matching configuration.
This commit is contained in:
Matthew Woehlke committed 2025-08-27 16:23:16 -04:00
1 parent 702b7fda49
commit a40896c0e4
3 files changed
+12 -12

No files matched your search

+9 -9
View File
@@ -3416,8 +3416,7 @@ cmValue cmTarget::GetLocation(std::string const& base,
bool cmTarget::GetLocation(std::string const& config, cmValue& loc,
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
// with exports.
@@ -3446,23 +3445,24 @@ bool cmTarget::GetLocation(std::string const& config, cmValue& loc,
return loc || imp || (this->GetType() == cmStateEnums::INTERFACE_LIBRARY);
}
bool cmTarget::GetMappedConfigNew(std::string const& desiredConfig,
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.
cmList mappedConfigs;
if (!desiredConfig.empty()) {
std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_",
cmSystemTools::UpperCase(desiredConfig));
std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", desiredConfig);
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.
if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
cmList const availableConfigs{ iconfigs };
cmList const availableConfigs{ cmSystemTools::UpperCase(*iconfigs) };
if (!mappedConfigs.empty()) {
for (auto const& c : mappedConfigs) {
+1 -1
View File
@@ -352,7 +352,7 @@ private:
bool GetMappedConfigOld(std::string const& desired_config, cmValue& loc,
cmValue& imp, std::string& suffix) const;
bool GetMappedConfigNew(std::string const& desiredConfig, cmValue& loc,
bool GetMappedConfigNew(std::string desiredConfig, cmValue& loc,
cmValue& imp, std::string& suffix) const;
cmValue GetLocation(std::string const& base,
std::string const& suffix) const;
@@ -7,9 +7,9 @@
function(do_match_config_test)
add_library(lib_match INTERFACE IMPORTED)
set_target_properties(lib_match PROPERTIES
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
IMPORTED_CONFIGURATIONS "TEST;RELEASE;DEBUG"
INTERFACE_COMPILE_DEFINITIONS
"$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>"
"$<$<CONFIG:debug>:DEBUG>;$<$<CONFIG:release>:RELEASE>;$<$<CONFIG:test>:TEST>"
)
add_executable(exe_match configtest.c)