[CMake] The output of cpack is an empty file

Eric Noulard eric.noulard at gmail.com
Tue Sep 27 05:38:50 EDT 2011


Second message for the list

2011/9/27 pellegrini <pellegrini at ill.fr>:
> Hello everybody,
>
> I would like to use cpack in order to gather a set of executables (built
> statically) into a single archive that could be extracted everywhere the
> user wants.
>
> My project architecture is the following:
>
> collections\
>   CMakeLists.txt
>   prog1\
>      CMakeLists.txt + source files
>   prog2\
>      CMakeLists.txt + source files
>   prog3\
>      CMakeLists.txt + source files
>
> where each CMakeLists.txt files are stand-alone CMake projects (historically
> each program still has to be "buildable" alone) that produces prog1, prog2,
> prog3 executables.
>
> My main CMakeLists.txt looks like:
>
> ##########################################
> project(collections)
>
> add_subdirectory(prog1)
> add_subdirectory(prog2)
> add_subdirectory(prog3)
>
> set(CPACK_GENERATOR "ZIP")
> set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
> set(CPACK_PACKAGE_NAME "collection of progs)
> set(CPACK_PACKAGE_FILE_NAME "collections")
> set(CPACK_PACKAGE_VERSION_MAJOR "1")
> set(CPACK_PACKAGE_VERSION_MINOR "0")
> set(CPACK_PACKAGE_EXECUTABLES "collections")
> include(CPack)
> ##########################################
>
> when running cmake and then nmake package, the built is done, cpack is
> launched but the resulting archive is empty. No README inside

Zip (or any other archive generator, TGZ, TBZ2 etc...) does not use
CPACK_PACKAGE_DESCRIPTION_FILE :-(

You could use something like

INSTALL(FILE ${CMAKE_CURRENT_SOURCE_DIR}/README
              DESTINATION .)

to make archive generator include the file a the root of the
tree  hierarchy.

>  and more
> disturbing no
> prog1, prog2, prog3 executables. I may have miss something when reading the
> examples but I still have not found what. Would you have any idea ?

Is there install rules for each executable in your sub-project?
CPack only package targets/files etc... which appear in some
install(...) statement.

Are those subproject already including CPack ?
If this is the case you should comment that out.
Currently CPack may only be included once.
see e.g: http://public.kitware.com/Bug/view.php?id=10751


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


More information about the CMake mailing list