在全局范围内可用的库中定义的CMake变量

时间:2019-04-29 12:18:14

标签: c++ cmake

在仅标头的库中定义CMake变量并使它们在其依赖范围中可用的最佳方法是什么?

例如:

    <#assign test = { "apple": "5", "banana": {"kiwi": 15 }} >

Directly access your key and display the value. (if you know the key)

    ${test.banana.kiwi}

Dynamically list the keys

    <#list test.banana?keys as k>
    ${k}
    </#list>

Dynamically list the values

    <#list test.banana?values as v>
    ${v}
    </#list>

Dynamically list the keys and values

    <#list test.banana as k,v >
    ${k}: ${v}
    </#list>

# Header-only library CMakeLists.txt
[...]
add_library(SomeLibrary INTERFACE)
set(FOO "Foo is defined" PARENT_SCOPE)     # this doesn't work

0 个答案:

没有答案