1# - FindXCB 2# 3# Copyright (C) 2015 Valve Corporation 4 5find_package(PkgConfig) 6 7if(NOT XCB_FIND_COMPONENTS) 8 set(XCB_FIND_COMPONENTS xcb) 9endif() 10 11include(FindPackageHandleStandardArgs) 12set(XCB_FOUND true) 13set(XCB_INCLUDE_DIRS "") 14set(XCB_LIBRARIES "") 15foreach(comp ${XCB_FIND_COMPONENTS}) 16 # component name 17 string(TOUPPER ${comp} compname) 18 string(REPLACE "-" "_" compname ${compname}) 19 # header name 20 string(REPLACE "xcb-" "" headername xcb/${comp}.h) 21 # library name 22 set(libname ${comp}) 23 24 pkg_check_modules(PC_${comp} QUIET ${comp}) 25 26 find_path(${compname}_INCLUDE_DIR NAMES ${headername} 27 HINTS 28 ${PC_${comp}_INCLUDEDIR} 29 ${PC_${comp}_INCLUDE_DIRS} 30 ) 31 32 find_library(${compname}_LIBRARY NAMES ${libname} 33 HINTS 34 ${PC_${comp}_LIBDIR} 35 ${PC_${comp}_LIBRARY_DIRS} 36 ) 37 38 set(FPHSA_NAME_MISMATCHED TRUE) 39 find_package_handle_standard_args(${comp} 40 FOUND_VAR ${comp}_FOUND 41 REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY) 42 unset(FPHSA_NAME_MISMATCHED) 43 44 mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY) 45 46 list(APPEND XCB_INCLUDE_DIRS ${${compname}_INCLUDE_DIR}) 47 list(APPEND XCB_LIBRARIES ${${compname}_LIBRARY}) 48 49 if(NOT ${comp}_FOUND) 50 set(XCB_FOUND false) 51 endif() 52endforeach() 53 54list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS) 55