0
$\begingroup$

Rosanswers logo

Sorry in advance if this is a poorly constructed idea/question.

I have strict orders that I can't use caktin build and that I should only use basic make/cmake commands to control the build process.

I am building a package of messages and then trying to find_package() that message package from another package that needs to use them. I provide the config files below for the message package amrl_msgs. If there is a fundamentally better way to try to do what I want to do, I am eager to hear, as long as it doesn't involve using catkin build/make :)

When I try to find_package(amrl_msgs) in another project I get a

  Could not find a package configuration file provided by "amrl_msgs" with
  any of the following names:

    amrl_msgsConfig.cmake
    amrl_msgs-config.cmake

error, even though the amrl_msgsConfig.cmake is found in amrl_msgs/build/devel/share/amrl_msgs/cmake and I have both the of the packages on the ROS_PACKAGE_PATH. I am assuming the way to solve this problem is not with the ROS_PACKAGE_PATH, but I also don't want to have to hardcode the absolute path to amrl_msgsConfig.cmake every time I use it. How do I direct the system to be able to find the messages without hardcoding the path?

cmake_minimum_required(VERSION 2.8.3)
project(amrl_msgs)

## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  std_msgs
  message_generation
) 

add_message_files(
  FILES
  Point2D.msg
  ColoredArc2D.msg
  ColoredLine2D.msg
  ColoredPoint2D.msg
  Localization2DMsg.msg
  PathVisualization.msg
  Point2D.msg
  Pose2Df.msg
  RobofleetStatus.msg
  RobofleetSubscription.msg
  VisualizationMsg.msg
 )

generate_messages(
  DEPENDENCIES
  std_msgs
 )

catkin_package(
  INCLUDE_DIRS build/devel/include
  CATKIN_DEPENDS std_msgs message_runtime
)

Originally posted by JackB on ROS Answers with karma: 977 on 2021-02-02

Post score: 1


Original comments

Comment by gvdhoorn on 2021-02-02:\

am assuming the way to solve this problem is not with the ROS_PACKAGE_PATH [..]

afaik CMake does not look at that variable for locations where it should look for *Config.cmake files.

You'll probably want/need to set CMAKE_PREFIX_PATH, which is one of the jobs Catkin (the tool) takes care of for you.

There is no magic, it's all just CMake.


Edit:

INCLUDE_DIRS build/devel/include

are you sure this is correct? Afaik paths passed to INCLUDE_DIRS should be relative to the CMakeLists.txt / package root. You appear to be referring to a directory generated during the build. And pure message packages typically don't export any include directories. That gets taken care of by generate_messages(..) and message_runtime et al.

Comment by gvdhoorn on 2021-02-02:\

I also don't want to have to hardcode the absolute path to amrl_msgsConfig.cmake every time I use it

CMake will crawl the FS to some extent, but unfortunately if you're not using Catkin, you're now responsible for updating the CMAKE_PREFIX_PATH such that it contains the locations CMake should crawl to look for *Config.cmake files.

That's again CMake, not Catkin.

Comment by gvdhoorn on 2021-02-02:
Perhaps the catkin/what: Structured Atomic Workspaces section helps.

Comment by AmirSaman on 2021-02-02:
using the following command " catkin_make --only-pkg-with-deps <target_package> " you can build the specific package instead of building all the packages in your system. Also if you have the package path you can put it in bashrc file so it will be loaded at all the times. you also can make a new enviorment and build your package there and source it into the bashrc file this will requires catkin_make however since it is in diffrent enviorment it will not make any issue for your current packages.

Comment by gvdhoorn on 2021-02-03:
@AmirSaman: the OP stated he cannot/is not allowed to use Catkin (the tool) in any way.

It's not clear to me how your comment addresses the issue and takes that into account.

Comment by AmirSaman on 2021-02-03:
@gvdhoorn I am just suggesting those ways in case if OP not aware of it which could enable him to do the catkin_make and solve his problem else what you have suggested earlier could help to settle this issue.

Comment by JackB on 2021-02-03:
Thanks for the feedback guys! That reading on Atomic Workspaces was very helpful to put the problem into context. I think there is not a good way to do what I want without hard coding paths in the CMake, or using make install to put the config files in more friendly locations (which isn't useful because often this will require sudo privileges). Thanks again!

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I'm not sure I understand why you need to "hard code paths in the CMake".

CMAKE_PREFIX_PATH is an environment variable. As long as the *Config.cmake files are in the appropriate location, CMake will find them.

Note: it's a prefix path, not a full path. CMake searches a few standard locations in each path on the CMAKE_PREFIX_PATH.


Originally posted by gvdhoorn with karma: 86574 on 2021-02-03

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by JackB on 2021-02-04:
You are 100% right! That is honestly exactly the solution I was looking for. We can just add the CMAKE_PREFIX_PATH of each package to the .bashrc or export it in each terminal session. Thanks so much!

Comment by gvdhoorn on 2021-02-04:
Yes, as I explained before: that's what Catkin does for you (among other things).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.