[CMake] Getting the source file list for an executable fails
Campbell Barton
ideasman42 at gmail.com
Thu Sep 15 21:24:56 EDT 2011
On Fri, Sep 16, 2011 at 11:11 AM, Michael Hertling <mhertling at online.de> wrote:
> On 09/16/2011 02:59 AM, Campbell Barton wrote:
>> Hi, I would expect this would work from reading the docs but it gives
>>
>> add_executable(mytarget ${SRC})
>> get_property(TESTPROP_A TARGET mytarget PROPERTY SOURCE)
>> get_target_property(TESTPROP_B mytarget SOURCE)
>> message(FATAL_ERROR "Testing ${TESTPROP_A}, ${TESTPROP_B}")
>>
>> The output I get is:
>>
>> Testing '', 'TESTPROP_B-NOTFOUND'
>>
>> This is odd since properties "TYPE" and "LOCATION" are found
>>
>> Obviously in this case ${SRC} is already available, but I'm just
>> trying to figure out why it fails.
>>
>> tested on cmake 2.8.5
>
> The property you probably refer to is named SOURCES, not SOURCE. The
> different results returned by GET_PROPERTY() and GET_TARGET_PROPERTY()
> are documented: The former returns an empty value if the property isn't
> set, and the latter returns the NOTFOUND value, both evaluating to FALSE.
>
> Regards,
>
> Michael
Ack!, sorry for the dumb mistake, but now I'm faced with a different problem.
Getting the sources for a library defined in another directory, and it
gives me relative paths.
How do you get the path a library is defined in so I can make the
absolute paths? - tried LOCATION but this gives the output location.
PREFIX, SUFFIX are not set.
More information about the CMake
mailing list