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

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Fri Jun 27 01:12:02 EDT 2014


Hi Egor,

DESTINATION should be specified as relative path. I would also recommend to
use COMPONENTS.

Finally, to know how to organize your files in the install package, I would
suggest you look at the "Filesystem Hierarchy Standard". See
http://www.pathname.com/fhs/pub/fhs-2.3.html

For example, see [1] to have an idea of how we will organize the files
within 3DSlicer to be compliant with the FHS.

Hth
Jc

[1]
http://wiki.slicer.org/slicerWiki/index.php/Documentation/Labs/FHSCompliantDirectoryStructure


On Sat, Jun 21, 2014 at 2:55 PM, Egor Tensin <egor.tensin at gmail.com> wrote:

> So you suggest that I define "full" relative paths in each CMakeLists.txt?
> Like
>
> install(TARGETS foo DESTINATION "bin/examples/lib1")
>
> instead of
>
> install(TARGETS foo DESTINATION "${INSTALL_PREFIX}/lib1")
>
> That's an option to consider, of course...
>
> On Sat, Jun 21, 2014 at 10:52 PM, J Decker <d3ck0r at gmail.com> wrote:
> > 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
> >
> >
> --
>
> 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
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140627/92e1b6c9/attachment-0001.html>


More information about the CMake mailing list