robotology / ycm-cmake-modules

YCM (YCM CMake modules) is a collection of various useful CMake modules.
http://robotology.github.io/ycm-cmake-modules
Other
52 stars 23 forks source link

Fix edit_cache targets in development mode #372

Closed PeterBowman closed 3 years ago

PeterBowman commented 3 years ago

I have noticed that upon enabling development mode on a superbuild subproject (either YCM_EP_DEVEL_MODE_<project_name> or YCM_EP_MAINTAINER_MODE set to ON, where <project_name> is orchestrated by YCM/ExternalProject), a specific target (e.g. <project_name>-edit_cache) is generated which opens the CMake cache editor, i.e. ccmake. It didn't work for me, though.

Then, I saw something like this in build/CMakeFiles/<project_name>-edit_cache.dir/build.make (real excerpt from generated Makefile by https://github.com/roboticslab-uc3m/asibot-main superbuild):

external/ROBOTICSLAB_KINEMATICS_DYNAMICS/CMakeFiles/YCMStamp/ROBOTICSLAB_KINEMATICS_DYNAMICS-edit_cache: external/ROBOTICSLAB_KINEMATICS_DYNAMICS/CMakeFiles/YCMStamp/ROBOTICSLAB_KINEMATICS_DYNAMICS-configure
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/bartek/wingit/asibot-main/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Running CMake cache editor for ROBOTICSLAB_KINEMATICS_DYNAMICS..."
    cd /home/bartek/wingit/asibot-main/build/external/ROBOTICSLAB_KINEMATICS_DYNAMICS && /usr/bin/ccmake -H -B/home/bartek/wingit/asibot-main/build/external/ROBOTICSLAB_KINEMATICS_DYNAMICS

The problem boils down to:

/usr/bin/ccmake -H -B<path_to_build_dir>

Cause: no source dir provided to the -H option since variable expansion failed. This patch aims to fix it while still accounting for the source subdir suffix. Tested on CMake 3.16.3 (Ubuntu 20.04).

drdanz commented 3 years ago

Merged, thanks.