Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9030135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:24:51+00:00 2026-06-16T07:24:51+00:00

I use CMake to manage a project with the following layout: ProjectA/ include doc

  • 0

I use CMake to manage a project with the following layout:

ProjectA/
  include
  doc
  test
ProjectB
  include
  doc
  test

I would like to use CPack to package up a tar.gz source archive with the following layout:

include/
ProjectA/
  doc
  test
ProjectB/
  doc
  test

where the new top-level include contains all include files.

I tried achieving this by running a CMake script through CPACK_INSTALL_SCRIPT, but this script runs before the files are created. Where can I hook into CPack to get that effect?

It also seems that install has no influence on what make
package_source
does, but it has an effect on make
package
. Unfortunately make package will also build and package
libraries, which is something I don’t want to happen. I want a pure
source distribution ala make dist.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:24:52+00:00Added an answer on June 16, 2026 at 7:24 am

    You can call install(DIRECTORY include DESTINATION include) on headers from both ProjectA and ProjectB and install them into the same dir. This would cause CPack to place them together in the generated package.

    Update

    Okay, i’ve managed to do this with CPACK_INSTALL_SCRIPT variable.

    I’ve created following script:

    set(CMAKE_SOURCE_DIR @CMAKE_SOURCE_DIR@)
    
    execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/A/ ${CMAKE_SOURCE_DIR})
    execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/B/ ${CMAKE_SOURCE_DIR})
    execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/A)
    execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/B)
    

    In the CMakeLists.txt i’ve populated it with actual value of CMAKE_SOURCE_DIR:

    configure_file(CPackScript.cmake CPackScript.cmake @ONLY)
    

    Finally, i’ve added set(CPACK_INSTALL_SCRIPT ${CMAKE_BINARY_DIR}/CPackScript.cmake) and voila! Generated packages now have include dir with headers from both A/ and B/, while A/ and B/ dirs don’t exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use CMake with GNU Make and would like to see all commands exactly
I would like to use Qt creator and Cmake together (please, don't ask me
I want to use Boost test in my project. I use cmake in my
I use CMake to generate unix makefiles. After that I compile project using make
I'm trying to use CMake to build my C++ project and I have a
I have two projects, both of which use CMake. Now I want to include
I'm trying to import my Cmake project in QtCreator, which I'd want to use
I use cmake to generate qtcreator's project files, For the run part I can
I use CMake to create my projects. In the project I use mainly Qt
I'm using cmake with C++ project. I want to use precompiled headers in GCC.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.