From 791e7d9947f33fe9427c7ef881934a9ac894f977 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Wed, 1 Dec 2021 20:43:46 -0500 Subject: [PATCH] Fix setup.sh and install dirs with absolute paths (#3138) The build script made some assumptions that CMAKE_INSTALL_*DIR was relative, which is not necessarily true. This commit fixes causes the plugins to be installed to the correct location and fixes the paths in setup.sh for both the relative and absolute cases. --- CMakeLists.txt | 25 +++++++++++++------------ cmake/setup.sh.in | 10 +++++----- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c00e609f8..af8e52c26f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,24 +168,26 @@ message (STATUS "----------------------------------------\n") # 1. In CMake code to pass preprocessor definitions to certain source files # (especially in common/CMakeLists.txt). # 2. In the generation of cmake/setup.sh from cmake/setup.sh.in +include (${gazebo_cmake_dir}/JoinPaths.cmake) set(GAZEBO_DEFAULT_MASTER_HOST localhost) set(GAZEBO_DEFAULT_MASTER_PORT 11345) -set(GAZEBO_RELATIVE_PLUGIN_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) -set(GAZEBO_RELATIVE_PLUGIN_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) -set(GAZEBO_PLUGIN_LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${GAZEBO_RELATIVE_PLUGIN_LIB_INSTALL_DIR}) -set(GAZEBO_PLUGIN_BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${GAZEBO_RELATIVE_PLUGIN_BIN_INSTALL_DIR}) +join_paths(GAZEBO_SETUP_SH_PLUGIN_LIB_INSTALL_DIR "\${installPrefix}" ${CMAKE_INSTALL_LIBDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) +join_paths(GAZEBO_SETUP_SH_PLUGIN_BIN_INSTALL_DIR "\${installPrefix}" ${CMAKE_INSTALL_BINDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) +set(GAZEBO_PLUGIN_LIB_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) +set(GAZEBO_PLUGIN_BIN_INSTALL_DIR ${CMAKE_INSTALL_FULL_BINDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) if(WIN32) - set(GAZEBO_RELATIVE_PLUGIN_PATH ${GAZEBO_RELATIVE_PLUGIN_BIN_INSTALL_DIR}) + set(GAZEBO_SETUP_SH_PLUGIN_PATH ${GAZEBO_SETUP_SH_PLUGIN_BIN_INSTALL_DIR}) + set(GAZEBO_PLUGIN_PATH ${GAZEBO_PLUGIN_BIN_INSTALL_DIR}) else() - set(GAZEBO_RELATIVE_PLUGIN_PATH ${GAZEBO_RELATIVE_PLUGIN_LIB_INSTALL_DIR}) + set(GAZEBO_SETUP_SH_PLUGIN_PATH ${GAZEBO_SETUP_SH_PLUGIN_LIB_INSTALL_DIR}) + set(GAZEBO_PLUGIN_PATH ${GAZEBO_PLUGIN_LIB_INSTALL_DIR}) endif() -set(GAZEBO_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${GAZEBO_RELATIVE_PLUGIN_PATH}) FILE(TO_NATIVE_PATH "${GAZEBO_PLUGIN_PATH}" GAZEBO_PLUGIN_PATH) -set(GAZEBO_RELATIVE_MODEL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/models) -set(GAZEBO_MODEL_PATH ${CMAKE_INSTALL_PREFIX}/${GAZEBO_RELATIVE_MODEL_PATH}) +join_paths(GAZEBO_SETUP_SH_MODEL_PATH "\${installPrefix}" ${CMAKE_INSTALL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/models) +set(GAZEBO_MODEL_PATH ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/models) FILE(TO_NATIVE_PATH "${GAZEBO_MODEL_PATH}" GAZEBO_MODEL_PATH) -set(GAZEBO_RELATIVE_RESOURCE_PATH ${CMAKE_INSTALL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}) -set(GAZEBO_RESOURCE_PATH ${CMAKE_INSTALL_PREFIX}/${GAZEBO_RELATIVE_RESOURCE_PATH}) +join_paths(GAZEBO_SETUP_SH_RESOURCE_PATH "\${installPrefix}" ${CMAKE_INSTALL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}) +set(GAZEBO_RESOURCE_PATH ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}) FILE(TO_NATIVE_PATH "${GAZEBO_RESOURCE_PATH}" GAZEBO_RESOURCE_PATH) set(GAZEBO_MODEL_DATABASE_URI http://models.gazebosim.org) set(OGRE_RESOURCE_PATH ${OGRE_PLUGINDIR}) @@ -428,7 +430,6 @@ else (build_errors) set (Boost_PKGCONFIG_LIBS "${Boost_PKGCONFIG_LIBS} ${bname}") endforeach(b) - include(${gazebo_cmake_dir}/JoinPaths.cmake) join_paths(pkgconfig_libdir "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") join_paths(pkgconfig_includedir "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/cmake/setup.sh.in b/cmake/setup.sh.in index 34f3b1e368..3d00d8be65 100644 --- a/cmake/setup.sh.in +++ b/cmake/setup.sh.in @@ -5,17 +5,17 @@ if [ ! -d "${installPrefix}" ]; then echo "The install prefix ${installPrefix} does not exist." unset installPrefix return 1 -elif [ ! -f "${installPrefix}/@GAZEBO_RELATIVE_RESOURCE_PATH@/setup.sh" ]; then - echo "The install prefix ${installPrefix}/@GAZEBO_RELATIVE_RESOURCE_PATH@ does not contain setup.sh." +elif [ ! -f "@GAZEBO_SETUP_SH_RESOURCE_PATH@/setup.sh" ]; then + echo "The install prefix @GAZEBO_SETUP_SH_RESOURCE_PATH@ does not contain setup.sh." unset installPrefix return 1 fi export GAZEBO_MASTER_URI=${GAZEBO_MASTER_URI:-http://@GAZEBO_DEFAULT_MASTER_HOST@:@GAZEBO_DEFAULT_MASTER_PORT@} export GAZEBO_MODEL_DATABASE_URI=@GAZEBO_MODEL_DATABASE_URI@ -export GAZEBO_RESOURCE_PATH=${installPrefix}/@GAZEBO_RELATIVE_RESOURCE_PATH@:${GAZEBO_RESOURCE_PATH} -export GAZEBO_PLUGIN_PATH=${installPrefix}/@GAZEBO_RELATIVE_PLUGIN_PATH@:${GAZEBO_PLUGIN_PATH} -export GAZEBO_MODEL_PATH=${installPrefix}/@GAZEBO_RELATIVE_MODEL_PATH@:${GAZEBO_MODEL_PATH} +export GAZEBO_RESOURCE_PATH=@GAZEBO_SETUP_SH_RESOURCE_PATH@:${GAZEBO_RESOURCE_PATH} +export GAZEBO_PLUGIN_PATH=@GAZEBO_SETUP_SH_PLUGIN_PATH@:${GAZEBO_PLUGIN_PATH} +export GAZEBO_MODEL_PATH=@GAZEBO_SETUP_SH_MODEL_PATH@:${GAZEBO_MODEL_PATH} export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:@GAZEBO_PLUGIN_PATH@ export OGRE_RESOURCE_PATH=@OGRE_RESOURCE_PATH@