[CMake] How to get target binary name?

Christian Arnault arnault at lal.in2p3.fr
Wed Jun 20 15:03:00 EDT 2012


Hi,

More generally speaking, I'm looking a way to query the existing 
configuration in terms of
- what are the libraries, executables, tests, etc...
- properties, compiler flags
declared through out various CMakeLists.txt
and WHERE they are declared ie in which directory (package)

This is also related with the former question: why to separate config 
phase from build phase?

In a very large project, made of a large number of packages in a wide 
DAG , developped by a large teas of developers, it's very desirable to 
QUERY such config without having to find/grep through out the zillions 
of CMakeLists.txt files.

It should trivial for CMake developers to add a kind of Database of all 
items to be constructed (basically all targets + how they are setup)

goals:

- debugging purposes
- understanding why/where/how a target exists
- understanding the relationships/dependencies between targets (even for 
those are not under your control)
- figure out the directory structure of the software base

I have managed to replace most of the add_xxx functions (plus some 
others) so as to offer the query feature to CMake but would it be 
offered by native CMake, this would be safer and efficient.

Comments?

Regards
Christian


Le 20/06/2012 20:48, David Cole a écrit :
> 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_CONFIG 
> for 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 <mailto: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
>     <mailto: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>
>         [mailto: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.
>
>
>
>     --
>
>     Powered by www.kitware.com <http://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
>
>
>
>
> --
>
> 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


-- 
--------------------------------------------
| Christian Arnault                        |
| LAL Bat 200 pièce 03a                    |
| 91405 Orsay CEDEX                        |
| phone   : (33) 1 64 46 84 24             |
| gsm     : (33) 6 77 27 62 30             |
| fax     : (33) 1 69 07 94 04             |
| e-mail  : christian.arnault at lal.in2p3.fr |
--------------------------------------------

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


More information about the CMake mailing list