How to set libraries in "Other linker flags" using CMake?

I am trying to create an Xcode project with cmake, but I cannot define "Other linker flags" in the project settings. I used "target_link_libraries", but it does not work. Any clue? I want to determine which libraries should be included when linking. If I do this manually, I add "-lopencv_core", for example.

+4
source share
1 answer

* target_link_libraries * should handle it for you. If you are not already using the FindOpenCV.cmake module to find libraries that are probably the problem, and you should try the following. To do this, first get the FindOpenCV.cmake file and put it in your project path (usually {project_dir} / cmake / Modules) and add the following line to your CMakeLists.txt:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") 

This will allow CMake to use the custom FindOpenCV.cmake method when resolving libraries. Then add:

 FIND_PACKAGE( OpenCV REQUIRED ) TARGET_LINK_LIBRARIES( PROJECT_NAME_HERE ${OpenCV_LIBS} ) 

Although you do not need to set linker flags with CMAKE_SHARED_LINKER_FLAGS .

0
source

Source: https://habr.com/ru/post/1436634/


All Articles