[CMake] Packaging DEB at different directory with CPack

Damián Nohales damiannohales at gmail.com
Tue Jan 24 11:13:36 EST 2012


Many thanks Eric! your explanation really helps me!

El 24/01/12 04:21, Eric Noulard escribió:
> 2012/1/24 Damián Nohales <damiannohales at gmail.com>:
>> 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)
> 
> this is ok.
> 
>>
>> # Another file to install
>> install(FILES ${CMAKE_SOURCE_DIR}/data/myapp.desktop DESTINATION
>> "${CMAKE_INSTALL_PREFIX}/share/applications")
> 
> This is usually wrong as it is an absolute PATH destination
> why don't you simply specify
> install(FILES ${CMAKE_SOURCE_DIR}/data/myapp.desktop DESTINATION
>  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 ..
> 
> Specifying CMAKE_INSTALL_PREFIX has no effect on the following CPack call
> 
>> $ make package
>> --------
>>
>> I need to specify a prefix for the installation because I want to test
>> the application without installing on my whole system.
> 
> Then you should override CPACK_PACKAGING_INSTALL_PREFIX
> 
> $ cd build
> $ cpack -D CPACK_PACKAGING_INSTALL_PREFIX=$HOME/testinstall -G DEB
> 
> another possibility is to install you deb content at an alternate location
> using
> 
> dpkg --instdir=$HOME/testinstall -i your.deb
> 
> 
>> But the .deb content resulting of executing "make package" is not what I
>> expected:
>>
> 
> [...]
> 
>>
>> 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?
> 
> Always use relative DESTINATION install path unless you forcibly want
> an ABSOLUTE destination.
> 


More information about the CMake mailing list