Specifying individual install locations at CPack time

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Specifying individual install locations at CPack time

Sean Anderson

I'm creating a small library (https://github.com/Forty-Bot/appdir) using
CMake, and I would like to package it with CPack. I build a shared
library, and some html documentation. In addition to that, I need to
ship the headers, the README, and the license. If I were to make an
archive by hand, it would look like


However, when running `make install`, these files go in different
locations (using GNUInstallDirs for the variables):


Of course, on Debian systems, `COPYING.LESSER` should be omitted, and a
`copyright` file should be written referencing the copy of the LGPL in
`/usr/share/common-licenses`, and this assumes some sort of posix-y
system. On windows, I don't think it makes sense to support an install
target because there is no standard location for dlls. On darwin, I have
no idea what the standard is, but it's likely not what works for linux.
Lastly, I'd like to generate reasonable output for DEB and RPM, as well
as one of the macos installers.

Clearly the default CPack behaviour will not work here. Currently, I use
a variable `CREATE_ARCHIVE` to switch between install layout behaviour,
but it seems like there should be some sort of way to do this without
reconfiguring; after all, the only difference is where everything gets
copied. I looked into using `CPACK_INSTALLED_DIRECTORIES`, but I want to
control individual files, and I'd end up having to simulate an install
step in order to get the correct directories. I also considered
`CPACK_INSTALL_SCRIPT`, but it looked like I'd just end up writing my
own `cmake_install.cmake`s. And of course, all of these solutions would
need to use `CPACK_PROJECT_CONFIG_FILE` to detect what sort of build we
were doing, which as far as I can tell corresponds to

This seems like a rather common use-case, and I'm surprised that I
couldn't find any obvious solution for it. Am I missing something here?
Installing everything twice and using components to select between
configurations could work, but it would mess up invocations of `make
install`. Additionally, my current solution doesn't address the
installation of `copyright` for Debian (Somehow we need to detect
whether we're on debian or whether we're build a deb).

The GNUInstallDirs script seems to only be valid for posix-y systems. Is
there some equivalent for discovering where to install things on (say)

I've been digging around for a few days, and there doesn't seem to be
any prior work in this area (not to mention the paucity of
documentation). Thanks in advance for any tips.



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:

signature.asc (631 bytes) Download Attachment