CPACK_STRIP_FILES has no effect with relative CPACK_PACKAGING_INSTALL_PREFIX path
I use CPack to create a .deb package and noticed that stripping of binaries did not work in one project, but it did in another. After a bit of testing I was able to reduce the change in behaviour to one setting: CPACK_PACKAGING_INSTALL_PREFIX being set to a relative path (or install(... DESTINATION relative_path), without the prefix).
Example CMakeLists.txt file:
project(Foo VERSION 1.0.0)
add_executable(foo main.cpp)
set(CPACK_GENERATOR "DEB")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_PACKAGE_NAME "foo")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "foo")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "None")
# relative path: this breaks the stripping step
set(CPACK_PACKAGING_INSTALL_PREFIX "opt/foo")
# absolute path: with this the stripping works fine
#set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/foo")
include(CPack)
install(TARGETS foo)
with main.cpp containing any valid C++ program.
Now setting CPACK_PACKAGING_INSTALL_PREFIX to a relative path was an oversight and not intentional. However since the rest of the build worked -- the resulting .deb package installed all files to the correct locations -- I did not notice this and was confused, why the stripping of the binary did not work.