diff --git a/CMakeLists.txt b/CMakeLists.txt index 81eac6a0a8..f5eeb01132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,11 +166,11 @@ message (STATUS "----------------------------------------\n") # 2. In the generation of cmake/setup.sh from cmake/setup.sh.in set(GAZEBO_DEFAULT_MASTER_HOST localhost) set(GAZEBO_DEFAULT_MASTER_PORT 11345) -set(GAZEBO_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) +set(GAZEBO_PLUGIN_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins) FILE(TO_NATIVE_PATH "${GAZEBO_PLUGIN_PATH}" GAZEBO_PLUGIN_PATH) -set(GAZEBO_MODEL_PATH ${CMAKE_INSTALL_PREFIX}/${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_RESOURCE_PATH ${CMAKE_INSTALL_PREFIX}/${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}) @@ -332,15 +332,15 @@ else (build_errors) gz_install_includes("" ${PROJECT_BINARY_DIR}/gazebo/gazebo_config.h) configure_file(${CMAKE_SOURCE_DIR}/cmake/setup.sh.in ${PROJECT_BINARY_DIR}/setup.sh @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.sh DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/) # Also install the setup.sh in an unversioned location - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gazebo/) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.sh DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gazebo/) if (WIN32) configure_file(${CMAKE_SOURCE_DIR}/cmake/setup.bat.in ${PROJECT_BINARY_DIR}/setup.bat @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.bat DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.bat DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/) # Also install the setup.bat in an unversioned location - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.bat DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gazebo/) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.bat DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/gazebo/) endif () if (DEFINED CMAKE_CXX_FLAGS) @@ -403,6 +403,10 @@ 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}") + foreach (pkgconfig ${pkgconfig_files}) configure_file(${CMAKE_SOURCE_DIR}/cmake/pkgconfig/${pkgconfig}.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${pkgconfig}.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${pkgconfig}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig COMPONENT pkgconfig) diff --git a/cmake/JoinPaths.cmake b/cmake/JoinPaths.cmake new file mode 100644 index 0000000000..2b376b7333 --- /dev/null +++ b/cmake/JoinPaths.cmake @@ -0,0 +1,23 @@ +# This module provides a function for joining paths +# known from most languages +# +# SPDX-License-Identifier: (MIT OR CC0-1.0) +# Copyright 2020 Jan Tojnar +# https://github.com/jtojnar/cmake-snips +# +# Modelled after Python’s os.path.join +# https://docs.python.org/3.7/library/os.path.html#os.path.join +# Windows not supported +function(join_paths joined_path first_path_segment) + set(temp_path "${first_path_segment}") + foreach(current_segment IN LISTS ARGN) + if(NOT ("${current_segment}" STREQUAL "")) + if(IS_ABSOLUTE "${current_segment}") + set(temp_path "${current_segment}") + else() + set(temp_path "${temp_path}/${current_segment}") + endif() + endif() + endforeach() + set(${joined_path} "${temp_path}" PARENT_SCOPE) +endfunction() diff --git a/cmake/gazebo-config.cmake.in b/cmake/gazebo-config.cmake.in index 330c4f9da2..b046db6194 100644 --- a/cmake/gazebo-config.cmake.in +++ b/cmake/gazebo-config.cmake.in @@ -5,7 +5,7 @@ set(@PKG_NAME@_CONFIG_INCLUDED TRUE) set(@PKG_NAME@_VERSION @GAZEBO_VERSION@) set(@PKG_NAME@_MAJOR_VERSION @GAZEBO_MAJOR_VERSION@) -set(@PKG_NAME@_PLUGIN_PATH "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins") +set(@PKG_NAME@_PLUGIN_PATH "@CMAKE_INSTALL_FULL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins") # The media path contains the location on disk where images, # materials scripts, shaders, and other related resources are stored. @@ -71,23 +71,23 @@ include (FindPkgConfig) # target_link_libraries(your_package @PKG_NAME@_PROTO_LIBRARIES) # set(@PKG_NAME@_PROTO_PATH - "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/gazebo/msgs/proto") + "@CMAKE_INSTALL_FULL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/gazebo/msgs/proto") find_library(gazebo_proto_msgs_lib gazebo_msgs - PATHS "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" NO_DEFAULT_PATH) + PATHS "@CMAKE_INSTALL_FULL_LIBDIR@" NO_DEFAULT_PATH) list(APPEND @PKG_NAME@_PROTO_LIBRARIES ${gazebo_proto_msgs_lib}) list(APPEND @PKG_NAME@_PROTO_INCLUDE_DIRS - "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/gazebo/msgs") + "@CMAKE_INSTALL_FULL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/gazebo/msgs") # End @PKG_NAME@_PROTO_PATH, @PKG_NAME@_PROTO_INCLUDE_DIRS, and # @PKG_NAME@_PROTO_LIBRARIES -list(APPEND @PKG_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@) -list(APPEND @PKG_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@) +list(APPEND @PKG_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@) +list(APPEND @PKG_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@) -list(APPEND @PKG_NAME@_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@) -list(APPEND @PKG_NAME@_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins) +list(APPEND @PKG_NAME@_LIBRARY_DIRS @CMAKE_INSTALL_FULL_LIBDIR@) +list(APPEND @PKG_NAME@_LIBRARY_DIRS @CMAKE_INSTALL_FULL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins) -list(APPEND @PKG_NAME@_CFLAGS -I@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@) -list(APPEND @PKG_NAME@_CFLAGS -I@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@) +list(APPEND @PKG_NAME@_CFLAGS -I@CMAKE_INSTALL_FULL_INCLUDEDIR@) +list(APPEND @PKG_NAME@_CFLAGS -I@CMAKE_INSTALL_FULL_INCLUDEDIR@/gazebo-@GAZEBO_MAJOR_VERSION@) if (GAZEBO_HAS_BULLET) if (PKG_CONFIG_FOUND) @@ -138,7 +138,7 @@ endif () foreach(lib @PKG_LIBRARIES@) set(onelib "${lib}-NOTFOUND") find_library(onelib ${lib} - PATHS "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" + PATHS "@CMAKE_INSTALL_FULL_LIBDIR@" NO_DEFAULT_PATH ) if(NOT onelib) @@ -217,6 +217,6 @@ if (GAZEBO_HAS_IGNITION_FUEL_TOOLS) list(APPEND @PKG_NAME@_LIBRARIES ${IGNITION-FUEL_TOOLS_LIBRARIES}) endif() -list(APPEND @PKG_NAME@_LDFLAGS -Wl,-rpath,@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins) -list(APPEND @PKG_NAME@_LDFLAGS -L@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@) -list(APPEND @PKG_NAME@_LDFLAGS -L@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins) +list(APPEND @PKG_NAME@_LDFLAGS -Wl,-rpath,@CMAKE_INSTALL_FULL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins) +list(APPEND @PKG_NAME@_LDFLAGS -L@CMAKE_INSTALL_FULL_LIBDIR@) +list(APPEND @PKG_NAME@_LDFLAGS -L@CMAKE_INSTALL_FULL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins) diff --git a/cmake/pkgconfig/gazebo.in b/cmake/pkgconfig/gazebo.in index 075cef356f..12e1654881 100644 --- a/cmake/pkgconfig/gazebo.in +++ b/cmake/pkgconfig/gazebo.in @@ -1,10 +1,10 @@ prefix=@CMAKE_INSTALL_PREFIX@ -libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=@pkgconfig_libdir@ +includedir=@pkgconfig_includedir@ Name: gazebo Description: Gazebo Libraries Version: @GAZEBO_VERSION_FULL@ Requires: sdformat protobuf @TBB_PKG_CONFIG@ ignition-math4 ignition-msgs1 ignition-transport4 @IGNITION_FUEL_TOOLS_PKGCONFIG@ -Libs: -Wl,-rpath,${prefix}/@CMAKE_INSTALL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins -L${libdir} -L${prefix}/@CMAKE_INSTALL_LIBDIR@/gazebo-@GAZEBO_MAJOR_VERSION@/plugins -lgazebo_transport -lgazebo_physics -lgazebo_sensors -lgazebo_rendering -lgazebo_gui -lgazebo_client -lgazebo_msgs -lgazebo_common -lgazebo @Boost_PKGCONFIG_LIBS@ @APPLE_PKGCONFIG_LIBS@ +Libs: -Wl,-rpath,${libdir}/gazebo-@GAZEBO_MAJOR_VERSION@/plugins -L${libdir} -L${libdir}/gazebo-@GAZEBO_MAJOR_VERSION@/plugins -lgazebo_transport -lgazebo_physics -lgazebo_sensors -lgazebo_rendering -lgazebo_gui -lgazebo_client -lgazebo_msgs -lgazebo_common -lgazebo @Boost_PKGCONFIG_LIBS@ @APPLE_PKGCONFIG_LIBS@ CFlags: -I${includedir}/gazebo-@GAZEBO_MAJOR_VERSION@ @Boost_PKGCONFIG_CFLAGS@ -std=c++11 diff --git a/cmake/pkgconfig/gazebo_ode.in b/cmake/pkgconfig/gazebo_ode.in index de878759fb..2516a73c0f 100644 --- a/cmake/pkgconfig/gazebo_ode.in +++ b/cmake/pkgconfig/gazebo_ode.in @@ -1,10 +1,10 @@ prefix=@CMAKE_INSTALL_PREFIX@ -libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=@pkgconfig_libdir@ +includedir=@pkgconfig_includedir@ Name: gazebo Description: Gazebo Exported ODE Libraries Version: @GAZEBO_VERSION_FULL@ Requires: -Libs: -Wl,-rpath,${prefix}/@CMAKE_INSTALL_LIBDIR@ -L${prefix}/@CMAKE_INSTALL_LIBDIR@ -lgazebo_ode +Libs: -Wl,-rpath,${libdir} -L${libdir} -lgazebo_ode CFlags: -I${includedir}/gazebo-@GAZEBO_MAJOR_VERSION@ diff --git a/cmake/pkgconfig/gazebo_transport.in b/cmake/pkgconfig/gazebo_transport.in index d9ec3c1721..f3ac1de4a2 100644 --- a/cmake/pkgconfig/gazebo_transport.in +++ b/cmake/pkgconfig/gazebo_transport.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=@pkgconfig_libdir@ +includedir=@pkgconfig_includedir@ Name: gazebo_transport Description: Gazebo Transport Library diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index cf107b8e70..d9e8a54669 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -161,7 +161,7 @@ set (DARTplugins ) set(GAZEBO_PLUGIN_INSTALL_DIR - ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins/ + ${CMAKE_INSTALL_FULL_LIBDIR}/gazebo-${GAZEBO_MAJOR_VERSION}/plugins/ ) add_library(TrackedVehiclePlugin SHARED TrackedVehiclePlugin.cc)