[CMake] --graphviz and generator expressions

Andrew Fuller mactalla.obair at gmail.com
Thu Jun 5 16:44:44 EDT 2014


Sorry, I meant to keep this on the mailing list.  Hit reply without
checking.

On Thu, Jun 5, 2014 at 1:33 PM, Andrew Fuller <mactalla.obair at gmail.com>
wrote:

> A non-trivial overhaul of the graphviz option implementation will
>> be needed to make it useful on projects using modern features.
>>
>
> Okay, I understand.
>
> As I've continued to investigate this I think my issue is actually deeper.
>
> When setting compiler definitions I can set a list within a generator
> expression and the entire set is handled correctly.
>
> eg:
> target_compile_definitions( my_target PRIVATE
>  $<$<PLATFORM_ID:Windows>:winone;wintwo>
>  $<$<PLATFORM_ID:Linux>:linuxone;linuxtwo> )
> gives -Dlinuxone -Dlinuxtwo on the command line under Linux.
>
> However, trying to do the same with target_link_libraries yields different
> results:
> target_link_libraries( my_target PRIVATE
>  $<$<PLATFORM_ID:Windows>:win.1;win.2>
>  $<$<PLATFORM_ID:Linux>:lin.1;lin.2> )
> gives a link line of -lwin.2 -llin.1 -llin.2
>
> As I was experimenting I discovered that $<JOIN:...> provides an
> interesting perspective into the issue:
> target_link_libraries( my_target PRIVATE
>  $<$<PLATFORM_ID:Windows>:$<JOIN:win.1;win.2, -I>>
>  $<$<PLATFORM_ID:Linux>:lin.1;lin.2> )
> gives a link line of -llin.1 -llin.2
> $<JOIN...> seems to correctly group the list so the elements don't leak
> out of the generator expression.  At least when the condition evaluates to
> 0.
>
> However,
> target_link_libraries( my_target PRIVATE
>  $<$<PLATFORM_ID:Windows>:$<JOIN:win.1;win.2, -I>>
>  $<$<PLATFORM_ID:Linux>:$<JOIN:lin.1;lin.2, -l>> )
> Gives
> CMake Error:
>
>   Error evaluating generator expression:
>
>     $<JOIN:lin.1>
>
>   $<JOIN> expression requires 2 comma separated parameters, but got 1
>   instead.
>
> It appears in this instance as though the list is being split before the
> generator expression is being evaluated.  $<JOIN...> seems to function as
> expected when used in target_compile_definitions.
>
> Is there a limitation in target_link_libraries I should be aware of?  I
> didn't find anything obvious in the documentation.
> I should mention I'm running 3.0.0-rc3 and set cmake_policy( VERSION 3.0 ).
>
> Thanks,
> -Andrew
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140605/526535fe/attachment.html>


More information about the CMake mailing list