ros / catkin

A CMake-based build system that is used to build all packages in ROS.
http://wiki.ros.org/catkin
BSD 3-Clause "New" or "Revised" License
321 stars 280 forks source link

Fix CATKIN_SYMLINK_INSTALL with add_subdirectory() #1102

Closed sloretz closed 4 years ago

sloretz commented 4 years ago

catkin_symlink_install_files/directory/programs() use generated functions that store the value of CMAKE_CURRENT_SOURCE_DIR at the time they are generated. This value is incorrect when install(...) is called from a directory using add_subdirectory() as is the case in gencpp. This fixes the issue by passing the current source directory to the generated functions at the time that they're called.

Noticed while reviewing #1100 and trying to build gencpp using

./src/catkin/bin/catkin_make_isolated --install --build-space buildi_noetic --devel-space develi_noetic --install-space installi_noetic --cmake-args -DCATKIN_SYMLINK_INSTALL=ON
==> make install in '/home/sloretz/ws/catkin/buildi_noetic/gencpp'
Install the project...
-- Install configuration: ""
-- Execute custom install script
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/_setup_util.py
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/env.sh
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/setup.bash
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/local_setup.bash
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/setup.sh
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/local_setup.sh
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/setup.zsh
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/local_setup.zsh
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/.rosinstall
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/lib/pkgconfig/gencpp.pc
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/share/gencpp/cmake/gencpp-extras.cmake
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/share/gencpp/cmake/gencppConfig.cmake
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/share/gencpp/cmake/gencppConfig-version.cmake
-- Symlinking: /home/sloretz/ws/catkin/install_noetic/share/gencpp/package.xml
CMake Error at catkin_symlink_install/catkin_symlink_install.cmake:151 (message):
  catkin_symlink_install_files() can't find
  '/home/sloretz/ws/catkin/src/gencpp/msg.h.template'
Call Stack (most recent call first):
  catkin_symlink_install/catkin_symlink_install.cmake:334 (catkin_symlink_install_files)
  cmake_install.cmake:41 (include)

make: *** [Makefile:86: install] Error 1
<== Failed to process package 'gencpp': 
  Command '['/home/sloretz/ws/catkin/install_noetic/env.sh', 'make', 'install']' returned non-zero exit status 2.

Reproduce this error by running:
==> cd /home/sloretz/ws/catkin/buildi_noetic/gencpp && /home/sloretz/ws/catkin/install_noetic/env.sh make install
dirk-thomas commented 4 years ago

Thanks for the patch and for iterating on it.

dirk-thomas commented 4 years ago

Cherry-picked to kinetic-devel in 77ca28cd081a853038ba279c2d8ac8dc22cc6852.