Reputation: 4082
I have a project which uses OpenCV and whose project files are generated via cmake. Now adding the opencv libs in CMake generally works like this:
find_package(OpenCV REQUIRED core highgui gpu)
add_executable(SomeExecutable someSource.cpp)
target_link_libraries(SomeExecutable ${OpenCV_LIBS})
Which would link the libs core, highgui and gpu to this executable. Now if I have a project with multiple executables, is it possible to add different ones of the OpenCV libs to the different executables? (E.g. because I don't want the other application to load unnecessary libraries).
Upvotes: 0
Views: 974
Reputation: 703
You should not link your targets with all found packages. Instead of writing:
target_link_libraries(SomeExecutable ${OpenCV_LIBS})
You might want to write:
target_link_libraries(SomeExecutable cxcore highgui)
For the names of OpenCV libraries check FindOpenCV.cmake file in your CMake path.
Upvotes: 1