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

Revision history [back]

click to hide/show revision 1
initial version

Found solution:

*##########################################################################

1 ) created a folder cmake in the "first package" and added a file pkg_config_extras.cmake into it. It contains:

cmake_minimum_required(VERSION 2.8.3)

set( My_Var "Hello World" )

*##########################################################################

2) to make My_Var viewable in the "first package" 's CMakeLists.txt I added:

include( cmake/pkg_config_extras.cmake )

----> now I can output it there with correct result:

message( "My_Var = ${My_Var}" )

----> Result:

My_Var = Hello World

*##########################################################################

3) to make My_Var viewable in the "second package" 's CMakeLists.txt ("second package" depends on the "first package") I needed to add in the "first package" 's CMakeLists.txt a CFG_EXTRAS when calling catkin_package:

catkin_package(
  INCLUDE_DIRS include                  # unchanged, whatever was there before
  LIBRARIES ${PROJECT_NAME}             # unchanged, whatever was there before
  CATKIN_DEPENDS roscpp                 # unchanged, whatever was there before
  DEPENDS OpenCV                        # unchanged, whatever was there before
  CFG_EXTRAS pkg_config_extras.cmake    # added this line !!!!
)

----> now I can also output it in the "second package" 's CmakeLists.txt with correct result:

message( "My_Var = ${My_Var}" )

----> Result:

My_Var = Hello World