Ask Your Question
2

Maintaining backwards compatibility (opencv2 problem)

asked 2012-05-24 10:58:37 -0500

StFS gravatar image

Hi.

I have a bunch of packages that were developed on ROS CTurtle but now I'm trying to upgrade them to compile on Fuerte.

Most of it just works, but I am having problems with one of my packages that link against OpenCV.

Very briefly, I found out that in Fuerte I need to put the following in my CMakeLists.txt:

find_package(OpenCV REQUIRED)

rosbuild_add_executable(foo src/foo.cpp)
target_link_libraries(foo ${OpenCV_LIBRARIES})

This works fine for Fuerte, but unfortunately, when I try to build now on CTurtle I get an error stating that the FindOpenCV.cmake file could not be found.

To fix that, I added the following above the find_package line:

set(OpenCV_DIR /opt/ros/cturtle/stacks/vision_opencv/opencv2/opencv/share/opencv/)

Now, my stuff compiles on CTurtle, but since the cturtle path is now hard-coded into the CMakeLists.txt file, it fails on Fuerte!

So my question (finally) is, is there a way to maintain "backwards compatibility" so I can build my packages on top of both CTurtle and Fuerte? Am I maybe doing something wrong (having to specify the OpenCV_DIR variable doesn't look like it should have to be done)? Is there a way to selectively define the variable only if I'm doing it on CTurtle?

Kind regards, Stefan Freyr

edit retag flag offensive close merge delete

Comments

One would think that this should be something that is documented somewhere... It might very well be that backwards compatibility between certain versions is not possible at all, and CTurtle and Fuerte are quite different, but backwards incompatible changes should be documented right?

StFS gravatar imageStFS ( 2012-05-30 04:54:31 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2012-05-31 03:32:16 -0500

SL Remy gravatar image

With the warning from fuerte/Migration

Current best practice: Don't switch environments.

The following might get you out of the jam.

find_package(OpenCV)
IF(NOT OpenCV_FOUND)
    set(OpenCV_DIR /opt/ros/cturtle/stacks/vision_opencv/opencv2/opencv/share/opencv/)
    find_package(OpenCV)
ENDIF(NOT OpenCV_FOUND)

Doesn't promise anything about env variables and the like though, so you may face other challenges later on.

Good luck.

edit flag offensive delete link more

Comments

Thanks for your answer!

StFS gravatar imageStFS ( 2012-05-31 03:51:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-05-24 10:58:37 -0500

Seen: 616 times

Last updated: May 31 '12