CPack: deb and archive generator different behaviour
Hi! I have something like this:
set(PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/python)
install(CODE "set(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")"
COMPONENT my_component)
install(CODE "set(PYTHON_INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/python\")"
COMPONENT my_component)
install(CODE "set(PATCHELF \"${PATCHELF}\")" COMPONENT my_component)
function(install_python_linux PROJECT_NAME)
install(CODE "set(PROJECT_NAME \"${PROJECT_NAME}\")" COMPONENT my_component)
install(CODE [[
message( STATUS "Installing ${PROJECT_NAME}")
]] COMPONENT my_component)
install(CODE "set(PROJECT_FILE \"$<TARGET_FILE:${PROJECT_NAME}>\")"
COMPONENT my_component)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH
${PYTHON_INSTALL_DIR}/lib)
install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}/lib COMPONENT my_component
ARCHIVE DESTINATION ${PYTHON_INSTALL_DIR}/lib COMPONENT my_component
RUNTIME DESTINATION ${PYTHON_INSTALL_DIR}/bin COMPONENT my_component)
install(
CODE [[
file(GET_RUNTIME_DEPENDENCIES
POST_EXCLUDE_REGEXES
"^/lib/.+"
DIRECTORIES
RESOLVED_DEPENDENCIES_VAR RES
UNRESOLVED_DEPENDENCIES_VAR UNRES
CONFLICTING_DEPENDENCIES_PREFIX CONFLICTING_DEPENDENCIES
EXECUTABLES ${PROJECT_FILE}
)
message("\n\nFound dependencies :")
foreach(DEP ${RES})
message("${DEP}")
endforeach()
message("\n\nNot found dependencies :")
foreach(DEP ${UNRES})
message("${DEP}")
endforeach()
foreach(_file ${RES})
file(INSTALL
DESTINATION "${PYTHON_INSTALL_DIR}/lib"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endforeach()
file(GLOB DEP_LIBS
"${PYTHON_INSTALL_DIR}/lib/*lib*.so*"
)
foreach(_file ${DEP_LIBS})
execute_process(
COMMAND ${PATCHELF} --set-rpath "$ORIGIN" ${_file})
endforeach()
message(STATUS "Deployed libs: ${DEP_LIBS}")
]]
COMPONENT my_component)
endfunction()
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
SET(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/_packages")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/my_component")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEB_COMPONENT_INSTALL YES)
set(CPACK_COMPONENTS_ALL my_component)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
include(CPack)
This script installs target binary, copies dependencies and then packages it. I call cmake with -DCMAKE_INSTALL_PREFIX:PATH=/opt/my_component
It works ok with DEB generator. Target was installed, dependencies were copied, patched and packaged. Pretty well.
Then I try to change generator to archive, for example TGZ. What I see? I see empty archive. What's gone wrong? I tried to investigate. I found that cpack installed everything to /opt/my_component
but packed another folder build_dir/_CPack_Packages/Linux/TGZ/project_name/opt/my_component
.
Cpack with DEG generator internally install everything into build_dir/_CPack_Packages/Linux/DEB/project_name/opt/my_component
(build_dir + temp folder + CPACK_PACKAGING_INSTALL_PREFIX (?) ) and pack the same folder. While cpack with TGZ generator internally install everything into /opt/my_component
and pack build_dir/_CPack_Packages/Linux/TGZ/project_name/opt/my_component
so my output archive'll empty. Who is right here and how it can be fixed? Thanx