[CMake] How to get target binary name?

David Cole david.cole at kitware.com
Wed Jun 20 14:50:17 EDT 2012


But do especially note:

"The path may contain a build-system-specific portion that is replaced at
build time with the configuration getting built (such as
"$(ConfigurationName)" in VS)."



On Wed, Jun 20, 2012 at 2:48 PM, David Cole <david.cole at kitware.com> wrote:

> Yes, with:
>
>   http://cmake.org/cmake/help/v2.8.8/cmake.html#prop_tgt:LOCATION
>     or
>   http://cmake.org/cmake/help/v2.8.8/cmake.html#prop_tgt:LOCATION_CONFIGfor per-config values
>
> and:
>
>
> http://cmake.org/cmake/help/v2.8.8/cmake.html#command:get_filename_component
>
>
> HTH,
> David
>
>
> On Wed, Jun 20, 2012 at 2:33 PM, Robert Dailey <rcdailey.lists at gmail.com>wrote:
>
>> If I were to try to do this *after* calling add_executable() or
>> add_library(), would it be easier to obtain?
>>
>>
>> On Wed, Jun 20, 2012 at 12:54 PM, Thompson, K T <kgt at lanl.gov> wrote:
>>
>>>  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> 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.****
>>>
>>> ** **
>>>
>>
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120620/1934f42a/attachment.htm>


More information about the CMake mailing list