Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add files to debian package with CPack?

I am using Cmake with Cpack to create debian package.

I would like to use Cpack to generate a package that will install that files to specific location. (ex. /usr/lib /usr/include/aaa)

each library and header files are specified in a install command, and I write CPack options and include CPack into root CMakeLists.txt

(sure root and middle CMakeList.txt have only set or add_subdirectory command)

project directory looks like follows.

root(CMakeLists.txt CPack) ┬AAA(CMakeLists.txt)─┬─AAA2(CMakeLists.txt install)-src-include
                           │                    └─AAA3(CMakeLists.txt install)-src-include
                           ├BBB(CMakeLists.txt)─┬─BBB2(CMakeLists.txt install)-src-include
...

install command seems to like:

ADD_LIBRARY(${AAA2} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${AAA2_SOURCE_DIR}/AAA.c)
INSTALL(TARGETS ${AAA2} DESTINATION /usr/lib)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${AAA_INCLUDE_DIR}/AAA2.h DESTINATION /usr/include/AAA)

I have tried make package with "make install" command with cmake

cpack made debian package but that does not have any file.

what did I do wrong? how can I add files to debian package with cpack?

like image 532
pius lee Avatar asked Mar 08 '11 12:03

pius lee


People also ask

What does CPack do?

CPack is a powerful, easy to use, cross-platform software packaging tool distributed with CMake. It uses the generators concept from CMake to abstract package generation on specific platforms. It can be used with or without CMake, but it may depend on some software being installed on the system.

What files are in a Debian package?

A Debian "package", or a Debian archive file, contains the executable files, libraries, and documentation associated with a particular suite of program or set of related programs. Normally, a Debian archive file has a filename that ends in . deb .

How do Debian packages work?

Debian packages are standard Unix ar archives that include two tar archives. One archive holds the control information and another contains the installable data. dpkg provides the basic functionality for installing and manipulating Debian packages.


1 Answers

You're using absolute paths for your install rule DESTINATION values: (i.e., "/usr/lib")

Use just "lib" instead. Which will be placed underneath CMAKE_INSTALL_PREFIX, since it is not an absolute path.

You can control the "/usr" part with CMAKE_INSTALL_PREFIX, or with some CPACK_ generator-specific variables, like CPACK_PACKAGING_PREFIX, as needed, later. (Hopefully, you won't even need to, as the default behavior should be largely sufficient based on which type of CPack package you're creating.)

You should avoid using absolute paths in CMake install rules unless the file must always be installed in that location on all platforms.

like image 155
DLRdave Avatar answered Sep 18 '22 19:09

DLRdave