Integrating external libraries

From Wiki for iCub and Friends
Jump to: navigation, search

Notes on integrating external libraries in a CMake project.


Eric has commited a "FindOpenCV.cmake" script in:


If you include opencv and yarp/sig header files in the same file, make sure you put the following line at the top of your program:

 #define YARP_CVTYPES_H_

This will prevent YARP's local copy of the IPL types conflicting with OpenCV. The two are the same. An example CMakeLists.txt (from Joerg, with updates from Eric):

 SET(YARP_DIR "$ENV{YARP_ROOT}" CACHE LOCATION "where is your yarp build directory?")
# This line will tell CMake to look in the project directory for configure scripts SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
# Adding 'REQUIRED' will cause CMake to stop with an error if a package is not found FIND_PACKAGE(OpenCV REQUIRED)
# The OPENCV_INCLUDE_DIR_CV variable should be enough to find all needed OpenCV headers INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${OPENCV_INCLUDE_DIR_CV})
# In addition to specifying the libraries to link, the directories containing the # libraries should be added in case the libraries are in a non-standard location LINK_DIRECTORIES(${OPENCV_LINK_DIRECTORIES}) LINK_LIBRARIES(${OPENCV_LIBRARIES})
ADD_EXECUTABLE(kibitzer main.cpp)


see example in YARP source code, example/imagemagick