[cmake-developers] target sources property

Brad King brad.king at kitware.com
Wed Jul 10 09:31:31 EDT 2013


On 07/09/2013 11:30 AM, Stephen Kelly wrote:
> Brad King <brad.king at ...> writes:
>> On 06/07/2013 09:13 AM, Stephen Kelly wrote:
>>>    SOURCES $<$<CONFIG:Debug>:other.cpp>
>>
>> That has been requested as a feature occasionally.  I'm not sure
>> it is possible to implement on all the generators though.

I just checked the VS 6, 9 and 11 IDEs and it is possible to mark
a source file as excluded from certain configurations.  Those versions
represent all the VS generators.  I do not see an obvious way to do it
in Xcode though :(

> I looked into this a bit and pushed target-SOURCES-property to my clone. The
> sources would necessarily be config-specific if they are going to depend on
> the linked libraries.
> 
> Can you think of any way around that?

No.  IIRC we have the same problem with inter-target dependencies and
we solved it by taking the union of dependencies from all configs.
Is that right?  I don't think that solution can work for source files.
Perhaps for Xcode we can generate wrapper sources that conditionally
#include the real source based on the configuration.  Hopefully there
is a better way.

BTW, the hunk

-    this->SetProperty("SOURCES", ss.str().c_str());
+    this->SetProperty("SOURCES_INTERNAL", ss.str().c_str());
+    return this->GetProperty("SOURCES_INTERNAL");

does not need to set an internal property.  We can just return the
string.  The only reason the old code set the property was to fall
through to the normal property lookup later in the method.

-Brad



More information about the cmake-developers mailing list