1 # - FindXCB 2 # 3 # Copyright (C) 2015 Valve Corporation 4 5 find_package(PkgConfig) 6 7 if(NOT XCB_FIND_COMPONENTS) 8 set(XCB_FIND_COMPONENTS xcb) 9 endif() 10 11 include(FindPackageHandleStandardArgs) 12 set(XCB_FOUND true) 13 set(XCB_INCLUDE_DIRS "") 14 set(XCB_LIBRARIES "") 15 foreach(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 find_package_handle_standard_args(${comp} 39 FOUND_VAR ${comp}_FOUND 40 REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY) 41 mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY) 42 43 list(APPEND XCB_INCLUDE_DIRS ${${compname}_INCLUDE_DIR}) 44 list(APPEND XCB_LIBRARIES ${${compname}_LIBRARY}) 45 46 if(NOT ${comp}_FOUND) 47 set(XCB_FOUND false) 48 endif() 49 endforeach() 50 51 list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS) 52