[cmake-developers] [CMake] add_custom_command() OUTPUT does not accept generator expressions, why?

Brad King brad.king at kitware.com
Wed Apr 6 10:12:33 EDT 2016


On 04/06/2016 09:59 AM, Yves Frederix wrote:
> In order to implement this, CMake should be able to determine if the
> result of resolving a generator expression depends on the
> configuration or not.

Not necessarily.  It can simply evaluate it with each configuration
to be generated and the result for each compared.  Build a list of
sources with per-configuration activation marks.  Use that to do
the actual generation.  This intermediate list/set/map may be needed
internally to do post-genex/per-config source file lookup anyway.

> Does the generator expression logic currently allow such check?

I don't remember ;)

>> A fallback approach could be to generate a wrapper source file
>> that uses the preprocessor to conditionally include the real
>> per-config source file based on the configuration.
> 
> That would be an option as well. I suspect best by using the
> CMAKE_INTDIR preprocessor define?

No, that just defines a string literal that we can't switch off.
I think it would be a source-specific generated macro name.

-Brad



More information about the cmake-developers mailing list