summaryrefslogtreecommitdiffhomepage
path: root/cmake/opentrack-pkg-config.cmake
blob: 0f13defcc2f5ddf405e00fb8164b3fa5aa40fa6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
include_guard(GLOBAL)
include(FindPkgConfig)

function(otr_pkgconfig_ ret target)
    set(${ret} 1 PARENT_SCOPE)
    foreach(i ${ARGN})
        set(k pkg-config_${i})
        pkg_check_modules(${k} QUIET ${i})
        if(${${k}_FOUND})
            target_compile_options(${target} PRIVATE "${${k}_CFLAGS}")
            target_link_options(${target} PRIVATE ${${k}_LDFLAGS})
            target_include_directories(${target} SYSTEM PRIVATE ${${k}_INCLUDE_DIRS} ${${k}_INCLUDEDIR})
            target_link_libraries(${target} ${${k}_LIBRARIES})
        else()
            set(${ret} 0 PARENT_SCOPE)
        endif()
    endforeach()
endfunction()

function(otr_pkgconfig target)
    set(ret "")
    otr_pkgconfig_(ret "${target}" ${ARGN})
    foreach(i ${ARGN})
        set(k pkg-config_${i})
        if(NOT ${${k}_FOUND})
            message(FATAL_ERROR "Can't find '${i}'. Please install development files for this package.")
        endif()
    endforeach()
endfunction()