Issue
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.
Solution
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:
- extract the parts
A
andB
like$<A:B>
- if part
A
isCONFIG
- then do stuff related toCONFIG
- if part
A
is, for example,STREQUAL
- then do stuff onB
related toSTREQUAL
. - for each case ...
- otherwise it's a
condition
, so if it's1
, then returnB
, otherwise empty string.
Answered By - KamilCuk Answer Checked By - Clifford M. (WPSolving Volunteer)