Skip to content

Commit

Permalink
Simplify CMake for INSTALL_DESTINATION_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
ruffsl authored and msz-rai committed Jun 6, 2024
1 parent 6a56c3a commit 9fbb280
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ros2_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(REQ_STANDALONE_LIBS "")
set(REQ_THIRD_PARTY_STANDALONE_LIBS "")
set(REQ_STANDALONE_DLLS "")

set(INSTALL_DESTINATION_DIR "ros2_standalone")
set(INSTALL_DESTINATION_DIR "lib/ros2_standalone")

# Extend REQ_THIRD_PARTY_STANDALONE_LIBS with _library_name third party dependencies
macro(get_standalone_third_party_dependencies _library_name)
Expand All @@ -31,7 +31,7 @@ endmacro()
# Install all libraries listed in REQ_THIRD_PARTY_STANDALONE_LIBS
macro(install_standalone_third_party)
install(FILES ${REQ_THIRD_PARTY_STANDALONE_LIBS}
DESTINATION ${INSTALL_DESTINATION_DIR}/../lib/ros2_standalone
DESTINATION ${INSTALL_DESTINATION_DIR}
)
endmacro()

Expand Down Expand Up @@ -161,7 +161,7 @@ macro(install_standalone_dependencies)
endforeach()
list(REMOVE_DUPLICATES REQ_STANDALONE_DLLS)
install(FILES ${REQ_STANDALONE_DLLS}
DESTINATION ${INSTALL_DESTINATION_DIR}/../lib/ros2_standalone
DESTINATION ${INSTALL_DESTINATION_DIR}
)
elseif(UNIX)
set(_resolvedFiles "")
Expand All @@ -172,7 +172,7 @@ macro(install_standalone_dependencies)
endforeach()

install(FILES ${_resolvedFiles}
DESTINATION ${INSTALL_DESTINATION_DIR}/../lib/ros2_standalone
DESTINATION ${INSTALL_DESTINATION_DIR}
)

# Fix soversion files
Expand All @@ -188,19 +188,19 @@ macro(install_standalone_dependencies)
string(SUBSTRING "${_remainingPath}" 0 ${_lastDotPos} _tempPos)
get_filename_component(_libPathFilename "${_tempPos}" NAME)
get_filename_component(_resolvedFilename "${_resolvedFile}" NAME)
install(CODE "execute_process(COMMAND ln -s ${_resolvedFilename} ${_libPathFilename} WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION_DIR}/../lib/ros2_standalone ERROR_QUIET)")
install(CODE "execute_process(COMMAND ln -s ${_resolvedFilename} ${_libPathFilename} WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION_DIR} ERROR_QUIET)")
set(_remainingPath "${_tempPos}")
endwhile()
endif()
endforeach()

# rpath for each standalone lib must be updated so all the libs will see each other
install(CODE
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION_DIR}/../lib/ros2_standalone -name *.so -exec patchelf --set-rpath $ORIGIN:. {} \;)"
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION_DIR} -name *.so -exec patchelf --set-rpath $ORIGIN:. {} \;)"
)
# soversion files as well
install(CODE
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION_DIR}/../lib/ros2_standalone -name *.so.* -exec patchelf --set-rpath $ORIGIN:. {} \;)"
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/${INSTALL_DESTINATION_DIR} -name *.so.* -exec patchelf --set-rpath $ORIGIN:. {} \;)"
)
endif()
endmacro()
Expand Down

0 comments on commit 9fbb280

Please sign in to comment.