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

Config --cmake-args -DCMAKE_PREFIX_PATH modify extended workspaces path. #711

Open
1 of 2 tasks
xkaraman opened this issue Feb 1, 2022 · 7 comments
Open
1 of 2 tasks

Comments

@xkaraman
Copy link

xkaraman commented Feb 1, 2022

System Info

  • Operating System: #109~18.04.1-Ubuntu
  • Python Version: Python 2.7.17
  • Version of catkin_tools: catkin_tools 0.8.2 (C) 2014-2022 Open Source Robotics Foundation
  • ROS Distro: melodic

Build / Run Issue

  • Works with catkin config --cmake-args -DOpen3D_ROOT=~/git/Open3D/install/lib/cmake/Open3D
  • Works with catkin config --cmake-args -DCMAKE_PREFIX_PATH=~/git/Open3D/install

Expected Behavior

I need to set prefix to find 3rd part library installed in non system paths eg -DCMAKE_PREFIX_PATH=~/git/Open3D/install.
I would expect catkin config --cmake-args -DCMAKE_PREFIX_PATH=~/git/Open3D/install to set up properly workspaces and not mess up extending workspaces.

Actual Behavior

--- Before catkin config --cmake-args -DCMAKE_PREFIX_PATH=~/git/Open3D/install

$ catkin config  
---------------------------------------------------------------------------
Profile:                     default
Extending:             [env] /home/user/catkin_ws/devel:/opt/ros/melodic
Workspace:                   /home/user/ros_ws/open3d_ws

This make the build failed for my package since find_packge(catkin REQUIRED ...) is not in path any more.

--- After catkin config --cmake-args -DCMAKE_PREFIX_PATH=~/git/Open3D/install

$ catkin config --cmake-args -DCMAKE_PREFIX_PATH=~/git/Open3D/install 
---------------------------------------------------------------------
Profile:                     default
Extending:             [env] ~/git/Open3D/install
Workspace:                   /home/user/ros_ws/open3d_ws

If catkin config --cmake-args -DOpen3D_ROOT=~/git/Open3D/install/lib/cmake/Open3d however is used, catkin find_package(catkin) is succesfull and Open3DConfig.cmake is found.

Check isl-org/Open3D#4093 (comment) even though now i think it's catkin bug and not open3d.

@timonegk
Copy link
Member

I tried to reproduce your error and there is definitely something strange going on. However, I think it is only a bug in the printed summary. Could you post the contents of .catkin_tools/profiles/default/config.yaml and the value of the environment variable CMAKE_PREFIX_PATH before and after setting the prefix path variable?

@xkaraman
Copy link
Author

xkaraman commented Apr 20, 2022

Sure let me do this from start:

Before Setting prefix path:

config.yaml

authors: []
blacklist: []
build_space: build
catkin_make_args: []
cmake_args: []
devel_layout: linked
devel_space: devel
extend_path: null
extends: null
install: false
install_space: install
isolate_install: false
jobs_args: []
licenses:
- TODO
log_space: logs
maintainers: []
make_args: []
source_space: src
use_env_cache: false
use_internal_make_jobserver: true
whitelist: []
$echo $CMAKE_PREFIX_PATH
/home/***/catkin_ws/devel:/opt/ros/melodic 

After setting with catkin config --cmake-args -DCMAKE_PREFIX_PATH=~/git/Open3D/install

config.yaml

authors: []
blacklist: []
build_space: build
catkin_make_args: []
cmake_args:
- -DCMAKE_PREFIX_PATH=~/git/Open3D/install
devel_layout: linked
devel_space: devel
extend_path: null
extends: null
install: false
install_space: install
isolate_install: false
jobs_args: []
licenses:
- TODO
log_space: logs
maintainers: []
make_args: []
source_space: src
use_env_cache: false
use_internal_make_jobserver: true
whitelist: []
$echo $CMAKE_PREFIX_PATH
/home/***/catkin_ws/devel:/opt/ros/melodic

@timonegk
Copy link
Member

From this output it looks like it is only a display issue. As you can see, there is no change to the extends and extend_path variables. But if your package still does not build (and I suppose you also did try to do a clean build), put the following two lines before the failing find_package:

message("CMake Variable: ${CMAKE_PREFIX_PATH}")
message("Env Variable: $ENV{CMAKE_PREFIX_PATH}")

and try to build again. Then we can hopefully see where the error comes from. The output of the first line should be ~/git/Open3D/install, the second should be the one containing your workspaces.

@xkaraman
Copy link
Author

Package still doesn't build even after catkin clean yes. Maybe seeing this issue can providde more information on what i tried and what failed.

I added the lines in CMakeLists.txt and tried with and without -DCMAKE_PREFIX_PATH=

Clean build without -DCMAKE_PREFIX_PATH

catkin clean
catkin build

Output:

CMake Variable: /home/user/ros_ws/open3d_ws/devel/.private/open3d_conversions;/home/user/ros_ws/open3d_ws/devel;/home/user/catkin_ws/devel;/opt/ros/melodic
Env Variable: /home/user/ros_ws/open3d_ws/devel:/home/user/catkin_ws/devel:/opt/ros/melodic

Clean build with -DCMAKE_PREFIX_PATH="~/git/Open3D/install"

catkin clean
catkin build -DCMAKE_PREFIX_PATH="~/git/Open3D/install"

Output: I doesn't even pass find_package(catkin) so no message appears. So i added the lines also above find_package(catkin)

CMake Variable: ~/git/Open3D/install
Env Variable: /home/user/ros_ws/open3d_ws/devel

This made me think that ros base workspace was not extended for some reason! Isn't supposed to be the default as long it was sourced before? Correct me if i am wrong though. Hope this sheds some light to the problem!

echo $CMAKE_PREFIX_PATH
/home/user/catkin_ws/devel:/opt/ros/melodic

@artivis
Copy link
Contributor

artivis commented Jun 1, 2022

I ran into this as well, after a quick investigation I believe the 'problem' takes place in catkin here.

use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
or CMAKE_PREFIX_PATH from the environment

catkin either uses the CMAKE_PREFIX_PATH cli argument or the CMAKE_PREFIX_PATH environment variable but not both. Note that the former takes precedence over the later. Since catkin uses the env. var. to pass around the underlay workspaces paths around (echo $CMAKE_PREFIX_PATH->/opt/ros/noetic), they get overwritten by the cmake flag and the build is broken.

Not sure if this is a feature or a bug but it is quite unfortunate.

@xkaraman
Copy link
Author

xkaraman commented Jun 2, 2022

So in order for this to get fixed, if it's a bug, is to append the CMAKE_PREFIX_PATH CLI to the ENV one instead of replacing it?
Yet is appending it always going to be the case, or are there other factors that we need to take into account that need CMAKE_PREFIX_PATH to be just overwritten?

@artivis
Copy link
Contributor

artivis commented Jun 2, 2022

I can't properly answer your question as I didn't dig any further. I simply tried to set the CMAKE_PREFIX_PATH cmake flag with the underlay path + my custom path (e.g. -DCMAKE_PREFIX_PATH='/opt/ros/noetic;/home/user/mylib') but that didn't work either.
But CMake offers other variables you can try, specifically <project>_ROOT or <project>_DIR. I'm still looking into those myself.

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

No branches or pull requests

3 participants