Hello,
I’m trying to use CPACK_PRE_BUILD_SCRIPTS to filter out certain files from the staging directory before CPack begins packaging. The use case for this is that we call on an external package manager executable to copy binaries into our install directory. That’s done through install(CODE …).
Unfortunately, some of the binaries being copied into the install directory aren’t required or desired in the final package, such as test executables and other CI tools. I was hoping to use CPACK_PRE_BUILD_SCRIPTS to remove any unwanted files from the staging directory before CPack does it’s thing.
This is where my issue lies, the script I have that’s run for CPACK_PRE_BUILD_SCRIPTS doesn’t have it’s CMAKE_ variables initialised to what I’d expect. If I have the following pre-build script:
message(“CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}”)
message(“CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}”)
message(“CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}”)
message(“CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}”)
message(“CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}”)
message(“CPACK_PACKAGE_FILES = ${CPACK_PACKAGE_FILES}”)
Then I get the following output during CPack:
CMAKE_INSTALL_PREFIX = C:/Program Files (x86)
CMAKE_SOURCE_DIR =
CMAKE_CURRENT_SOURCE_DIR =
CMAKE_BINARY_DIR =
CMAKE_CURRENT_BINARY_DIR =
CPACK_PACKAGE_FILES =
At the very least I was hoping that CMAKE_INSTALL_PREFIX would be initialised to the staging directory. Currently it’s not even set to what’s in my CMakeCache.
Is this expected behaviour for CPACK_PRE_BUILD_SCRIPTS?
Currently using CMake 3.19.3
Windows 10
Tried Visual Studio 2019 and Ninja CMake generators
Tried ZIP and NSIS CPack generators