[CMake] Packaging a directory with CPack RPM

Ashish Sadanandan ashish.sadanandan at gmail.com
Wed Sep 11 20:26:27 EDT 2019


Hello,
I'm using CPack to create RPMs for an application. I have this working but
the CPack step is quite slow. While investigating this, I noticed that all
files in a directory I'm packaging, which contains a large number of small
files, is being listed in the spec file.

For instance, say I have

    set(CPACK_PACKAGING_INSTALL_PREFIX /opt/myapp)
    install(DIRECTORY ${CMAKE_BINARY_DIR}/myapp/foo
            DESTINATION foo
            COMPONENT myapp
    )

In the %files section I see

    %files
    %dir /opt/myapp/foo
    " /opt/myapp/foo/file1"
    " /opt/myapp/foo/file2"
    ...
    " /opt/myapp/foo/file60000"

If I were writing the spec file by hand, this entire section could be
replaced by a single line

    %files
    /opt/myapp/foo

RPM will package all files within the directory if you specify the
directory under %files (
http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html - the
"The %dir Directive" section)

Is there an option to list just the directory instead of recursively
listing all contained files within the directory?

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.

Best regards,
Ashish.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190911/0465033e/attachment.html>


More information about the CMake mailing list