Only build WSI support for XCB surfaces when xcb.h is found

Previously we built with VK_USE_PLATFORM_XCB_KHR when the XCB library
was found, but some systems may have it without having the header
available.

This change enables VK_USE_PLATFORM_XCB_KHR when the header is found,
regardless of whether the library is found. Note that the latter still
gets dynamically checked for at run-time before we expose the
VK_KHR_xcb_surface extension.

A warning is emitted on Linux builds if xcb/xcb.h is not found since
XCB is the main WSI integration on this platform and it's typically a
build system setup bug if the libx11-xcb-dev package was not installed.

Bug: b/209030951
Change-Id: Ifa7bd23c99245025182100412d36f3d3cb3258b2
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/64730
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Mikael Pessa <mikaelpessa@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Commit-Queue: Nicolas Capens <nicolascapens@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8192d87..7049995 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,13 +105,19 @@
 # Host libraries
 ###########################################################
 
-include(CheckSymbolExists)
 if(LINUX)
+    include(CheckSymbolExists)
     check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
     check_symbol_exists(mallinfo2 malloc.h HAVE_MALLINFO2)
+
+    include(CheckIncludeFiles)
+    CHECK_INCLUDE_FILES("xcb/xcb.h" HAVE_XCB_H)
+    if(NOT HAVE_XCB_H)
+        message(WARNING "xcb/xcb.h was not found. Install the libx11-xcb-dev package "
+                        "to build with WSI support for XCB surfaces.")
+    endif()
 endif()
 
-find_library(XCB xcb)
 if(SWIFTSHADER_BUILD_WSI_WAYLAND)
     find_library(WAYLAND wayland-client)
 endif(SWIFTSHADER_BUILD_WSI_WAYLAND)
@@ -792,7 +798,7 @@
 if(WIN32)
     target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WIN32_KHR")
 elseif(LINUX)
-    if(XCB)
+    if(HAVE_XCB_H)
         target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XCB_KHR")
     endif()
     if(SWIFTSHADER_BUILD_WSI_WAYLAND)
diff --git a/src/WSI/CMakeLists.txt b/src/WSI/CMakeLists.txt
index 0e14f95..f324582 100644
--- a/src/WSI/CMakeLists.txt
+++ b/src/WSI/CMakeLists.txt
@@ -32,7 +32,7 @@
         Win32SurfaceKHR.hpp
     )
 elseif(LINUX)
-    if(XCB)
+    if(HAVE_XCB_H)
         list(APPEND WSI_SRC_FILES
             XcbSurfaceKHR.cpp
             XcbSurfaceKHR.hpp