Link opencv in Cmakelist.txt [closed]
What is the proper way of linking OpenCV
on CMakeList.txt?
That's my CmakeList.txt:
find_package(OpenCV)
catkin_package(
DEPENDS opencv
)
include_directories(
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${catkin_LIBRARIES}
)
It causes the error below:
CMake Error at airsim_ros/CMakeLists.txt:154 (target_link_libraries):
Cannot specify link libraries for target "airsim_ros" which is not built by
this project.
You need to specify target_link_libraries for each binary (executable/library) separately, not for the package as a whole.
From cmake docs
target
must have been created byadd_executable
command which expects a C/C++, however I'm using pythonadd_executable, target_link_libraries and include_directories are only relevant to c++ nodes. If you're package only contains python nodes you do not need those lines.
Python does not link against anything, so a
CMakeLists.txt
is very empty for Python packages.See the Catkin documentation for more information.