Is it possible to add some files only to the ARCHIVE generators with CMake/CPack? Apparently components do that, but I can't figure how to say "only add component X to generator Y". I did something like this:
INSTALL(FILES somefile DESTINATION "." COMPONENT static)
But how to add the static
component only to ARCHIVEs and not to other generators like DEB and RPM?
Eventually found this with some help from the CMake list. In your CMakeLists.txt do something like this:
install(PROGRAMS basic.sh DESTINATION "." COMPONENT basic)
install(PROGRAMS optional.sh DESTINATION "." COMPONENT optional)
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CPackOptions.cmake")
CPackOptions.cmake should handle the ifs. Notice that you must turn on CPACK_*_COMPONENT_INSTALL for any other generator you might want:
SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
SET(CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
IF ("${CPACK_GENERATOR}" MATCHES "TGZ")
SET(CPACK_COMPONENTS_ALL basic optional)
ELSEIF ("${CPACK_GENERATOR}" MATCHES "TBZ2")
SET(CPACK_COMPONENTS_ALL basic optional)
ELSE()
SET(CPACK_COMPONENTS_ALL basic)
ENDIF()