As far as I can tell, you’re able to pass generator expressions to CMake through the command-line and have them be evaluated appropriately. This comes in handy when wanting to set
CMAKE_MSVC_RUNTIME_LIBRARY for some third-party library while using a multi-config generator like
cmake -B ./build -G "Ninja Multi-Config" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Foo,Bar>:Debug> cmake --build ./build --config Foo
How do you achieve the same thing with
ExternalProject_Add and its
CMAKE_ARGS without the generator expression being evaluated in the calling project?
I’ve tried replacing every closing angle bracket with
$<ANGLE-R> in hopes that it would somehow defer the evaluation of the generator expression, but without luck. My every attempt at trying to escape the generator expression has resulted in the generator expressions either still being evaluated in the calling project (i.e. not getting escaped) or seemingly just turned into a token soup that CMake can’t understand and it falls back to the default value of