CMake variable names case sensitive?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 12:31:57

问题


How does CMake treat variable names? Are they case sensitive?

If I use FindFoo.cmake with

find_package(Foo)

can I use FOO_FOUND, Foo_FOUND and foo_FOUND?


回答1:


CMake variables are case sensitive. See documentation.


As a side note, commands are case insensitive, and their arguments are case sensitive. See wiki. Keywords like STATUS are case sensitive because they are arguments. Example:

message(STATUS foo)
MESSAGE(status foo)

outputs:

foo
statusfoo

the second marked as a warning (default message type).

Still regarding case sensitivity, take also a look to the boolean variable section.




回答2:


They are case sensitive.

Here an example:

set(foo 42)

MESSAGE( STATUS ${foo})
MESSAGE( STATUS ${Foo})

Output:

-- 42
-- 



回答3:


Look at the documentation of FindFoo to find out what the correct _FOUND variable is. Or maybe use this tool someday:

https://youtu.be/BPgXuvPAl-8?t=659



来源:https://stackoverflow.com/questions/35023939/cmake-variable-names-case-sensitive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!