1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-08 22:37:04 +08:00

CPS: Fix mangling of relative requirement names

CPS names look like `[package]:component`, which needs to get mangled
into `package::component` to match CMake's convention. This was
implemented correctly for fully qualified component requirements, but
relative names were not being properly mangled. Adjust handling of
relative names to correctly translate from CPS to CMake convention.
This commit is contained in:
Matthew Woehlke 2025-04-30 11:56:09 -04:00
parent 9c8fe5d0b4
commit 9081e73104
4 changed files with 35 additions and 1 deletions

View File

@ -212,7 +212,7 @@ std::string NormalizeTargetName(std::string const& name,
std::string const& context)
{
if (cmHasLiteralPrefix(name, ":")) {
return cmStrCat(context, name);
return cmStrCat(context, ':', name);
}
std::string::size_type const n = name.find_first_of(':');

View File

@ -180,6 +180,14 @@ else()
target_link_libraries(defs-test defs::defs)
endif()
###############################################################################
# Test importing and mangling of requirements (i.e. link libraries).
find_package(RequiresTest CONFIG REQUIRED)
add_library(requires-test STATIC requires-test.cxx)
target_link_libraries(requires-test RequiresTest::Indirect)
###############################################################################
# Test importing of (language-specific) include paths.

View File

@ -0,0 +1,19 @@
{
"cps_version": "0.13",
"name": "RequiresTest",
"cps_path": "@prefix@/cps",
"components": {
"Indirect": {
"type": "interface",
"requires": [ ":Direct" ]
},
"Direct": {
"type": "interface",
"definitions": {
"*": {
"ANSWER": 42
}
}
}
}
}

View File

@ -0,0 +1,7 @@
#ifndef ANSWER
# error ANSWER is not defined
#else
# if ANSWER != 42
# error ANSWER has the wrong value
# endif
#endif