Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What is the best way for CMakeLists.txt to check if ROS is installed?

I'm working on a toolbox written in C++ that is outside of the ROS ecosystem but want to conditionally add ROS support if ROS is installed on the local machine. What is the best way to check if ROS is installed in my toolbox's CMakeLists.txt?

I'm currently checking for the existing of a local environment variable called "ROS_ROOT" as shown below.

if(DEFINED ENV{ROS_ROOT})
  find_package(roscpp REQUIRED)
  include_directories(${roscpp_INCLUDE_DIRS})
  ...
endif()

Is this an acceptable solution? Is there a better solution?

What is the best way for CMakeLists.txt to check if ROS is installed?

I'm working on a toolbox written in C++ that is outside of the ROS ecosystem but want to conditionally add ROS support if ROS is installed on the local machine. What is the best way to check if ROS is installed in my toolbox's CMakeLists.txt?

I'm currently checking for the existing existance of a local environment variable called "ROS_ROOT" as shown below.

if(DEFINED ENV{ROS_ROOT})
  find_package(roscpp REQUIRED)
  include_directories(${roscpp_INCLUDE_DIRS})
  ...
endif()

Is this an acceptable solution? Is there a better solution?