From 4fe3bccfe0889bc942601c77bba285226c0edb6d Mon Sep 17 00:00:00 2001 From: PengZheng Date: Mon, 11 Sep 2023 15:23:17 +0800 Subject: [PATCH] Rewrite RPATH when installing bundles. Previously RPATH rewrite for bundles does not work because `install(FILES)` deos not overwrite existing files. This changes fix it by removing the file to be overwritten. It all fix broken bundle installation using zip. --- cmake/cmake_celix/BundlePackaging.cmake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmake/cmake_celix/BundlePackaging.cmake b/cmake/cmake_celix/BundlePackaging.cmake index 336ad5387..f006c1c66 100644 --- a/cmake/cmake_celix/BundlePackaging.cmake +++ b/cmake/cmake_celix/BundlePackaging.cmake @@ -1015,17 +1015,16 @@ function(install_celix_bundle) endif () get_target_property(BUNDLE_CONTENT_DIR ${BUNDLE} "BUNDLE_CONTENT_DIR") - set(BUNDLE_INSTALL_DIR "${BUNDLE_CONTENT_DIR}_install") - # copy bundle content to prepare the bundle to be installed - install(CODE "file(COPY ${BUNDLE_CONTENT_DIR}/ DESTINATION ${BUNDLE_INSTALL_DIR})") # fix RPATH of shared objects in the bundle to be installed using CMake's internal RPATH rewrite get_target_property(LIB_TARGETS ${BUNDLE} "BUNDLE_LIB_TARGETS") get_target_property(BUNDLE_GEN_DIR ${BUNDLE} "BUNDLE_GEN_DIR") foreach (LIB_TARGET ${LIB_TARGETS}) install(TARGETS ${LIB_TARGET} LIBRARY DESTINATION ${BUNDLE_GEN_DIR} NAMELINK_SKIP COMPONENT ${BUNDLE}) + # remove the shared objects with BUILD_RPATH + install(CODE "file(REMOVE ${BUNDLE_CONTENT_DIR}/$)" COMPONENT ${BUNDLE}) # JAR does not support symbolic links, so we only install soname file - install(FILES ${BUNDLE_GEN_DIR}/$ DESTINATION ${BUNDLE_INSTALL_DIR} + install(FILES ${BUNDLE_GEN_DIR}/$ DESTINATION ${BUNDLE_CONTENT_DIR} RENAME $ COMPONENT ${BUNDLE}) endforeach () @@ -1037,17 +1036,19 @@ function(install_celix_bundle) if (JAR_COMMAND) install(CODE "execute_process( - COMMAND ${JAR_COMMAND} ${CELIX_JAR_COMMAND_ARGUMENTS} ${BUNDLE_FILE_INSTALL} ${BUNDLE_GEN_DIR}/MANIFEST.MF -C ${BUNDLE_INSTALL_DIR} . + COMMAND ${JAR_COMMAND} ${CELIX_JAR_COMMAND_ARGUMENTS} ${BUNDLE_FILE_INSTALL} ${BUNDLE_GEN_DIR}/MANIFEST.MF -C ${BUNDLE_CONTENT_DIR} . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )" + COMPONENT ${BUNDLE} ) elseif (ZIP_COMMAND) install(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE_GEN_DIR}/MANIFEST.MF META-INF/MANIFEST.MF - COMMAND ${ZIP_COMMAND} ${CELIX_ZIP_COMMAND_ARGUMENTS} ${BUNDLE_FILE_INSTALL} * - WORKING_DIRECTORY ${BUNDLE_INSTALL_DIR} + COMMAND ${ZIP_COMMAND} ${CELIX_ZIP_COMMAND_ARGUMENTS} ${BUNDLE_FILE_INSTALL} . -i * + WORKING_DIRECTORY ${BUNDLE_CONTENT_DIR} )" + COMPONENT ${BUNDLE} ) else () message(FATAL_ERROR "A jar or zip command is needed to jar/zip bundles")