Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake variable names case sensitive?

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?

like image 967
usr1234567 Avatar asked Jan 26 '16 21:01

usr1234567


People also ask

What is ${} in CMake?

Local Variables You access a variable by using ${} , such as ${MY_VARIABLE} . 1. CMake has the concept of scope; you can access the value of the variable after you set it as long as you are in the same scope. If you leave a function or a file in a sub directory, the variable will no longer be defined.


3 Answers

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.

like image 124
Antonio Avatar answered Sep 23 '22 02:09

Antonio


They are case sensitive.

Here an example:

set(foo 42)

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

Output:

-- 42
-- 
like image 35
Mijago Avatar answered Sep 25 '22 02:09

Mijago


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

like image 32
steveire Avatar answered Sep 23 '22 02:09

steveire