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
.
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.