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 does, but it has an effect on
package_sourcemake. Unfortunately
packagemake 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 bothProjectAandProjectBand 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_SCRIPTvariable.I’ve created following script:
In the
CMakeLists.txti’ve populated it with actual value ofCMAKE_SOURCE_DIR:Finally, i’ve added
set(CPACK_INSTALL_SCRIPT ${CMAKE_BINARY_DIR}/CPackScript.cmake)and voila! Generated packages now haveincludedir with headers from bothA/andB/, whileA/andB/dirs don’t exist.