[CMake] Install selected|group of targets

Eric Noulard eric.noulard at gmail.com
Wed Feb 1 19:57:50 EST 2012


2012/2/1 Joakim Hove <joakim.hove at gmail.com>:
> Hello;
>
> I have a quite large CMake project consisting of many libraries and
> executable programs. Schematically my codebase is organised as:
>
>
>
> root/CMakeLists.txt
> root/package1/CMakeLists.txt
> root/package1/lib/CMakeLists.txt
> root/package1/app/CMakeLists.txt
> root/package2/CMakeLists.txt
> root/package2/lib/CMakeLists.txt
> root/package2/app/CMakeLists.txt
> ....
>
> The CMakeLists.txt files in each of the lib directories contain
>
> add_library( pack1 ...)
>
> And in the app directories there are
>
> add_executable(app1 ...)
> add_executable(app2 ...)
>
> Now I would like to be able to install a group of libraries / executables as
> e.g.
>
> make install package2
>
> To install all the libraries and binaries under the package2/ subdirectory.
> The documentation says that something like this should be possible through
> the use of COMPONENTS - but just how is less than clear for me?

First you should use the COMPONENT parameter of the INSTALL command.
See:
cmake --help-command install
and
http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack

then you may install all the target/files/... belonging to a
particular component by doing:

cd buildir
cmake -DCOMPONENT="componentname" -P cmake_install.cmake


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list