[CMake] Packaging DEB at different directory with CPack

Damián Nohales damiannohales at gmail.com
Mon Jan 23 22:16:39 EST 2012


Hello,

I'm doing an application for Debian based systems and I need to package
a .deb file, my application has several files to install in addition to
the main executable.

So, my CMakeLists.txt file looks like:

--------
project("myapp" C)
cmake_minimum_required(VERSION 2.8)

# The executable
add_executable(myapp main.c)
install(TARGETS myapp RUNTIME DESTINATION bin)

# Another file to install
install(FILES ${CMAKE_SOURCE_DIR}/data/myapp.desktop DESTINATION
"${CMAKE_INSTALL_PREFIX}/share/applications")

SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Damián Nohales")

INCLUDE(CPack)
--------

I execute CMake and build the package in this way:

--------
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=install ..
$ make package
--------

I need to specify a prefix for the installation because I want to test
the application without installing on my whole system.

But the .deb content resulting of executing "make package" is not what I
expected:

--------
DEBIAN
home
  user
    projects
      myapp
        build
          install
            share
              applications
                myapp.desktop
usr
  bin
    myapp
--------

(Note that I'm developing my application on the following directory:
"/home/user/projects/myapp")

Well, I'm sure you are understanding the problem, I'm expecting that the
generated .deb package to has the files under the /usr directory having
too the myapp.desktop file under the following filename
"/usr/share/applications/myapp.desktop".


Any suggestion?
Thanks in advance!


More information about the CMake mailing list