ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

CMakeLists: only link library if Raspberry Pi (or equivalent condition)

asked 2017-03-11 16:12:37 -0500

I have a package that I want to run on both a desktop/laptop (x64) and a Raspberry Pi (armhf). There's a node in my package that has to be run on the Raspberry Pi. It uses the wiringPi library. Obviously, doing catkin_make on something other than a RPi results in an error, so at the moment I just comment out those lines.

I'd like to find a way to only execute target_link_libraries() if the current computer/architecture/distro matches that of the RPi.

edit retag flag offensive close merge delete

Comments

2

@Chris_: this is really a CMake question, and not related to ROS per se (catkin == essentially CMake in this case). I'd advise you to do a (google) search for keywords like "cmake detect architecture" or "cmake detect raspberry pi". You'll probably find a solution much faster that way.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-12 04:14:54 -0500 )edit

@gvdhoorn yeah I figured it wasn't strictly ROS-related, but I thought I'd see if people went through the same stuff here. Thanks for the suggestion!

christophebedard gravatar image christophebedard  ( 2017-03-12 11:00:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-03-12 11:03:02 -0500

Wolf gravatar image

You can add an if - Else - endif clause in your CMakeLists.txt using a self defined variable, e.g. IS_RASP, with different target_link_libraries commands in if and Else.

When calling Into catkin_make you can call it without additional arg on your Host anderen with catkin_make -DIS_RASP=1 in your device. Note you can pass Command Line args to cmake when calling it via catkin_make using the -D Just Like you would so in plain cmake.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-11 16:10:41 -0500

Seen: 1,246 times

Last updated: Mar 12 '17