Adding a cpp file to include in executable file
New to CMake and trying to figure out how to include a cpp file that an executable file links to. Trying to program Object Oriented. I want to add a robot.cpp as a class file, so that i will be able to create a Robot object in my executable file.
The robot.cpp file at this location: include/manuscriptBuilder/robot.cpp
Made these modifications to the CMakeLists.txt:
- under find_package i added:
"robot" - under catkin_package i added:
"DEPENDS robot" - include_directories( include ${catkin_INCLUDE_DIRS})
- add_library(robot include/manuscriptBuilder/robot.cpp)
- target_link_libraries(motor_command_pub_test_node ${catkin_LIBRARIES})
Enden up with this error message:
CMake Warning at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
Could not find a package configuration file provided by "robot" with any of the following names:
robotConfig.cmake
robot-config.cmake
Add the installation prefix of "robot" to CMAKE_PREFIX_PATH or set "robot_DIR" to a directory containing one of the above files. If "robot" provides a separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
ev3_ros/CMakeLists.txt:10 (find_package)
-- Could not find the required component 'robot'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "robot" with any of the following names:
robotConfig.cmake
robot-config.cmake
Add the installation prefix of "robot" to CMAKE_PREFIX_PATH or set "robot_DIR" to a directory containing one of the above files. If "robot" provides a separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
ev3_ros/CMakeLists.txt:10 (find_package)
-- Configuring incomplete, errors occurred!
As i said i am new to CMake and catkin and C++ all together, so any tutorials to understand the CMakeLists.txt file and how to use it in relation to ROS would make me very happy.
It has worked in another project, where i had a header file and a cpp file, with the same name. I just used add_library, added it as a dependence and required component.
Please provide the entire CMakeLists.txt file -- that will make it easier to debug. (Remove the boilerplate comments.)
As an aside, the typical layout is this:
If you follow this layout the tutorials will make more sense.