cmPackageInfoReader: Fix default configurations
Fix two minor issues with how default configurations are set from CPS packages. First, imported configurations were (appropriately) being converted to upper case, but default configurations weren't. Second, default configurations were being set only after importing components from the root package configuration file, resulting in configurations specified in the root file preceding the default configurations.
This commit is contained in:
parent
2b0d0b1544
commit
63c96e76f9
@ -472,7 +472,11 @@ std::unique_ptr<cmPackageInfoReader> cmPackageInfoReader::Read(
|
||||
reader->ComponentTargets = parent->ComponentTargets;
|
||||
reader->DefaultConfigurations = parent->DefaultConfigurations;
|
||||
} else {
|
||||
reader->DefaultConfigurations = ReadList(reader->Data, "configurations");
|
||||
for (std::string const& config :
|
||||
ReadList(reader->Data, "configurations")) {
|
||||
reader->DefaultConfigurations.emplace_back(
|
||||
cmSystemTools::UpperCase(config));
|
||||
}
|
||||
}
|
||||
|
||||
return reader;
|
||||
@ -664,6 +668,12 @@ cmTarget* cmPackageInfoReader::AddLibraryComponent(
|
||||
// Create the imported target.
|
||||
cmTarget* const target = makefile->AddImportedTarget(name, type, false);
|
||||
|
||||
// Set default configurations.
|
||||
if (!this->DefaultConfigurations.empty()) {
|
||||
target->SetProperty("IMPORTED_CONFIGURATIONS",
|
||||
cmJoin(this->DefaultConfigurations, ";"_s));
|
||||
}
|
||||
|
||||
// Set target properties.
|
||||
this->SetTargetProperties(makefile, target, data, package, {});
|
||||
auto const& cfgData = data["configurations"];
|
||||
@ -671,12 +681,6 @@ cmTarget* cmPackageInfoReader::AddLibraryComponent(
|
||||
this->SetTargetProperties(makefile, target, *ci, package, IterKey(ci));
|
||||
}
|
||||
|
||||
// Set default configurations.
|
||||
if (!this->DefaultConfigurations.empty()) {
|
||||
target->SetProperty("IMPORTED_CONFIGURATIONS",
|
||||
cmJoin(this->DefaultConfigurations, ";"_s));
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -267,3 +267,20 @@ elseif(TARGET TransitiveDep::Target4)
|
||||
elseif(TARGET TransitiveDep::Target5)
|
||||
message(SEND_ERROR "TransitiveDep::Target5 exists ?!")
|
||||
endif()
|
||||
|
||||
###############################################################################
|
||||
# Test default configurations.
|
||||
|
||||
find_package(DefaultConfigurationsTest)
|
||||
if(NOT DefaultConfigurationsTest_FOUND)
|
||||
message(SEND_ERROR "DefaultConfigurationsTest not found !")
|
||||
elseif(NOT TARGET DefaultConfigurationsTest::Target)
|
||||
message(SEND_ERROR "DefaultConfigurationsTest::Target missing !")
|
||||
else()
|
||||
get_property(dct_configs
|
||||
TARGET DefaultConfigurationsTest::Target PROPERTY IMPORTED_CONFIGURATIONS)
|
||||
if(NOT "${dct_configs}" STREQUAL "DEFAULT;TEST")
|
||||
message(SEND_ERROR "DefaultConfigurationsTest::Target has wrong configurations '${dct_configs}' !")
|
||||
endif()
|
||||
set(dct_configs)
|
||||
endif()
|
||||
|
16
Tests/FindPackageCpsTest/cps/DefaultConfigurationsTest.cps
Normal file
16
Tests/FindPackageCpsTest/cps/DefaultConfigurationsTest.cps
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"cps_version": "0.13",
|
||||
"name": "DefaultConfigurationsTest",
|
||||
"cps_path": "@prefix@/cps",
|
||||
"configurations": [ "Default" ],
|
||||
"components": {
|
||||
"Target": {
|
||||
"type": "interface",
|
||||
"configurations": {
|
||||
"Test": {
|
||||
"includes": [ "@prefix@/include" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user