Reputation: 871
This CMake Doc : https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html tells us that :
$<CONFIG> Configuration name.
and that :
Conditional generator expressions depend on a boolean condition that must be 0 or 1.
$<condition:true_string> Evaluates to true_string if condition is 1. Otherwise evaluates to the empty string.
$<IF:condition,true_string,false_string> New in version 3.8.
Evaluates to true_string if condition is 1. Otherwise evaluates to false_string.
Typically, the condition is a boolean generator expression. For instance,
$<$<CONFIG:Debug>:DEBUG_MODE> expands to DEBUG_MODE when the Debug configuration is used, and otherwise expands to the empty string.
If I understand correctly, in Visual Studio, if I'm switching from Debug to Release this line :
$<$<CONFIG:Debug>:DEBUG_MODE>
Should also expand to DEBUG_MODE, isn't it ? because CONFIG will contain, according to my understanding "Release" and it's a non empty string, thus it will expand to Debug, than this last will make the first generator expression expand to DEBUG_MODE because of this statement in the documentation :
$condition:true_string Evaluates to true_string if condition is 1. Otherwise evaluates to the empty string.
I know I'm wrong, please help me to understand how it works.
Upvotes: 2
Views: 637
Reputation: 141881
because CONFIG will contain
CONFIG
does not contain, it's not a condition, it's a specific Variable query with special rules.
$<CONFIG:cfgs> 1 if config is any one of the entries in cfgs, else 0. [...]
Let's say it works like this:
A
and B
like $<A:B>
A
is CONFIG
- then do stuff related to CONFIG
A
is, for example, STREQUAL
- then do stuff on B
related to STREQUAL
.condition
, so if it's 1
, then return B
, otherwise empty string.Upvotes: 2