Skip to content

Commit

Permalink
Added FindXCB.
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Apr 20, 2021
1 parent e9d5941 commit b292b6a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ if (NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message( FATAL_ERROR "Only 64 bit builds supported." )
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

include("cmake/compiler.cmake")

find_package(Threads REQUIRED)
Expand Down
51 changes: 51 additions & 0 deletions cmake/FindXCB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# - FindXCB
#
# Copyright 2015 Valve Coporation

find_package(PkgConfig)

if(NOT XCB_FIND_COMPONENTS)
set(XCB_FIND_COMPONENTS xcb)
endif()

include(FindPackageHandleStandardArgs)
set(XCB_FOUND true)
set(XCB_INCLUDE_DIRS "")
set(XCB_LIBRARIES "")
foreach(comp ${XCB_FIND_COMPONENTS})
# component name
string(TOUPPER ${comp} compname)
string(REPLACE "-" "_" compname ${compname})
# header name
string(REPLACE "xcb-" "" headername xcb/${comp}.h)
# library name
set(libname ${comp})

pkg_check_modules(PC_${comp} QUIET ${comp})

find_path(${compname}_INCLUDE_DIR NAMES ${headername}
HINTS
${PC_${comp}_INCLUDEDIR}
${PC_${comp}_INCLUDE_DIRS}
)

find_library(${compname}_LIBRARY NAMES ${libname}
HINTS
${PC_${comp}_LIBDIR}
${PC_${comp}_LIBRARY_DIRS}
)

find_package_handle_standard_args(${comp}
FOUND_VAR ${comp}_FOUND
REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY)
mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY)

list(APPEND XCB_INCLUDE_DIRS ${${compname}_INCLUDE_DIR})
list(APPEND XCB_LIBRARIES ${${compname}_LIBRARY})

if(NOT ${comp}_FOUND)
set(XCB_FOUND false)
endif()
endforeach()

list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS)

0 comments on commit b292b6a

Please sign in to comment.