[CMake] What are the best practices for project installation hierarchy?

J Decker d3ck0r at gmail.com
Sat Jun 21 14:52:49 EDT 2014


Install has a DESTINATION option; which should be used rather than
modifying what the install path is....
well I guess depends on the method... install( targets ) has 3
destinations, LIBRARY_DESTINTION, RUNTIME_DESTINATION,
(something)_DESTINATION for shared library output


On Sat, Jun 21, 2014 at 11:14 AM, Egor Tensin <egor.tensin at gmail.com> wrote:

> Hello,
>
> I'm bothered with my approach to `install`ing CMake-enabled project
> components. The whole source tree is separated into "libs" and
> "examples" subdirectories, with a lot of libraries under the "libs"
> subdirectory and library usage examples under the "examples"
> subdirectory.
>
> For example:
> .
> ├── examples
> │   ├── CMakeLists.txt
> │   ├── lib1
> │   │   ├── CMakeLists.txt
> │   │   ├── example1.cpp
> │   │   └── example2.cpp
> │   └── lib2
> │       ├── CMakeLists.txt
> │       └── example1.cpp
> └── libs
>     ├── CMakeLists.txt
>     ├── lib1
>     └── lib2
>
> I would like to install the corresponding targets like this:
>
> .
> ├── bin
> │   └── examples
> │       ├── lib1
> │       │   ├── example1.exe
> │       │   └── example2.exe
> │       └── lib2
> │           └── example1.exe
> └── lib
>     ├── lib1.lib
>     └── lib2.lib
>
> At the moment I'm just defining a custom variable (say,
> INSTALL_PREFIX) in the highest-level CMakeLists.txt, and basically in
> each of the underlying CMakeLists.txt files append something to the
> variable. For example, in libs/CMakeLists.txt I use:
>
> set(INSTALL_PREFIX "${INSTALL_PREFIX}/lib")
>
> and in examples/CMakeLists.txt:
>
> set(INSTALL_PREFIX "${INSTALL_PREFIX}/bin")
>
> and in examples/lib1/CMakeLists.txt:
>
> set(INSTALL_PREFIX "${INSTALL_PREFIX}/lib1")
>
> I'm wondering if it's idiomatic, because at the moment I'm facing a
> few issues using this approach. For example, if I build & install only
> examples/lib1/example1.cpp, it gets installed to "lib1/" instead of
> "bin/examples/lib1".
>
> Could you please share your best practices on installing project
> components or give me an advice on how to fix the issue(s) I'm facing?
>
> Thank you,
> Egor Tensin.
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140621/1bc7e45b/attachment.html>


More information about the CMake mailing list