[cmake-developers] [Discussion] Add python support for CMakeLists
Florent Castelli
florent.castelli at gmail.com
Mon Jan 16 17:37:43 EST 2017
>
> It's up to users to use generator expressions instead of if(WIN32) or
> whatever:
>
> add_library(foo
> foo.cpp
> $<$<PLATFORM_ID:Windows>:foo_win.cpp>
> )
>
> This has been possible for years and was designed with IDEs in mind:
Sure, it’s possible, but it’s not very user friendly or declarative (you need to parse and interpret the generator expression).
>
> http://public.kitware.com/pipermail/cmake-developers/2014-September/023042.html
>
>> I find that most of the conditionals are just to create the list of
>> sources per platform and then the list of dependencies. It’s certainly
>> possible to use generator expressions for some cases, but they don’t have
>> the prettiest syntax around, and maybe also not access to all the local
>> variables that you need to pick the right files.
>
> You should be able to put any configure-time variable through the generator
> expressions $<BOOL> or $<STREQUAL> to make them genex-compatible.
Same, it’s not user friendly or a great syntax.
I’ve rarely seen any advanced usage in projects in the wild, I think for that very reason.
One thing that I dislike in genex is that there is no “else” clause.
So you have to duplicate the whole condition and add a $<NOT> around it.
Having something close to a ternary operator would be nice.
/Florent
More information about the cmake-developers
mailing list