[CMake] add_custom_command doesn't know about target; but get_target_property does

Nils Gladitz nilsgladitz at gmail.com
Fri Aug 22 06:37:32 EDT 2014


On 22.08.2014 02:15, Braden McDaniel wrote:
> Ah.  Bummer.
>
> Well, as you might have guessed, I'm trying to address an issue where
> the LOCATION property of a target (EXPORT_TARGET, in the example above)
> was being used.  Is there some way I can get this information about the
> target that doesn't involve modifying the CMakeLists.txt in each
> subdirectory where a target of interest resides?

Perhaps something like:

file(GENERATE
     OUTPUT "${CMAKE_BINARY_DIR}/${LIB_PATHS}/${EXPORT_TARGET}_$<CONFIG>"
     CONTENT "$<TARGET_FILE:${EXPORT_TARGET}>"
)

Or if you want to keep this at build time a custom command with the 
OUTPUT signature and
e.g. a custom target that depends on that output.

Nils


More information about the CMake mailing list