MantisBT - CMake
View Issue Details
0013599CMakeCMakepublic2012-10-22 15:272012-10-23 13:02
sutasu 
Eric NOULARD 
normalminoralways
closedwon't fix 
x86win, linuxany
CMake 2.8.9 
 
0013599: package per component generation doesn't work
According to documentation the default behavior for following code is producing 2 packages files (one per component) but it makes only one.
cmake_minimum_required(VERSION 2.8)

file(WRITE file.txt.in "hi")
configure_file(file.txt.in ${CMAKE_CURRENT_BINARY_DIR}/file-runtime.txt)
configure_file(file.txt.in ${CMAKE_CURRENT_BINARY_DIR}/file-devel.txt)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/file-runtime.txt
         DESTINATION bin COMPONENT Runtime)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/file-devel.txt
         DESTINATION lib COMPONENT Development)

SET(CPACK_COMPONENTS_ALL Runtime Development)
include(CPack)
> cmake ..
-- Building for: Visual Studio 8 2005
-- Check for working C compiler using: Visual Studio 8 2005
-- Check for working C compiler using: Visual Studio 8 2005 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 8 2005
-- Check for working CXX compiler using: Visual Studio 8 2005 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Projects/cmake_multiple_tst/build

> cpack -G ZIP
CPack: Create package using ZIP
CPack: Install projects
CPack: - Install project: Project
CPack: Create package
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32.zip generated.
No tags attached.
Issue History
2012-10-22 15:27sutasuNew Issue
2012-10-22 15:45Eric NOULARDPriorityhigh => normal
2012-10-22 15:45Eric NOULARDSeveritymajor => minor
2012-10-22 15:45Eric NOULARDAssigned To => Eric NOULARD
2012-10-22 15:45Eric NOULARDStatusnew => assigned
2012-10-22 15:48Eric NOULARDNote Added: 0031289
2012-10-22 15:49Eric NOULARDNote Added: 0031290
2012-10-22 15:49Eric NOULARDStatusassigned => feedback
2012-10-23 11:06sutasuNote Added: 0031293
2012-10-23 11:06sutasuStatusfeedback => assigned
2012-10-23 11:30Eric NOULARDNote Added: 0031294
2012-10-23 12:03sutasuNote Added: 0031295
2012-10-23 13:02Eric NOULARDNote Added: 0031296
2012-10-23 13:02Eric NOULARDStatusassigned => closed
2012-10-23 13:02Eric NOULARDResolutionopen => won't fix

Notes
(0031289)
Eric NOULARD   
2012-10-22 15:48   
Hi,

Where do you mean by "According to documentation".
For some generator component packaging is not the default behavior,
see here:
http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack#CPack_Generator_specific_behavior [^]

The default behavior of the ZIP generator (which is a sub-class of Archive generator) is to not generate several packages for backward compatibility reason.

However running:
cpack -D CPACK_ARCHIVE_COMPONENT_INSTALL=1 -G ZIP

should produce the 2 packages.
You can
set(CPACK_ARCHIVE_COMPONENT_INSTALL 1)
inside your CMakeLists.txt as well.
(0031290)
Eric NOULARD   
2012-10-22 15:49   
I'll wait for your feedback before closing this.
(0031293)
sutasu   
2012-10-23 11:06   
Documentation mentions that for archive generators cpack possibly generates multiple package files which is quite vague.
Then is says "For CPack generators which generates several packages the default behavior is to generate one package per COMPONENT GROUP".

The code above doesn't use component groups though I tried using them too.

And there is no any traces in this documentation of CPACK_ARCHIVE_COMPONENT_INSTALL variable.

It's a pity that it's so hard for even not a newbie of cmake to figure out how to do such a simple thing... In general please provide more examples in documentation, give more details on every aspect. I find that it often takes too much experimentation using cmake and cpack to achieve a goal.

Anyway thank you!

Back to the problem... On windows the suggestion you gave worked perfectly:

C:\Projects\cmake_multiple_tst\build>cpack -D CPACK_ARCHIVE_COMPONENT_INSTALL=1
-G ZIP
CPack: Create package using ZIP
CPack: Install projects
CPack: - Install project: Project
CPack: - Install component: Runtime
CPack: - Install component: Development
CPack: Create package
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32-Devel
opment.zip generated.
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32-Runti
me.zip generated.

C:\Projects\cmake_multiple_tst\build>cpack -D CPACK_ARCHIVE_COMPONENT_INSTALL=1
-G TGZ
CPack: Create package using TGZ
CPack: Install projects
CPack: - Install project: Project
CPack: - Install component: Runtime
CPack: - Install component: Development
CPack: Create package
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32-Devel
opment.tar.gz generated.
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32-Runti
me.tar.gz generated.

C:\Projects\cmake_multiple_tst\build>cpack -D CPACK_ARCHIVE_COMPONENT_INSTALL=1
-G TBZ2
CPack: Create package using TBZ2
CPack: Install projects
CPack: - Install project: Project
CPack: - Install component: Runtime
CPack: - Install component: Development
CPack: Create package
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32-Devel
opment.tar.bz2 generated.
CPack: - package: C:/Projects/cmake_multiple_tst/build/Project-0.1.1-win32-Runti
me.tar.bz2 generated.


But on linux it produced three packages with the same content of both components:

> cpack -DCPACK_ARCHIVE_COMPONENT_INSTALL=1 -G TGZ
CPack: Create package using STGZ
CPack: Install projects
CPack: - Run preinstall target for: Project
CPack: - Install project: Project
CPack: Create package
CPack: - package: /home/stanislav/Projects/cmake_test/build/Project-0.1.1-Linux.sh generated.
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: Project
CPack: - Install project: Project
CPack: Create package
CPack: - package: /home/stanislav/Projects/cmake_test/build/Project-0.1.1-Linux.tar.gz generated.
CPack: Create package using TZ
CPack: Install projects
CPack: - Run preinstall target for: Project
CPack: - Install project: Project
CPack: Create package
CPack: - package: /home/stanislav/Projects/cmake_test/build/Project-0.1.1-Linux.tar.Z generated.

Thank you!
(0031294)
Eric NOULARD   
2012-10-23 11:30   
I know CPack documentation is sparse but I can ensure
you it is improving....and
I would kindly accept patch for the documentation as well.

Concerninng the wrong linux behavior, you have a small command
line typo:
cpack -DCPACK_ARCHIVE_COMPONENT_INSTALL=1 -G TGZ

should be:
cpack -D CPACK_ARCHIVE_COMPONENT_INSTALL=1 -G TGZ

there must be a " " [space] between -D and var value.
In any case if you get tree kind of packages and asked
for only one (-G TGZ) then there must be some command line issue.

And...yes the command line parsing should be improved,.
(0031295)
sutasu   
2012-10-23 12:03   
I see...))) Usually space doesn't make any difference in command line parsers.
Thank you for being cooperative and good luck!
Let's consider this discussion closed.
(0031296)
Eric NOULARD   
2012-10-23 13:02   
Nothing to fix or may be the doc.