catkin icon indicating copy to clipboard operation
catkin copied to clipboard

switch from `cmi` to `cmi --install` results in <dependency>_DIR to still refer to devel-space instead of install-space

Open mxsrc opened this issue 7 years ago • 7 comments

When running catkin_make using the --install switch after changing a packages CMakeLists.txt on a already built workspace, dependencies's _DIR variables will still be pointing to the devel-space Config.cmake. In case, the current package requires messages from its dependency this will terminate the build.

Steps to reproduce:

  • Set up a clean workspace for the ros_comm packages: rosinstall_generator ros_comm kinetic --deps --wet-only --tar > test.rosinstall wstool init -j8 src test.rosinstall
  • Build without --install switch: ./src/catkin/bin/catkin_make_isolated
  • Modify src/ros_comm_msgs/rosgraph_msgs/CMakeLists.txt (e.g. add a message call)
  • Build with install-switch: ./src/catkin/bin/catkin_make_isolated --install

The second build will fail when trying to build rosgraph_msgs. The reason is that the install-space -msg-paths.cmake sets the MSG_INCLUDE_DIR relative to _DIR, which is still refering to devel-space where the msg-directory does not exist.

mxsrc avatar Apr 27 '17 13:04 mxsrc

When running catkin_make using the --install ...

I assume you mean catkin_make_isolated here?

I am assuming the second build doesn't run cmake for the rosgraph_msgs package. Can you confirm that in the output? Can you please try to also pass --force-cmakeon the invocation with --install and comment if that fixes the problem.

dirk-thomas avatar Apr 27 '17 15:04 dirk-thomas

You're right, I call catkin_make_isolated. The second run does not invoke the std_msgs cmake again, only for rosgraph_msgs. Calling it with --force-cmake though did not fix the problem, I still get the same error message.

mxsrc avatar Apr 27 '17 15:04 mxsrc

Modify src/ros_comm_msgs/rosgraph_msgs/CMakeLists.txt (e.g. add a message call)

Can you please describe exactly what you do in this step.

dirk-thomas avatar Apr 27 '17 16:04 dirk-thomas

I changed it to:

cmake_minimum_required(VERSION 2.8.3)
project(rosgraph_msgs)

find_package(catkin REQUIRED COMPONENTS message_generation std_msgs)

message(foo)

add_message_files(DIRECTORY msg
  FILES
  Clock.msg
  Log.msg
  TopicStatistics.msg)

generate_messages(DEPENDENCIES std_msgs)

catkin_package(CATKIN_DEPENDS message_runtime std_msgs)

mxsrc avatar Apr 27 '17 16:04 mxsrc

Ok, the added message() call already implies a CMake reconfigure invocation. So the same problem happens without the change when invoking catkin_make_isolated --force-cmake --install for the second build.

What happens is that on the first run CMake find std_msgs in .../devel_isolated/std_msgs/share/std_msgs/cmake. On the second build it won't search for it again since the CMake cache still contains that location. That is why it fails.

The build tool would need to detect the switch between not using --install and using --install and then go through the CMake cache and remove potentially problematic entries. While that would be possible I am not sure if it will be implemented in the future.

Therefore I can only recommend that you have to remove your CMake cache files when switching to --install (or more extremely remove the build and devel space completely). Sorry for not having a better answer for you.

dirk-thomas avatar Apr 27 '17 17:04 dirk-thomas

Okay, the bug is not too annoying anyway, at least now I know its reason.

mxsrc avatar Apr 28 '17 10:04 mxsrc

As a point of comparison, catkin build will detect when you move from --no-install to --install (or vice versa) and refuse to build, suggesting you clean your build and devel space before continuing.

wjwwood avatar Apr 28 '17 21:04 wjwwood