[CMake] Packaging a directory with CPack RPM

Eric Noulard eric.noulard at gmail.com
Mon Sep 16 14:01:11 EDT 2019


Le lun. 16 sept. 2019 à 18:12, Ashish Sadanandan <
ashish.sadanandan at gmail.com> a écrit :

> On Thu, Sep 12, 2019 at 4:57 AM Eric Noulard <eric.noulard at gmail.com>
> wrote:
> >
> >
> >
> > Le jeu. 12 sept. 2019 à 02:27, Ashish Sadanandan <
> ashish.sadanandan at gmail.com> a écrit :
>
> >
> > Now may be you can tell CPack to ignore some of you installed
> files/directory by using: CPACK_RPM_USER_FILELIST
> >
> https://cmake.org/cmake/help/v3.15/cpack_gen/rpm.html#cpack_gen:CPack%20RPM%20Generator
> >
>
> Sorry, I should've mentioned in the original email that the files are
> required, so ignoring is not what I want.
>

My answer wasn't clear, using   CPACK_RPM_USER_FILELIST enables you to
specify the de %file and/or %dir
directive you want and it thus make CPackRPM avoid using its ownn generated
file list  (i.e. ignore it).

You can somehow override the builtin file and dir discovery of CPack.

As the doc says:
"Since the CPack RPM generator is generating the list of files (and
directories) the user specified files of the
CPACK_RPM_<COMPONENT>_USER_FILELIST list will be removed from the generated
list. If referring to directories do not add a trailing slash."

>> I'm not claiming this is the reason for CPack being slow, I came across
> this while investigating performance and if nothing else, this will result
> in a cleaner looking spec file.
> >
> >
> > For performance sake you can try CPACK_RPM_USER_BINARY_SPECFILE,
> CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
> > and handcraft your "user" spec file in order to see if it helps the
> packaging performance.
> > and/or you can set CPACK_RPM_PACKAGE_DEBUG to 1 in order to get more
> timed traces of CPackRPM execution.
> >
>
> Thanks, this looks promising but I'm having trouble getting CPack to
> use my custom spec file. This is what I've added to my CMakeLists.txt
> so far (using cmake 3.6.3)
>


Then be sure to read the corresponding documentation:
https://cmake.org/cmake/help/v3.6/module/CPackRPM.html



>     # We're already using component install
>     set(CPACK_RPM_COMPONENT_INSTALL ON)
>     set(CPACK_RPM_TESTS_FILE_NAME
>
> "${CPACK_PACKAGE_NAME}-tests-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}.rpm"
>     )
>     install(DIRECTORY ${CMAKE_BINARY_DIR}/tests
>             DESTINATION tests
>             COMPONENT tests
>     )
>     set(CPACK_RPM_TESTS_USER_BINARY_SPECFILE
>         "${CMAKE_CURRENT_SOURCE_DIR}/tests.spec"
>     )
>
> But CPack is still generating a spec file for the tests RPM instead of
> using my spec file. I've even tried using an absolute path to the spec
> file but still the same behavior. What am I doing wrong?
>

Difficult to say without seeing your CMakeLists.txt or verbose CPack output.

Did you set those variables before or after include(CPack) ?
Those vars should be set *before*  include(CPack) otherwise they won't be
taken into account.

Did you try running CPack in debug mode:

cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM

in order to have more verbose output?
-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190916/36b650cc/attachment.html>


More information about the CMake mailing list