mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
Merge topic 'cps-fix-default-configs' into release-4.0
63c96e76f9
cmPackageInfoReader: Fix default configurations
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10469
This commit is contained in:
@@ -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" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user