mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Make the cmake check_lib macro more versatile. It first tries pkg-config, and if that fails it then check for libraries and required headers. Also cleaned up the output a little bit.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6544 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,34 +1,64 @@
|
||||
macro(check_lib var lib required)
|
||||
pkg_search_module(${var} ${lib})
|
||||
include(FindPkgConfig OPTIONAL)
|
||||
|
||||
macro(_internal_message msg _quiet)
|
||||
if(NOT _quiet)
|
||||
message("${msg}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_lib var lib)
|
||||
set(_is_required 0)
|
||||
set(_is_quiet 0)
|
||||
foreach(_arg ${ARGN})
|
||||
if(_arg STREQUAL "REQUIRED")
|
||||
set(_is_required 1)
|
||||
endif()
|
||||
if(_arg STREQUAL "QUIET")
|
||||
set(_is_quiet 1)
|
||||
endif()
|
||||
endforeach()
|
||||
if(ARGN)
|
||||
list(REMOVE_ITEM ${ARGN} "REQUIRED")
|
||||
list(REMOVE_ITEM ${ARGN} "QUIET")
|
||||
endif()
|
||||
|
||||
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND)
|
||||
string(TOLOWER ${lib} lower_lib)
|
||||
pkg_search_module(${var} QUIET ${lower_lib})
|
||||
endif()
|
||||
|
||||
if(${var}_FOUND)
|
||||
message("${lib} found")
|
||||
_internal_message("${lib} found" _is_quiet)
|
||||
else()
|
||||
find_library(${var} ${lib})
|
||||
if(${var})
|
||||
message("${lib} found")
|
||||
foreach(_file ${ARGN})
|
||||
find_path(${var}_INCLUDE ${_file})
|
||||
endforeach()
|
||||
if(${var} AND ${var}_INCLUDE)
|
||||
_internal_message("${lib} found" _is_quiet)
|
||||
set(${var}_FOUND 1 CACHE INTERNAL "")
|
||||
else()
|
||||
if(${required} STREQUAL "REQUIRED")
|
||||
if(_is_required)
|
||||
message(FATAL_ERROR "${lib} is required but not found")
|
||||
else()
|
||||
message("${lib} not found")
|
||||
_internal_message("${lib} not found" _is_quiet)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_lib_and_header var lib header required)
|
||||
find_library(${var} ${lib})
|
||||
find_path(${var}_INCLUDE ${header})
|
||||
if(${var} AND ${var}_INCLUDE)
|
||||
message("${lib} found")
|
||||
set(${var}_FOUND 1 CACHE INTERNAL "")
|
||||
macro(check_libav)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBAV libavcodec>=52.72.2 libavformat>=52.64.2
|
||||
libswscale>=0.11.0 libavutil>=50.15.1)
|
||||
else()
|
||||
if(${required} STREQUAL "REQUIRED")
|
||||
message(FATAL_ERROR "${lib} is required but not found")
|
||||
else()
|
||||
message("${lib} not found")
|
||||
endif()
|
||||
message("pkg-config is required to check for libav")
|
||||
endif()
|
||||
if(LIBAV_FOUND)
|
||||
message("libav found, enabling AVI frame dumps")
|
||||
add_definitions(-DHAVE_LIBAV)
|
||||
else()
|
||||
message("libav not found, disabling AVI frame dumps")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
Reference in New Issue
Block a user