2017-01-17 21:32:55 +01:00
|
|
|
find_package(PkgConfig)
|
2010-12-10 03:00:05 +01:00
|
|
|
|
2010-12-13 06:29:13 +01:00
|
|
|
macro(_internal_message msg)
|
|
|
|
if(NOT ${_is_quiet})
|
2017-01-17 21:47:24 +01:00
|
|
|
message(STATUS "${msg}")
|
2010-12-10 03:00:05 +01:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-06-03 00:00:50 +02:00
|
|
|
macro(check_lib var pc lib)
|
2010-12-10 03:00:05 +01:00
|
|
|
set(_is_required 0)
|
|
|
|
set(_is_quiet 0)
|
2010-12-13 06:29:13 +01:00
|
|
|
set(_arg_list ${ARGN})
|
2010-12-10 03:00:05 +01:00
|
|
|
foreach(_arg ${ARGN})
|
|
|
|
if(_arg STREQUAL "REQUIRED")
|
2010-12-13 06:29:13 +01:00
|
|
|
list(REMOVE_ITEM _arg_list "REQUIRED")
|
2010-12-10 03:00:05 +01:00
|
|
|
set(_is_required 1)
|
|
|
|
endif()
|
|
|
|
if(_arg STREQUAL "QUIET")
|
2010-12-13 06:29:13 +01:00
|
|
|
list(REMOVE_ITEM _arg_list "QUIET")
|
2010-12-10 03:00:05 +01:00
|
|
|
set(_is_quiet 1)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND)
|
2015-06-03 00:00:50 +02:00
|
|
|
pkg_search_module(${var} QUIET ${pc})
|
2010-12-10 03:00:05 +01:00
|
|
|
endif()
|
|
|
|
|
2010-11-12 06:05:27 +01:00
|
|
|
if(${var}_FOUND)
|
2017-01-17 17:47:19 +01:00
|
|
|
if(${var}_INCLUDE_DIRS)
|
|
|
|
include_directories(${${var}_INCLUDE_DIRS})
|
|
|
|
endif()
|
2010-12-13 06:29:13 +01:00
|
|
|
# Make sure include directories for headers found using find_path below
|
|
|
|
# are re-added when reconfiguring
|
2017-01-17 17:47:19 +01:00
|
|
|
if(${var}_INCLUDE)
|
|
|
|
include_directories(${${var}_INCLUDE})
|
|
|
|
endif()
|
2010-12-13 06:29:13 +01:00
|
|
|
_internal_message("${lib} found")
|
2010-11-12 06:05:27 +01:00
|
|
|
else()
|
|
|
|
find_library(${var} ${lib})
|
2010-12-15 00:19:34 +01:00
|
|
|
if(_arg_list)
|
|
|
|
find_path(${var}_INCLUDE ${_arg_list})
|
|
|
|
else()
|
|
|
|
set(${var}_INCLUDE FALSE)
|
|
|
|
endif()
|
2010-12-10 03:00:05 +01:00
|
|
|
if(${var} AND ${var}_INCLUDE)
|
2010-12-13 06:29:13 +01:00
|
|
|
include_directories(${${var}_INCLUDE})
|
|
|
|
_internal_message("${lib} found")
|
2010-11-12 06:05:27 +01:00
|
|
|
set(${var}_FOUND 1 CACHE INTERNAL "")
|
|
|
|
else()
|
2010-12-10 03:00:05 +01:00
|
|
|
if(_is_required)
|
2010-11-12 06:05:27 +01:00
|
|
|
message(FATAL_ERROR "${lib} is required but not found")
|
|
|
|
else()
|
2010-12-13 06:29:13 +01:00
|
|
|
_internal_message("${lib} not found")
|
2010-11-12 06:05:27 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|