[CMake] CPACK "deb" package Problem

Eric Noulard eric.noulard at gmail.com
Thu Oct 14 06:15:55 EDT 2010


Hi Chang,

2010/10/14 Chang Yu Huang <yillkid at gmail.com>:
> Here is my CMakeLists.txt file, and when I use the "make" and "make install"
> command, I can successfully install all files into the file system.

You think you do but in fact you don't :-], but keep reading.

> However, when I use the "make package" command, there is no any file be
> packaged in "deb package", I would like to ask why, thanks a lot.


There is some "problem/weirdness" with your CMakeLists.txt

1)  EXECUTABLE_OUTPUT_PATH is not meant to "install" things
>
> SET(EXECUTABLE_OUTPUT_PATH /usr/bin)
[...]
> ADD_EXECUTABLE (my_project ${MY_PROJECT_SRCS})
[...]

So here you are putting your executable in "/usr/bin"
AT BUILD TIME and you have no INSTALL rule
for your "my_project" executable.

This is not usually the way it goes.
First of all note that with CMake you have several "times":

0) CMake time = when CMake is running
1) Build time    = when the build tool is running (in your case "make")
2) Install time   = when install target is launched
3) CPack time  = when CPack is running
4) Package Install Time = when the package you build with CPack is installed

0) is essentially the configuration of your sources

1) is when all sort of things (including libraries and executable) are built
    usually within the BUILD TREE

2) All INSTALL rules specified in CMakeLists.txt are processed.

3) When running CPack, cpack runs the step 2) using specific arguments
    in order to install everything in a local sub-directory of the build tree
    before packaging.

> INSTALL(FILES my_project.glade DESTINATION /usr/share/my_project)
> INSTALL(FILES my_project.png DESTINATION /usr/share/my_project)
> INSTALL(FILES my_project.desktop DESTINATION /usr/share/applications)

You use ABSOLUTE destination, this is known to be broken for many
CPack generator (including DEB, RPM and TGZ).
This should be fixed (for RPM and DEB) in the forthcoming 2.8.3 cmake release.

However, you should probably use relative destination:

INSTALL(FILES my_project.glade DESTINATION share/my_project)
INSTALL(FILES my_project.png DESTINATION share/my_project)
INSTALL(FILES my_project.desktop DESTINATION share/applications)

[...]

> TARGET_LINK_LIBRARIES(deva ${GTK2_LINK_FLAGS})

As already said you lack an install rule for your target;

INSTALL(TARGET deva bin)

In summary;

1) You should really not be using /usr/bin as EXECUTABLE_OUTPUT_PATH
    EXECUTABLE_OUTPUT_PATH is is build time var not meant to replace
    intall time procedure.

2) You'd better use relative install path
    If you want to stick with absolute install
    you may have to set(CPACK_SET_DESTDIR ON)

3) You should have 1 install rule for each target/file/directory you
want to install
    The CPack package will only contains things for which there exists
an install rule.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list