1

I'm having problems convincing cmake/cpack to generate a debian package that contains a single executable quine stored in a specific folder named /absolute/path.

According to https://cmake.org/cmake/help/v2.8.0/cmake.html#command:install I should be able to use an absolute path:

DESTINATION arguments specify the directory on disk to which a file will be installed. If a full path (with a leading slash or drive letter) is given it is used directly. If a relative path is given it is interpreted relative to the value of CMAKE_INSTALL_PREFIX.

Here is my C file quine.c:

char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";main(){printf(s,34,s,34);}

and my CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)

project(quine)

file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c)

add_executable(quine ${SOURCES})

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nobody")

install(
    TARGETS quine
    RUNTIME DESTINATION /absolute/path
)

include(CPack)

In an empty subdirectory called build I invoke the following:

$ cmake ..
$ make package

and the resulting package is only 512 bytes in length, and a:

$ dpkg -c quine-0.1.1-Linux.deb

confirms that the package is empty.

What am I doing wrong?

spierepf
  • 2,774
  • 2
  • 30
  • 52
  • 1
    Could you try with *relative* destination path? Absolute installation paths don't play well with packaging... – Tsyvarev Jun 27 '17 at 13:46
  • 1
    If I use a relative path, the executable is installed under `/usr/...` which is not what I want. What is the challenge with absolute paths and packaging? – spierepf Jun 27 '17 at 13:57
  • 3
    In short, when packaging all files are installed as usual, but with *DESTDIR* as root directory. Then, files from *DESTDIR* are archived into the package file. There are some topics in the net, you may try to google them. As for your case, probably setting *CPACK_SET_DESTDIR* variable should help, like in https://stackoverflow.com/questions/6712000/cmake-cpack-package-installation-path-nightmare. – Tsyvarev Jun 27 '17 at 14:10
  • 1
    I just added `set(CPACK_SET_DESTDIR true)` and `set(CPACK_INSTALL_PREFIX /)` to my `CMakeLists.txt` file, and changed `/specific/dir` to `specific/dir` and it worked. Thanks Tsyvarev! – spierepf Jun 27 '17 at 14:59

0 Answers0