Link opencv in Cmakelist.txt [closed]

asked 2018-11-13 16:04:28 -0500

bxl gravatar image

updated 2018-11-15 06:59:43 -0500

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.
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by bxl
close date 2018-11-15 14:12:17.815744

Comments

1

You need to specify target_link_libraries for each binary (executable/library) separately, not for the package as a whole.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-13 17:49:16 -0500 )edit

From cmake docstargetmust have been created by add_executable command which expects a C/C++, however I'm using python

bxl gravatar image bxl  ( 2018-11-15 06:50:00 -0500 )edit
1

add_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.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-15 06:59:49 -0500 )edit

Python does not link against anything, so a CMakeLists.txt is very empty for Python packages.

See the Catkin documentation for more information.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 11:11:26 -0500 )edit