2019-06-25 05:21:31 +00:00
|
|
|
# This script only supports the following components of XCB
|
2019-06-15 15:12:57 +00:00
|
|
|
set(XCB_known_components
|
|
|
|
XCB
|
|
|
|
RANDR
|
|
|
|
COMPOSITE
|
|
|
|
XKB
|
|
|
|
XRM
|
|
|
|
CURSOR)
|
|
|
|
|
2019-06-25 05:21:31 +00:00
|
|
|
# Deducing header from the name of the component
|
2019-06-15 15:12:57 +00:00
|
|
|
foreach(_comp ${XCB_known_components})
|
|
|
|
string(TOLOWER "${_comp}" _lc_comp)
|
|
|
|
set(XCB_${_comp}_pkg_config "xcb-${_lc_comp}")
|
|
|
|
set(XCB_${_comp}_header "xcb/${_lc_comp}.h")
|
|
|
|
endforeach()
|
2019-06-25 05:21:31 +00:00
|
|
|
# Exception cases
|
2019-06-15 15:12:57 +00:00
|
|
|
set(XCB_XRM_header "xcb/xcb_xrm.h")
|
|
|
|
set(XCB_CURSOR_header "xcb/xcb_cursor.h")
|
|
|
|
|
2019-06-25 05:21:31 +00:00
|
|
|
cmake_policy(PUSH)
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
2019-06-15 15:12:57 +00:00
|
|
|
|
|
|
|
foreach(_comp ${Xcb_FIND_COMPONENTS})
|
|
|
|
if (NOT ${_comp} IN_LIST XCB_known_components)
|
|
|
|
cmake_policy(POP)
|
2019-06-25 05:21:31 +00:00
|
|
|
message(FATAL_ERROR "Unknow component \"${_comp}\" of XCB")
|
2019-06-15 15:12:57 +00:00
|
|
|
endif()
|
|
|
|
|
2019-06-25 05:21:31 +00:00
|
|
|
find_package_impl(${XCB_${_comp}_pkg_config} "Xcb_${_comp}" "${XCB_${_comp}_header}")
|
2019-06-15 15:12:57 +00:00
|
|
|
|
|
|
|
if(Xcb_${_comp}_FOUND AND NOT TARGET Xcb::${_comp})
|
2019-06-25 05:21:31 +00:00
|
|
|
create_imported_target("Xcb::${_comp}" "${Xcb_${_comp}_INCLUDE_DIRS}" "${Xcb_${_comp}_LIBRARIES}")
|
2019-06-15 15:12:57 +00:00
|
|
|
elseif(NOT Xcb_${_comp}_FOUND AND Xcb_FIND_REQUIRED)
|
2019-06-25 05:21:31 +00:00
|
|
|
cmake_policy(POP)
|
|
|
|
message(FATAL_ERROR "Xcb: Required component \"${_comp}\" is not found")
|
2019-06-15 15:12:57 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
cmake_policy(POP)
|