colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

A cmake initial cache file via '-C' with --cmake-args fails #104

Open stonier opened 3 years ago

stonier commented 3 years ago
$ colcon  build --symlink-install --event-handlers console_direct+ --cmake-args -C /mnt/mervin/workspaces/devel/camera/initial_cache.cmake
loading initial cache file /mnt/mervin/workspaces/devel/camera/initial_cache.cmake
Re-run cmake no build system arguments
CMake Error: The source directory "/mnt/mervin/workspaces/devel/camera/initial_cache.cmake" is a file, not a directory.

So, loads fine, but fails because it confuses the initial cache path with the source directory. Digging into an example of the actual command that colcon uses for cmake (use --log-level=debug with colcon):

[0.214s] DEBUG:colcon.colcon_core.event_handler.log_command:Invoked command in '/mnt/mervin/workspaces/devel/camera/build/ueye_cam' returned '1':  CMAKE_PREFIX_PATH=/opt/ros/dashing /usr/bin/cmake /mnt/mervin/workspaces/devel/camera/src/ueye_cam -C /mnt/mervin/workspaces/devel/camera/initial_cache.cmake -DAMENT_CMAKE_SYMLINK_INSTALL=1 -DCMAKE_INSTALL_PREFIX=/mnt/mervin/workspaces/devel/camera/install/ueye_cam

Here the source directory is specified prior to the -C argument (as well as the other arguments). While this works for other cmake args, it does not work for the -C argument. In addition, this would appear not to be a cmake problem - cmake does in fact suggest options should come first:

cmake --help
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>

Q: Are there any ramifications to moving the specified source directory to the end of this list of arguments?

stonier commented 3 years ago

Attempting to switch the order (i.e. put args.path to the end) in:

https://github.com/colcon/colcon-cmake/blob/8f1b92a190b2ad4289ecf837c3200d540c13fdd9/colcon_cmake/task/cmake/build.py#L146-L148

hidmic commented 2 years ago

Q: Are there any ramifications to moving the specified source directory to the end of this list of arguments?

This makes sense to me. @dirk-thomas ?

@stonier would you be willing to submit a patch?

dirk-thomas commented 2 years ago

Sounds reasonable to me. I haven't tried or tested the suggestion though.