cpack -B PACKAGE_DIR implicitly converts RELATIVE-PATH into absolute-path by using CWD=/ (root-directory)
VERSION-INFO: cpack/cmake version 3.14.5 (RELATED-TO: Issue #18133 (closed))
CPACK_PACKAGE_DIRECTORY
value on cpack command-line is implicitly converted into an absolute-path.
Normally, a relative-path to absolute-path conversion uses PWD/
CWD instead of CWD="/" (root-directory).
# -- PRECONDITION: CMake project with CPack support
$ mkdir build.debug && cd build.debug && cmake -G Ninja ..
$ cpack -B OTHER_DIR --config CPackConfig.cmake
...
CMake Error at .../build.debug/foo/cmake_install.cmake:$LINE_NUMBER (file):
file cannot create directory:
/OTHER_DIR/_CPack_Packages/...
# -- SAME-FOR:
$ cpack -D CPACK_PACKAGE_DIRECTORY=OTHER_DIR --config CPackConfig.cmake
ANALYSIS:
The following file(INSTALL DESTINATION ...)
construct seems to implicitly convert the relative-path CMAKE_INSTALL_PREFIX="OTHER_DIR/_CPack_Packages/..."
into /OTHER_DIR/_CPack_Packages/...
:
# -- FILE: build.debug/foo/cmake_install.cmake
...
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES ...more)
...
HINT: Similar Context in CMake
The following CMake command runs without any problems in a similar context.
$ cmake -DCMAKE_INSTALL_PREFIX=OTHER_DIR .
$ cmake --build . --target install
...
-- Installing: /.../build.debug/OTHER_DIR/lib/...
-- Installing: ... (without any problems)
Edited by jenisys