[CMake] Trouble with conditional generator expression inside target_link_libraries

Eric Noulard eric.noulard at gmail.com
Thu Oct 4 13:12:26 EDT 2018


Le jeu. 4 oct. 2018 à 18:59, Marc CHEVRIER <marc.chevrier at gmail.com> a
écrit :

> I am afraid that you cannot mix "optimized" or "debug" keywords with
> "generator expressions" because keywords handling is done during evaluation
> of command "target_link_libraries" and "generator expressions" are
> evaluated during generation.
>
> And target_link_libraries expect following pattern: [<keyword>] <library>
> [<library> ...], so specifying a generator expression wrapping this breaks
> the parsing of the arguments: keyword is no longer at the beginning of the
> sequence so it is no longer  recognized as is...
>
> So, The most efficient way to work-around this problem is to transform
> your list of libraries in valid generator expressions:
>
>    - INITIAL: optimized foo debug food_d
>    - RESULT: $<$<CONFIG:RELEASE>:foo> $<$<CONFIG:DEBUG>:foo_d>
>
> For that purpose, an helper function can do the trick...
>

I agree with you Marc but I nevertheless think the handling of list in
genex has something unexpected.

See my previous example with custom target.

-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181004/76c69e1f/attachment.html>


More information about the CMake mailing list