summaryrefslogtreecommitdiffhomepage
path: root/cmake/opentrack-pkg-config.cmake
blob: bad4fae13837f62db772a79fe4b4d411cad3ea7b (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
include(FindPkgConfig)

function(otr_pkgconfig target)
    set(cflags "")
    set(includes "")
    set(ldflags "")
    set(libs "")
    foreach(i ${ARGN})
        set(k pkg-config_${i})
        pkg_check_modules(${k} QUIET ${i})
        if(${${k}_FOUND})
            set(cflags "${cflags} ${${k}_CFLAGS} ")
            set(includes ${includes} ${${k}_INCLUDE_DIRS} ${${k}_INCLUDEDIR})
            set(ldflags "${ldflags} ${${k}_LDFLAGS} ")
            set(libs ${libs} ${${k}_LIBRARIES})
            message(STATUS "${target} | ${i} | ${cflags} | ${includes} | ${ldflags} | ${libs} | ")
        else()
            message(FATAL_ERROR "Can't find '${i}'. Please install development files for this package.")
        endif()
    endforeach()
    set_property(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS "${cflags} ")
    target_include_directories(${target} SYSTEM PRIVATE ${includes})
    set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "${ldflags} ")
    target_link_libraries(${target} ${libs})
endfunction()