Merge topic 'fix-cps-relative-name-mangling'

9081e73104 CPS: Fix mangling of relative requirement names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10729
This commit is contained in:
Brad King
2025-05-01 12:31:04 +00:00
committed by Kitware Robot
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

@@ -175,6 +175,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