2014-08-04 16:05:13 +00:00
|
|
|
include(FindPkgConfig OPTIONAL)
|
|
|
|
|
|
|
|
macro(_internal_message msg)
|
|
|
|
message("${msg}")
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(check_lib var lib)
|
|
|
|
set(_arg_list ${ARGN})
|
|
|
|
|
2014-12-28 03:15:08 +00:00
|
|
|
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND AND NOT CMAKE_CROSSCOMPILING)
|
2014-08-04 16:05:13 +00:00
|
|
|
string(TOLOWER ${lib} lower_lib)
|
|
|
|
pkg_search_module(${var} QUIET ${lower_lib})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${var}_FOUND)
|
|
|
|
include_directories(${${var}_INCLUDE_DIRS})
|
|
|
|
# Make sure include directories for headers found using find_path below
|
|
|
|
# are re-added when reconfiguring
|
|
|
|
include_directories(${${var}_INCLUDE})
|
2014-09-24 07:00:35 +00:00
|
|
|
_internal_message("-- ${lib} found")
|
2014-08-04 16:05:13 +00:00
|
|
|
else()
|
2014-09-24 07:00:35 +00:00
|
|
|
find_library(${var}_LIBRARIES ${lib})
|
2014-08-04 16:05:13 +00:00
|
|
|
if(_arg_list)
|
|
|
|
find_path(${var}_INCLUDE ${_arg_list})
|
|
|
|
else()
|
|
|
|
set(${var}_INCLUDE FALSE)
|
|
|
|
endif()
|
2014-09-24 07:00:35 +00:00
|
|
|
if(${var}_LIBRARIES AND ${var}_INCLUDE)
|
2014-08-04 16:05:13 +00:00
|
|
|
include_directories(${${var}_INCLUDE})
|
2014-09-24 07:00:35 +00:00
|
|
|
_internal_message("-- ${lib} found")
|
2014-08-04 16:05:13 +00:00
|
|
|
set(${var}_FOUND 1 CACHE INTERNAL "")
|
2014-12-07 21:06:39 +00:00
|
|
|
elseif(${var}_LIBRARIES)
|
|
|
|
_internal_message("-- ${lib} not found (miss include)")
|
|
|
|
elseif(${var}_INCLUDE)
|
|
|
|
_internal_message("-- ${lib} not found (miss lib)")
|
|
|
|
else()
|
2014-09-24 07:00:35 +00:00
|
|
|
_internal_message("-- ${lib} not found")
|
2014-08-04 16:05:13 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|