I am using CPack to create source archives:
cmake --build . --config Release --target package_source
This works fine on my local Ubuntu machine, but the resulting archives are empty when build on Travis CI. There are no error messages. I have checked the CPack logs when --debug
is enabled and do not see any differences except the files are not being copied to the temporary install space. The source and destination paths are correct, but the files are not being found.
Why are the archives empty when built on some machines but not others?
After being stuck with the same issue for 10+ hours I finally figured it out. Maybe it's the same for you. It's the most logical thing actually after excluding all other causes: The files are being ignored!
I was skipping the "build" directory within my source from package_source:
# exclude build directories like /build/, /build-* and /build_*
list(APPEND CPACK_SOURCE_IGNORE_FILES "/build[\\-_/]")
However the path on travis is /home/travis/build/AlexanderLanin/ccache
I'm no regex expert, but this should put you on the right path at least:
list(APPEND CPACK_SOURCE_IGNORE_FILES "^((?!/home/travis/).*|/home/travis/.+)/build[\\-_/]")
Explained @ https://regex101.com/r/DJfeDi/1
Slightly simpler assuming you are within CMakeLists.txt:
list(APPEND CPACK_SOURCE_IGNORE_FILES "^${CMAKE_SOURCE_DIR}/build[\\-_/]")
list(APPEND CPACK_SOURCE_IGNORE_FILES "^${CMAKE_BINARY_DIR}")