[CMake] List all binaries associated with a target.

Klaim - Joël Lamotte mjklaim at gmail.com
Mon Mar 16 16:22:25 EDT 2015


On Mon, Mar 16, 2015 at 7:11 PM, Roman Bolshakov <roolebo at gmail.com> wrote:

> > I'm not totally sure install() does exactly what I need.
> > My use case is that I need to debug each executable in an installed-like
> > context (with data), which imply that each time it is compiled it should
> be installed too.
> > Actually 2 and 3 are the same, I just put the files in a specific place
> in the
> > build directory so that it looks like installed, but I do this when the
> binary is
> > built so that it's always up to date while debugging.
> > Now, I use post-build command (add_custom_command) to do this indeed
> > but I didn't find a way yet to trigger install() a specific binary on
> post-build yet,
> > but I suppose I just missed it so far.
>
>
> If one source tree has a few separate binaries, I'd just use
> install(TARGET) with COMPONENT specified. Even if you have a library
> which is shared between the set of separate components you can specify
> its installation for a few components using foreach loop:
> foreach(COMP A B C)
>   install(
>     TARGET common-lib
>     DESTINATION lib
>     COMPONENT ${COMP}
>   )
> endforeach()
>

Then you can invoke top-level cmake_install.cmake to install a subset
> of your project:
> DESTDIR=/destination/install/path cmake -DCOMPONENT=A -P
> cmake_install.cmake
>
>
It is not clear to me how all this would help installing automatically a
library and it's dependencies
when I modify then build the library.
If my understanding is correct, all this need to be triggered by cmake
install command, right?
Also, the main issue is gathering binaries so that they can be debugged on
windows (as you
point later) without having to move files around, in particular
dependencies binaries that
can and will change through developement.


> Also note, that if your project is shipped as one bundle on a platform
> which supports RPATH you don't need to do any actions as you can run
> any executable in build tree without any additional actions using
> add_test command. ctest can drive test execution in the build tree.
>

My debug setup issue is apparently only on Windows with VS indeed.
Someone explained to be about the RPATH and indeed it should prevent the
need for moving files around.
So far I've been happy with a python script finding all dependencies for
each library in my install directory
but I want to do it through cmake and I would like to avoid having to
specify where are the
dependencies binaries exactly, because depending on if you install them in
the system
or build them from scratch, I don't always know where to find them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150316/5d02f625/attachment.html>


More information about the CMake mailing list