Hey, I am trying to explicitly introduce a cpack step to package a zip-archive with all my sources. I also want to include the root CMakeLists.txt file because the entire archive is supposed to be consumed via FetchContent from other projects.
Previously i had a custom build target that handled this but I wanted to make it explicit that this is a step a developer may want to perform. For reference, this is how I did it before:
set(PACKAGE_ZIP ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip)
set(package_files MyLibrary/ CMakeLists.txt)
add_custom_target(${PROJECT_NAME}_package ALL
COMMAND ${CMAKE_COMMAND} -E rm -f ${PACKAGE_ZIP}
COMMAND ${CMAKE_COMMAND} -E tar c ${PACKAGE_ZIP} --format=zip -- ${package_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Removing old zip and creating new ${PACKAGE_ZIP}"
)
And this is how i tried to replace it:
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-src-${PROJECT_VERSION}")
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_OVERWRITE 1)
set(CPACK_SOURCE_INSTALLED_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/MyLibrary;MyLibrary"
)
set(CPACK_SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
include(CPack)
However, the root CMakeLists.txt is NOT included in the archive when i invoke it via this preset:
"packagePresets": [
{
"name": "default-package",
"configurePreset": "default",
"configFile": "CPackSourceConfig.cmake",
"generators": [ "ZIP" ]
}
],
How can I make the cpack call include the root CMakeLists.txt file in the zip-archive?