[CMake] How to get target binary name?

Thompson, K T kgt at lanl.gov
Wed Jun 20 13:54:40 EDT 2012


Robert,

I'm not sure this is exactly what you are looking for, but you may be able to use "generator expressions."  See the documentation for add_custom_command for more details, but basically you can use the expression $<TARGET_FILE:foo> to retrieve the executable name generated by target 'foo'.  I think this only works after you use add_executable( foo ${src} ).

-kt



From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Robert Dailey
Sent: Wednesday, June 20, 2012 11:41 AM
To: CMake ML
Subject: Re: [CMake] How to get target binary name?

Another note: This has to work the same for both release and debug, and for both visual studio and makefile generators.
On Wed, Jun 20, 2012 at 12:40 PM, Robert Dailey <rcdailey.lists at gmail.com<mailto:rcdailey.lists at gmail.com>> wrote:
I'm looking for the quickest and most natural way to get the final binary name of a target, ideally before add_executable() or add_library() is called (not sure if this is possible).

For example, if my executable target's output is fubar.exe, I want to get "fubar.exe" in a variable.

Any examples? Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120620/6e6db416/attachment-0001.htm>


More information about the CMake mailing list