cartographer icon indicating copy to clipboard operation
cartographer copied to clipboard

CartographerTargets.cmake contains absolute paths

Open PeterProfessional opened this issue 4 years ago • 0 comments

When I run cmake the file CartographerTargets.cmake is generated and contains absolute paths as follows:

set_target_properties(cartographer PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/usr/include/eigen3;/usr/local/include;/usr/include/eigen3;/usr/include;/usr/include;/usr/include/lua5.2;/usr/include;/usr/local/include;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "ceres;/usr/lib/x86_64-linux-gnu/liblua5.2.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;glog;gflags;cairo;/usr/local/lib/libprotobuf.a;standalone_absl;pthread"
  INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "/usr/include/eigen3;/usr/local/include;/usr/include/eigen3;/usr/include;/usr/include;/usr/include/lua5.2;/usr/include;/usr/local/include"
)

Usually this file should contain relative paths, so that paths still work if something is relocated or if used in specific build environments (e.g. for cross compiling). In parts, the above is already correct, since it contains e.g. ${_IMPORT_PREFIX}/include in the list of INTERFACE_INCLUDE_DIRECTORIES and in INTERFACE_LINK_LIBRARIES some libraries are referenced without using absolute paths, e.g. ceres or pthread.

Do these absolute paths also occur on other/all build systems? Does anyone know how to fix this properly?

I already know that the file CartographerTargets.cmake is generated by the following command

install(
  EXPORT CartographerExport
  DESTINATION share/cartographer/cmake/
  FILE CartographerTargets.cmake
)

in the CMakeLists.txt. I am not sure however, why the INTERFACE properties are set with absolute paths, since I neither see anything wrong with the install(TARGETS) command nor the target_link_libraries and target_include_directories commands.

additional info:

tested with commit bcd5486025df4f601c3977c44a5e00e9c80b4975 built on ubuntu 16.04 cmake version 3.5.1

PeterProfessional avatar May 15 '20 11:05 PeterProfessional