Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CATKIN_SYMLINK_INSTALL with add_subdirectory() #1102

Merged

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Jul 1, 2020

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

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() rules are
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.

Signed-off-by: Shane Loretz<sloretz@openrobotics.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz added the bug label Jul 1, 2020
@sloretz sloretz requested a review from dirk-thomas July 1, 2020 20:04
@sloretz sloretz self-assigned this Jul 1, 2020
sloretz added 2 commits July 10, 2020 17:26
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@dirk-thomas
Copy link
Member

Thanks for the patch and for iterating on it.

@dirk-thomas dirk-thomas merged commit 2d710b7 into ros:noetic-devel Jul 13, 2020
@sloretz sloretz deleted the sloretz/symlink_install_add_subdirectory branch July 13, 2020 22:00
dirk-thomas pushed a commit that referenced this pull request Jul 14, 2020
* Fix CATKIN_SYMLINK_INSTALL with add_subdirectory()

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() rules are
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.

Signed-off-by: Shane Loretz<sloretz@openrobotics.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Document CURRENT_SOURCE_DIR arg and alphabetical order

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* Quote to avoid variable expansion

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@dirk-thomas
Copy link
Member

Cherry-picked to kinetic-devel in 77ca28c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants