| 1 |
find_package(PkgConfig) |
| 2 |
|
| 3 |
macro(_internal_message msg) |
| 4 |
if(NOT ${_is_quiet}) |
| 5 |
message(STATUS "${msg}") |
| 6 |
endif() |
| 7 |
endmacro() |
| 8 |
|
| 9 |
macro(check_lib var pc lib) |
| 10 |
set(_is_required 0) |
| 11 |
set(_is_quiet 0) |
| 12 |
set(_arg_list ${ARGN}) |
| 13 |
foreach(_arg ${ARGN}) |
| 14 |
if(_arg STREQUAL "REQUIRED") |
| 15 |
list(REMOVE_ITEM _arg_list "REQUIRED") |
| 16 |
set(_is_required 1) |
| 17 |
endif() |
| 18 |
if(_arg STREQUAL "QUIET") |
| 19 |
list(REMOVE_ITEM _arg_list "QUIET") |
| 20 |
set(_is_quiet 1) |
| 21 |
endif() |
| 22 |
endforeach() |
| 23 |
|
| 24 |
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND) |
| 25 |
pkg_search_module(${var} QUIET ${pc}) |
| 26 |
endif() |
| 27 |
|
| 28 |
if(${var}_FOUND) |
| 29 |
if(${var}_INCLUDE_DIRS) |
| 30 |
include_directories(${${var}_INCLUDE_DIRS}) |
| 31 |
endif() |
| 32 |
# Make sure include directories for headers found using find_path below |
| 33 |
# are re-added when reconfiguring |
| 34 |
if(${var}_INCLUDE) |
| 35 |
include_directories(${${var}_INCLUDE}) |
| 36 |
endif() |
| 37 |
_internal_message("${lib} found") |
| 38 |
else() |
| 39 |
find_library(${var} ${lib}) |
| 40 |
if(_arg_list) |
| 41 |
find_path(${var}_INCLUDE ${_arg_list}) |
| 42 |
else() |
| 43 |
set(${var}_INCLUDE FALSE) |
| 44 |
endif() |
| 45 |
if(${var} AND ${var}_INCLUDE) |
| 46 |
include_directories(${${var}_INCLUDE}) |
| 47 |
_internal_message("${lib} found") |
| 48 |
set(${var}_FOUND 1 CACHE INTERNAL "") |
| 49 |
else() |
| 50 |
if(_is_required) |
| 51 |
message(FATAL_ERROR "${lib} is required but not found") |
| 52 |
else() |
| 53 |
_internal_message("${lib} not found") |
| 54 |
endif() |
| 55 |
endif() |
| 56 |
endif() |
| 57 |
endmacro() |
| 58 |
|