find_package() on ROS_PACKAGE_PATH?
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
)
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:
are you sure this is correct? Afaik paths passed to
INCLUDE_DIRS
should be relative to theCMakeLists.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 bygenerate_messages(..)
andmessage_runtime
et al.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.
Perhaps the catkin/what: Structured Atomic Workspaces section helps.
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.
@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.
@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.
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!