MantisBT - CMake
View Issue Details
0012096CMakeCPackpublic2011-04-16 13:062011-09-05 11:37
Alexey Uratkin 
Eric NOULARD 
normalminoralways
closedfixed 
LinuxRPM based distros
CMake 2.8.4 
CMake 2.8.5CMake 2.8.5 
0012096: CPackRPM: Error while using component install mode
I am going to use CPack to build RPM.
I need to build more than one package.

The instruction is at:
http://www.itk.org/Wiki/CMake:Component_Install_With_CPack [^]

I've done all according to the instruction, but got no packages.

I've look into generated spec files by CPack and found that ALL files from ALL packages included to each package.

More detail investigation revealed that:
"Modules/CPackRPM.cmake" use CPACK_RPM_ABSOLUTE_INSTALL_FILES variable set by "Source/CPack/cmCPackGenerator.cxx"
I've traced "Source/CPack/cmCPackGenerator.cxx" and discovered that CPACK_RPM_ABSOLUTE_INSTALL_FILES filled with all files from all packages.

This gets me down and I've created a patch which solved this problem.

I think it should be included to the next release.
No tags attached.
patch cpack_rpm.patch (2,317) 2011-04-16 13:07
https://public.kitware.com/Bug/file/3822/cpack_rpm.patch
patch 0001-CPackRPM-Fix-12096-handle-absolute-install-path-with.patch (3,268) 2011-04-17 15:01
https://public.kitware.com/Bug/file/3823/0001-CPackRPM-Fix-12096-handle-absolute-install-path-with.patch
gz CPackTestAbsolutePath-0.2.0-Source.tar.gz (948) 2011-04-17 15:09
https://public.kitware.com/Bug/file/3824/CPackTestAbsolutePath-0.2.0-Source.tar.gz
Issue History
2011-04-16 13:06Alexey UratkinNew Issue
2011-04-16 13:07Alexey UratkinFile Added: cpack_rpm.patch
2011-04-16 17:04Eric NOULARDAssigned To => Eric NOULARD
2011-04-16 17:04Eric NOULARDStatusnew => assigned
2011-04-16 17:07Eric NOULARDNote Added: 0026196
2011-04-16 17:37Alexey UratkinNote Added: 0026197
2011-04-17 15:01Eric NOULARDFile Added: 0001-CPackRPM-Fix-12096-handle-absolute-install-path-with.patch
2011-04-17 15:09Eric NOULARDFile Added: CPackTestAbsolutePath-0.2.0-Source.tar.gz
2011-04-17 15:16Eric NOULARDNote Added: 0026206
2011-04-17 15:17Eric NOULARDTarget Version => CMake 2.8.5
2011-04-17 15:18Eric NOULARDNote Added: 0026207
2011-04-17 15:18Eric NOULARDStatusassigned => resolved
2011-04-17 15:18Eric NOULARDFixed in Version => CMake 2.8.5
2011-04-17 15:18Eric NOULARDResolutionopen => fixed
2011-09-05 11:37David ColeStatusresolved => closed
2011-09-05 11:37David ColeNote Added: 0027345

Notes
(0026196)
Eric NOULARD   
2011-04-16 17:07   
Thank you for the report and the patch.
I'll have a look soon.

Did you try with CPack 2.8.4 or current git master branch?

By the way could you give me some example of INSTALL(TARGETS ...)
you use in your CMakeLists.txt.
Normally CPACK_RPM_ABSOLUTE_INSTALL_FILES is triggered by absolute destination.
(0026197)
Alexey Uratkin   
2011-04-16 17:37   
I tried with CMake 2.8.4 official release.

I've got a difficult distributed make system. But for tests you could use simple example that covered topic issue:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

SET(TARGET app)
SET(SRCS
    main.cpp
    f.cpp
    )
SET(HDRS
    f.h
    )
SET(CONFS
    f.conf
    )

ADD_EXECUTABLE(${TARGET} ${SRCS})

INSTALL(
    PROGRAMS
    ${EXECUTABLE_OUTPUT_PATH}/${TARGET}
    DESTINATION
    /usr/bin
    COMPONENT app
    )

INSTALL(
    FILES
    ${HDRS}
    DESTINATION
    /usr/include
    COMPONENT hdrs
    )

INSTALL(
    FILES
    ${CONFS}
    DESTINATION
    /etc
    COMPONENT conf
    )


SET(CPACK_RPM_COMPONENT_INSTALL ON)
SET(CPACK_GENERATOR "RPM")
SET(CPACK_COMPONENTS_ALL app hdrs conf)

SET(CPACK_COMPONENT_APP_GROUP "Runtime")
SET(CPACK_COMPONENT_HDRS_GROUP "Development")
SET(CPACK_COMPONENT_CONF_GROUP "Runtime")

INCLUDE(CPack)

In result of "make package" I want to get 3 package. Default CPack behavior doesn't provide it.
(0026206)
Eric NOULARD   
2011-04-17 15:16   
Alexey,

I did some more work on your patch in order to merge it to current
CMake codebase. The corresponding patch and sample test project is
attached to the tracker.

There is the corresponding stage/CPackRPM-fix12096 branch which I just
merged to next.

It should do what you expect.
Note however that CPackRPM is doing his best to build relocatable package
so that you'd better not do thing like:

INSTALL(
    FILES
    ${HDRS}
    DESTINATION
    /usr/include
    COMPONENT hdrs
    )

but instead:
INSTALL(
    FILES
    ${HDRS}
    DESTINATION
    include
    COMPONENT hdrs
    )

and then chose CPACK_PACKAGING_INSTALL_PREFIX in order to setup your
custom packaging install prefix if the default provided by the
generator does not suits you need.

That's the reason for which
INSTALL(
    FILES
    ${CONFS}
    DESTINATION
    /etc
    COMPONENT conf
    )

is oK with the side effect that those files will be flagged as "%config"
as it should be. The "automatic" %config flag has been made for ease
of use. If you don't want that, please file another bug report and
we will see how we can handle that. Providing a patch proposal would even
be better.

Thank you for the report and the patch.
(0026207)
Eric NOULARD   
2011-04-17 15:18   
Fetching upstream next
Merge topic 'CPackRPM-fix12096' into next

d3fd945 CPackRPM Fix 0012096: handle absolute install path with component install
(0027345)
David Cole   
2011-09-05 11:37   
Closing resolved issues that have not been updated in more than 4 months.