[CMake] Getting a filename from a target.

Brad King brad.king at kitware.com
Tue Feb 15 12:08:50 EST 2005


Moreland, Kenneth wrote:
> Is there a way to get the name of the file generated by a target?  For
> example, when a CMake command like ADD_EXECUTABLE(Foo ...) or
> ADD_LIBRARY(Foo ...) is given, a target named Foo is created, but so is
> one that points to a file that is generated on the system.  How do you
> get the name of this latter target that points to a usable file?

You can use GET_TARGET_PROPERTY to get the location of the target.  The 
reference produced is valid only inside the build system (though on some 
platforms it may be valid anywhere).  It is used for adding custom 
commands involving the target.  See this FAQ entry:

http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F

-Brad


More information about the CMake mailing list