You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some CMake functions, like add_compile_definitions, accept generator expressions these take the form of $<...> and are only evaluated at generation time, not at configure time such as regular variables.
the CMakeToolchain conan uses some of these functions with dynamic values in conan_toolchain.cmake. This brings some problems, however, because values need to be escaped. For example:
which will evaluate (in the debug config) as: abc 1 def >. Note that first assigning define to a CMake variable and using that in the expression as in "$<$<CONFIG:Debug>:${var}>" does not save us, as ${var} is evaluated at the configuration stage, before generation time.
To solve the issue, we need to escape (besides " and the usual):
Describe the bug
Some CMake functions, like
add_compile_definitions
, accept generator expressions these take the form of$<...>
and are only evaluated at generation time, not at configure time such as regular variables.the CMakeToolchain conan uses some of these functions with dynamic values in
conan_toolchain.cmake
. This brings some problems, however, because values need to be escaped. For example:add_compile_definitions("$<$<CONFIG:Debug>:{{define}}>")
with
define
=MYMACRO=abc $<CONFIG:Debug> def > 123
becomes:which will evaluate (in the debug config) as:
abc 1 def >
. Note that first assigningdefine
to a CMake variable and using that in the expression as in"$<$<CONFIG:Debug>:${var}>"
does not save us, as${var}
is evaluated at the configuration stage, before generation time.To solve the issue, we need to escape (besides
"
and the usual):>
as$<ANGLE-R>
$
as$<1:$>
(think:if(1) return "$"
),
and;
may need to be escaped as well.Note that this should not just be done inside of generator expressions, but for all arguments that accept them, even if conan does not use them.
How to reproduce it
E.g. set
tools.build:defines=['MYMACRO=abc $<CONFIG:Debug> def > 123']
and observe how the actual define passed to the compiler is not the same.The text was updated successfully, but these errors were encountered: