[CMake] CPack: Project and independent subproject

Eric Noulard eric.noulard at gmail.com
Mon Oct 22 14:59:35 EDT 2012


2012/10/22 Romain LEGUAY <romain.leguay at gmail.com>:
> Hello everyone,
>
> My c++ project contains a Library folder, an Applications folder and a Demos
> folder like this:
>
> Project/
>          |-> Library/
>                          |-> include/
>                          |-> src/
>          |-> Applications/
>                          |-> appliA/
>                                         |-> include/
>                                         |-> src/
>                          ...
>          |-> Demos/
>                          |-> demoA/
>                                         |-> include/
>                                         |-> src/
>                          ...
>
> The applications and demos use the Library (which is a static library).
>
> I can build all the application correctly in different level (directly
> inside demoA/ for example or in Project/).
> I create custom target to build my package: demoA-package,
> demoA-package_source ....
>
> My problem is when I want to create a package (tar.gz, dmg, nsis or
> others...), I can't figure how to put just the executable of demosA inside
> the package: I have all the executable and the library.

If you want to have control over what is installed the better to do that
is to create COMPONENT.

> This is a part of my CMakeLists.txt:
>
> install(TARGETS ${PROJECT_NAME}
>           DESTINATION "Demos"
>           COMPONENT ${PROJECT_NAME})

like this but I doubt that you can name a COMPONENT with the same
name as the name of your project.

then you must either define:
set(CPACK_INSTALL_CMAKE_PROJECTS
"${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};${PROJECT_NAME}:/")

see documentation
cpack --help-variable CPACK_INSTALL_CMAKE_PROJECTS

> set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
> set(CPACK_PACKAGE_VENDOR "Me")
> set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Example test framework: demos
> ${PROJECT_NAME}")
> set(CPACK_PACKAGE_VERSION_MAJOR "1")
> set(CPACK_PACKAGE_VERSION_MINOR "0")
[....]


> I searched some methods to put the wanted files inside a package but I only
> found how to ignore some files.
>
> Does anyone have those kind of problem?

By the does your Demo/ directory have a "project(...)" command in its
CMakeLists.txt?


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list