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})
|
|
|
|
|
2023-12-30 04:24:09 +00:00
|
|
|
if(PKG_CONFIG_FOUND AND NOT DEFINED pcsx2_manually_found_${var})
|
2014-08-04 16:05:13 +00:00
|
|
|
string(TOLOWER ${lib} lower_lib)
|
2021-04-17 20:30:03 +00:00
|
|
|
pkg_search_module(${var} QUIET IMPORTED_TARGET ${lower_lib})
|
2014-08-04 16:05:13 +00:00
|
|
|
endif()
|
|
|
|
|
2021-04-17 20:30:03 +00:00
|
|
|
if(TARGET PkgConfig::${var})
|
2017-02-03 22:30:25 +00:00
|
|
|
_internal_message("-- ${var} found pkg")
|
2014-08-04 16:05:13 +00:00
|
|
|
else()
|
2021-07-04 05:24:21 +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()
|
2017-02-03 22:30:25 +00:00
|
|
|
|
2021-07-04 05:24:21 +00:00
|
|
|
if(${var}_LIBRARIES AND ${var}_INCLUDE)
|
2021-04-17 20:30:03 +00:00
|
|
|
add_library(PkgConfig::${var} UNKNOWN IMPORTED GLOBAL)
|
|
|
|
# Imitate what pkg-config would have found
|
|
|
|
set_target_properties(PkgConfig::${var} PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${${var}_LIBRARIES}"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${${var}_INCLUDE}"
|
|
|
|
)
|
2021-07-04 05:24:21 +00:00
|
|
|
_internal_message("-- ${var} found")
|
|
|
|
set(${var}_FOUND 1 CACHE INTERNAL "")
|
2021-07-20 03:18:08 +00:00
|
|
|
set(pcsx2_manually_found_${var} 1 CACHE INTERNAL "")
|
2021-07-04 05:24:21 +00:00
|
|
|
elseif(${var}_LIBRARIES)
|
|
|
|
_internal_message("-- ${var} not found (miss include)")
|
|
|
|
elseif(${var}_INCLUDE)
|
|
|
|
_internal_message("-- ${var} not found (miss lib)")
|
|
|
|
else()
|
|
|
|
_internal_message("-- ${var} not found")
|
|
|
|
endif()
|
2014-08-04 16:05:13 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|