CMake variable names case sensitive?

2019-06-15 15:50发布

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?

3条回答
走好不送
2楼-- · 2019-06-15 16:29

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.

查看更多
倾城 Initia
3楼-- · 2019-06-15 16:38

They are case sensitive.

Here an example:

set(foo 42)

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

Output:

-- 42
-- 
查看更多
Melony?
4楼-- · 2019-06-15 16:42

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

查看更多
登录 后发表回答