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:
parent
9c8fe5d0b4
commit
9081e73104
@ -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(':');
|
||||
|
@ -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.
|
||||
|
||||
|
19
Tests/FindPackageCpsTest/cps/RequiresTest.cps
Normal file
19
Tests/FindPackageCpsTest/cps/RequiresTest.cps
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
Tests/FindPackageCpsTest/requires-test.cxx
Normal file
7
Tests/FindPackageCpsTest/requires-test.cxx
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef ANSWER
|
||||
# error ANSWER is not defined
|
||||
#else
|
||||
# if ANSWER != 42
|
||||
# error ANSWER has the wrong value
|
||||
# endif
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user