[CMake] Getting the source file list for an executable fails

Michael Hertling mhertling at online.de
Thu Sep 15 21:11:28 EDT 2011


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


More information about the CMake mailing list