forked from os-autoinst/os-autoinst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkg-config.cmake
18 lines (16 loc) · 842 Bytes
/
pkg-config.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cmake_minimum_required(VERSION 3.17.0)
include(FindPkgConfig)
function (target_use_pkg_config_module TARGET PACKAGE)
pkg_check_modules(PKG_CONFIG "${PACKAGE}")
target_link_libraries("${TARGET}" PRIVATE opencv_core opencv_imgcodecs ${PKG_CONFIG_LIBRARIES})
target_include_directories("${TARGET}" PRIVATE ${PKG_CONFIG_INCLUDE_DIRS})
target_compile_options("${TARGET}" PRIVATE ${PKG_CONFIG_CFLAGS_OTHER})
if (COMMAND target_link_options)
target_link_options("${TARGET}" PRIVATE ${PKG_CONFIG_LDFLAGS_OTHER})
elseif (PKG_CONFIG_LDFLAGS_OTHER)
# fallback for older CMake versions not supporting target_link_options
foreach (FLAG ${PKG_CONFIG_LDFLAGS_OTHER})
set_property(TARGET "${TARGET}" APPEND_STRING PROPERTY LINK_FLAGS " ${FLAG}")
endforeach ()
endif ()
endfunction ()