Suppose I set the following variable in CMake:
set(foo TRUE)
Now, I want to define a bar
variable with the opposite boolean value of foo
(in other words: in this context, I want bar
to be FALSE
, or equivalent, like false
or 0
). One way of completing this is:
if(foo)
set(bar FALSE)
else()
set(bar TRUE)
endif()
However, this is kinda verbose. How can I accomplish the same thing in fewer lines?
Notes
I tried to use generator expressions, but they don't seem to work in the set
command:
set(bar $<NOT:${foo}>)
Or even
set(bar $<NOT:foo>)
Won't produce the desired result.