code:
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindVulkan
----------

.. versionadded:: 3.7

Find Vulkan, which is a low-overhead, cross-platform 3D graphics
and computing API.

Optional COMPONENTS
^^^^^^^^^^^^^^^^^^^

.. versionadded:: 3.24

This module respects several optional COMPONENTS.
There are corresponding imported targets for each of these.

``glslc``
  The SPIR-V compiler.

``glslangValidator``
  The ``glslangValidator`` tool.

``glslang``
  The SPIR-V generator library.

``shaderc_combined``
  The static library for Vulkan shader compilation.

``SPIRV-Tools``
  Tools to process SPIR-V modules.

``MoltenVK``
  On macOS, an additional component ``MoltenVK`` is available.

``dxc``
  .. versionadded:: 3.25

  The DirectX Shader Compiler.

The ``glslc`` and ``glslangValidator`` components are provided even
if not explicitly requested (for backward compatibility).

IMPORTED Targets
^^^^^^^^^^^^^^^^

This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found:

``Vulkan::Vulkan``
  The main Vulkan library.

``Vulkan::glslc``
  .. versionadded:: 3.19

  The GLSLC SPIR-V compiler, if it has been found.

``Vulkan::Headers``
  .. versionadded:: 3.21

  Provides just Vulkan headers include paths, if found.  No library is
  included in this target.  This can be useful for applications that
  load Vulkan library dynamically.

``Vulkan::glslangValidator``
  .. versionadded:: 3.21

  The glslangValidator tool, if found.  It is used to compile GLSL and
  HLSL shaders into SPIR-V.

``Vulkan::glslang``
  .. versionadded:: 3.24

  Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V
  generator library (glslang).

``Vulkan::shaderc_combined``
  .. versionadded:: 3.24

  Defined if SDK has the Google static library for Vulkan shader compilation
  (shaderc_combined).

``Vulkan::SPIRV-Tools``
  .. versionadded:: 3.24

  Defined if SDK has the Khronos library to process SPIR-V modules
  (SPIRV-Tools).

``Vulkan::MoltenVK``
  .. versionadded:: 3.24

  Defined if SDK has the Khronos library which implement a subset of Vulkan API
  over Apple Metal graphics framework. (MoltenVK).

``Vulkan::volk``
  .. versionadded:: 3.25

  Defined if SDK has the Vulkan meta-loader (volk).

``Vulkan::dxc_lib``
  .. versionadded:: 3.25

  Defined if SDK has the DirectX shader compiler library.

``Vulkan::dxc_exe``
  .. versionadded:: 3.25

  Defined if SDK has the DirectX shader compiler CLI tool.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``Vulkan_FOUND``
  set to true if Vulkan was found
``Vulkan_INCLUDE_DIRS``
  include directories for Vulkan
``Vulkan_LIBRARIES``
  link against this library to use Vulkan
``Vulkan_VERSION``
  .. versionadded:: 3.23

  value from ``vulkan/vulkan_core.h``
``Vulkan_glslc_FOUND``
  .. versionadded:: 3.24

  True, if the SDK has the glslc executable.
``Vulkan_glslangValidator_FOUND``
  .. versionadded:: 3.24

  True, if the SDK has the glslangValidator executable.
``Vulkan_glslang_FOUND``
  .. versionadded:: 3.24

  True, if the SDK has the glslang library.
``Vulkan_shaderc_combined_FOUND``
  .. versionadded:: 3.24

  True, if the SDK has the shaderc_combined library.
``Vulkan_SPIRV-Tools_FOUND``
  .. versionadded:: 3.24

  True, if the SDK has the SPIRV-Tools library.
``Vulkan_MoltenVK_FOUND``
  .. versionadded:: 3.24

  True, if the SDK has the MoltenVK library.
``Vulkan_volk_FOUND``
  .. versionadded:: 3.25

  True, if the SDK has the volk library.

``Vulkan_dxc_lib_FOUND``
  .. versionadded:: 3.25

  True, if the SDK has the DirectX shader compiler library.

``Vulkan_dxc_exe_FOUND``
  .. versionadded:: 3.25

  True, if the SDK has the DirectX shader compiler CLI tool.

The module will also defines these cache variables:

``Vulkan_INCLUDE_DIR``
  the Vulkan include directory
``Vulkan_LIBRARY``
  the path to the Vulkan library
``Vulkan_GLSLC_EXECUTABLE``
  the path to the GLSL SPIR-V compiler
``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE``
  the path to the glslangValidator tool
``Vulkan_glslang_LIBRARY``
  .. versionadded:: 3.24

  Path to the glslang library.
``Vulkan_shaderc_combined_LIBRARY``
  .. versionadded:: 3.24

  Path to the shaderc_combined library.
``Vulkan_SPIRV-Tools_LIBRARY``
  .. versionadded:: 3.24

  Path to the SPIRV-Tools library.
``Vulkan_MoltenVK_LIBRARY``
  .. versionadded:: 3.24

  Path to the MoltenVK library.

``Vulkan_volk_LIBRARY``
  .. versionadded:: 3.25

  Path to the volk library.

``Vulkan_dxc_LIBRARY``
  .. versionadded:: 3.25

  Path to the DirectX shader compiler library.

``Vulkan_dxc_EXECUTABLE``
  .. versionadded:: 3.25

  Path to the DirectX shader compiler CLI tool.

Hints
^^^^^

.. versionadded:: 3.18

The ``VULKAN_SDK`` environment variable optionally specifies the
location of the Vulkan SDK root directory for the given
architecture. It is typically set by sourcing the toplevel
``setup-env.sh`` script of the Vulkan SDK directory into the shell
environment.

#]=======================================================================]

cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW)

# Provide compatibility with a common invalid component request that
# was silently ignored prior to CMake 3.24.
if("FATAL_ERROR" IN_LIST Vulkan_FIND_COMPONENTS)
  message(AUTHOR_WARNING
    "Ignoring unknown component 'FATAL_ERROR'.\n"
    "The find_package() command documents no such argument."
    )
  list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR")
endif()

# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc`
# and `glslangValidator` without requesting the corresponding component.
if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS)
  list(APPEND Vulkan_FIND_COMPONENTS glslc)
endif()
if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
  list(APPEND Vulkan_FIND_COMPONENTS glslangValidator)
endif()

if(WIN32)
  set(_Vulkan_library_name vulkan-1)
  set(_Vulkan_hint_include_search_paths
    "$ENV{VULKAN_SDK}/include"
  )
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
    set(_Vulkan_hint_executable_search_paths
      "$ENV{VULKAN_SDK}/bin"
    )
    set(_Vulkan_hint_library_search_paths
      "$ENV{VULKAN_SDK}/lib"
      "$ENV{VULKAN_SDK}/bin"
    )
  else()
    set(_Vulkan_hint_executable_search_paths
      "$ENV{VULKAN_SDK}/bin32"
      "$ENV{VULKAN_SDK}/bin"
    )
    set(_Vulkan_hint_library_search_paths
      "$ENV{VULKAN_SDK}/lib32"
      "$ENV{VULKAN_SDK}/bin32"
      "$ENV{VULKAN_SDK}/lib"
      "$ENV{VULKAN_SDK}/bin"
    )
  endif()
else()
  set(_Vulkan_library_name vulkan)
  set(_Vulkan_hint_include_search_paths
    "$ENV{VULKAN_SDK}/include"
  )
  set(_Vulkan_hint_executable_search_paths
    "$ENV{VULKAN_SDK}/bin"
  )
  set(_Vulkan_hint_library_search_paths
    "$ENV{VULKAN_SDK}/lib"
  )
endif()
if(APPLE AND DEFINED ENV{VULKAN_SDK})
  cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK")
  if(EXISTS "${_MoltenVK_path}")
    list(APPEND _Vulkan_hint_include_search_paths
      "${_MoltenVK_path}/include"
    )
    if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
      list(APPEND _Vulkan_hint_library_search_paths
        "${_MoltenVK_path}/dylib/iOS"
      )
    elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
      list(APPEND _Vulkan_hint_library_search_paths
        "${_MoltenVK_path}/dylib/tvOS"
      )
    else()
      list(APPEND _Vulkan_hint_library_search_paths
        "${_MoltenVK_path}/dylib/macOS"
      )
    endif()
  endif()
  unset(_MoltenVK_path)
endif()

find_path(Vulkan_INCLUDE_DIR
  NAMES vulkan/vulkan.h
  HINTS
    ${_Vulkan_hint_include_search_paths}
  )
mark_as_advanced(Vulkan_INCLUDE_DIR)

find_library(Vulkan_LIBRARY
  NAMES ${_Vulkan_library_name}
  HINTS
    ${_Vulkan_hint_library_search_paths}
  )
mark_as_advanced(Vulkan_LIBRARY)

if(glslc IN_LIST Vulkan_FIND_COMPONENTS)
  find_program(Vulkan_GLSLC_EXECUTABLE
    NAMES glslc
    HINTS
      ${_Vulkan_hint_executable_search_paths}
    )
  mark_as_advanced(Vulkan_GLSLC_EXECUTABLE)
endif()
if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
  find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE
    NAMES glslangValidator
    HINTS
      ${_Vulkan_hint_executable_search_paths}
    )
  mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
endif()
if(glslang IN_LIST Vulkan_FIND_COMPONENTS)
  find_library(Vulkan_glslang-spirv_LIBRARY
    NAMES SPIRV
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-spirv_LIBRARY)

  find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY
    NAMES SPIRVd
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY)

  find_library(Vulkan_glslang-oglcompiler_LIBRARY
    NAMES OGLCompiler
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY)

  find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY
    NAMES OGLCompilerd
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)

  find_library(Vulkan_glslang-osdependent_LIBRARY
    NAMES OSDependent
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY)

  find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY
    NAMES OSDependentd
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY)

  find_library(Vulkan_glslang-machineindependent_LIBRARY
    NAMES MachineIndependent
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY)

  find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY
    NAMES MachineIndependentd
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)

  find_library(Vulkan_glslang-genericcodegen_LIBRARY
    NAMES GenericCodeGen
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY)

  find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY
    NAMES GenericCodeGend
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)

  find_library(Vulkan_glslang_LIBRARY
    NAMES glslang
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang_LIBRARY)

  find_library(Vulkan_glslang_DEBUG_LIBRARY
    NAMES glslangd
    HINTS
      ${_Vulkan_hint_library_search_paths}
    )
  mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY)
endif()
if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS)
  find_library(Vulkan_shaderc_combined_LIBRARY
    NAMES shaderc_combined
    HINTS
    ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_shaderc_combined_LIBRARY)

  find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY
    NAMES shaderc_combinedd
    HINTS
    ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY)
endif()
if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS)
  find_library(Vulkan_SPIRV-Tools_LIBRARY
    NAMES SPIRV-Tools
    HINTS
      ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY)

  find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY
    NAMES SPIRV-Toolsd
    HINTS
      ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
endif()
if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS)
  find_library(Vulkan_MoltenVK_LIBRARY
    NAMES MoltenVK
    HINTS
      ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_MoltenVK_LIBRARY)

  find_path(Vulkan_MoltenVK_INCLUDE_DIR
    NAMES MoltenVK/mvk_vulkan.h
    HINTS
      ${_Vulkan_hint_include_search_paths}
    )
  mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR)
endif()
if(volk IN_LIST Vulkan_FIND_COMPONENTS)
  find_library(Vulkan_volk_LIBRARY
          NAMES volk
          HINTS
            ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_Volk_LIBRARY)
endif()

if (dxc IN_LIST Vulkan_FIND_COMPONENTS)
  find_library(Vulkan_dxc_LIBRARY
          NAMES dxcompiler
          HINTS
            ${_Vulkan_hint_library_search_paths})
  mark_as_advanced(Vulkan_dxc_LIBRARY)

  find_program(Vulkan_dxc_EXECUTABLE
          NAMES dxc
          HINTS
            ${_Vulkan_hint_executable_search_paths})
  mark_as_advanced(Vulkan_dxc_EXECUTABLE)
endif()

if(Vulkan_GLSLC_EXECUTABLE)
  set(Vulkan_glslc_FOUND TRUE)
else()
  set(Vulkan_glslc_FOUND FALSE)
endif()

if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
  set(Vulkan_glslangValidator_FOUND TRUE)
else()
  set(Vulkan_glslangValidator_FOUND FALSE)
endif()

if (Vulkan_dxc_EXECUTABLE)
  set(Vulkan_dxc_exe_FOUND TRUE)
else()
  set(Vulkan_dxc_exe_FOUND FALSE)
endif()

function(_Vulkan_set_library_component_found component)
  cmake_parse_arguments(PARSE_ARGV 1 _ARG
    "NO_WARNING"
    ""
    "DEPENDENT_COMPONENTS")

  set(all_dependent_component_found TRUE)
  foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS)
    if(NOT Vulkan_${dependent_component}_FOUND)
      set(all_dependent_component_found FALSE)
      break()
    endif()
  endforeach()

  if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY))
    set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE)

    # For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI:
    #   - Release binaries uses a runtime library
    #   - Debug binaries uses a debug runtime library
    # This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI.
    if(WIN32 AND NOT _ARG_NO_WARNING)
      if(NOT Vulkan_${component}_LIBRARY)
        message(WARNING
"Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.")
      endif()
      if(NOT Vulkan_${component}_DEBUG_LIBRARY)
        message(WARNING
"Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.")
      endif()
    endif()
  else()
    set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE)
  endif()
endfunction()

_Vulkan_set_library_component_found(glslang-spirv NO_WARNING)
_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING)
_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING)
_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING)
_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING)
_Vulkan_set_library_component_found(glslang DEPENDENT_COMPONENTS glslang-spirv)
_Vulkan_set_library_component_found(shaderc_combined)
_Vulkan_set_library_component_found(SPIRV-Tools)
_Vulkan_set_library_component_found(volk)
_Vulkan_set_library_component_found(dxc)

if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY)
  set(Vulkan_MoltenVK_FOUND TRUE)
else()
  set(Vulkan_MoltenVK_FOUND FALSE)
endif()

set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})

# detect version e.g 1.2.189
set(Vulkan_VERSION "")
if(Vulkan_INCLUDE_DIR)
  set(VULKAN_CORE_H ${Vulkan_INCLUDE_DIR}/vulkan/vulkan_core.h)
  if(EXISTS ${VULKAN_CORE_H})
    file(STRINGS  ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ")
    string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}")
    file(STRINGS  ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ")
    string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}")
    list(LENGTH VulkanHeaderVersion2 _len)
    #  versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2'
    if(_len EQUAL 3)
        list(REMOVE_AT VulkanHeaderVersion2 0)
    endif()
    list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion})
    list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION)
  endif()
endif()

if(Vulkan_MoltenVK_FOUND)
  set(Vulkan_MoltenVK_VERSION "")
  if(Vulkan_MoltenVK_INCLUDE_DIR)
    set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h)
    if(EXISTS ${VK_MVK_MOLTENVK_H})
      file(STRINGS  ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ")
      string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}")
      file(STRINGS  ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ")
      string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}")
      file(STRINGS  ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ")
      string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}")
      set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}")
      unset(_Vulkan_MoltenVK_VERSION_MAJOR)
      unset(_Vulkan_MoltenVK_VERSION_MINOR)
      unset(_Vulkan_MoltenVK_VERSION_PATCH)
    endif()
  endif()
endif()

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(Vulkan
  REQUIRED_VARS
    Vulkan_LIBRARY
    Vulkan_INCLUDE_DIR
  VERSION_VAR
    Vulkan_VERSION
  HANDLE_COMPONENTS
)

if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan)
  add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
  set_target_properties(Vulkan::Vulkan PROPERTIES
    IMPORTED_LOCATION "${Vulkan_LIBRARIES}"
    INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
endif()

if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers)
  add_library(Vulkan::Headers INTERFACE IMPORTED)
  set_target_properties(Vulkan::Headers PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
endif()

if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc)
  add_executable(Vulkan::glslc IMPORTED)
  set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}")
endif()

if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator)
  add_executable(Vulkan::glslangValidator IMPORTED)
  set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}")
endif()

if(Vulkan_FOUND)
  if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv)
    add_library(Vulkan::glslang-spirv STATIC IMPORTED)
    set_property(TARGET Vulkan::glslang-spirv
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_glslang-spirv_LIBRARY)
      set_property(TARGET Vulkan::glslang-spirv APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::glslang-spirv
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}")
    endif()
    if(Vulkan_glslang-spirv_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::glslang-spirv APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::glslang-spirv
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}")
    endif()
  endif()

  if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler)
    add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED)
    set_property(TARGET Vulkan::glslang-oglcompiler
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_glslang-oglcompiler_LIBRARY)
      set_property(TARGET Vulkan::glslang-oglcompiler APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::glslang-oglcompiler
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}")
    endif()
    if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::glslang-oglcompiler APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::glslang-oglcompiler
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}")
    endif()
  endif()

  if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent)
    add_library(Vulkan::glslang-osdependent STATIC IMPORTED)
    set_property(TARGET Vulkan::glslang-osdependent
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_glslang-osdependent_LIBRARY)
      set_property(TARGET Vulkan::glslang-osdependent APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::glslang-osdependent
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}")
    endif()
    if(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::glslang-osdependent APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::glslang-osdependent
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}")
    endif()
  endif()

  if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent)
    add_library(Vulkan::glslang-machineindependent STATIC IMPORTED)
    set_property(TARGET Vulkan::glslang-machineindependent
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_glslang-machineindependent_LIBRARY)
      set_property(TARGET Vulkan::glslang-machineindependent APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::glslang-machineindependent
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}")
    endif()
    if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::glslang-machineindependent APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::glslang-machineindependent
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}")
    endif()
  endif()

  if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen)
    add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED)
    set_property(TARGET Vulkan::glslang-genericcodegen
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_glslang-genericcodegen_LIBRARY)
      set_property(TARGET Vulkan::glslang-genericcodegen APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::glslang-genericcodegen
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}")
    endif()
    if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::glslang-genericcodegen APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::glslang-genericcodegen
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}")
    endif()
  endif()

  if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY)
      AND TARGET Vulkan::glslang-spirv
      AND NOT TARGET Vulkan::glslang)
    add_library(Vulkan::glslang STATIC IMPORTED)
    set_property(TARGET Vulkan::glslang
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_glslang_LIBRARY)
      set_property(TARGET Vulkan::glslang APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::glslang
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}")
    endif()
    if(Vulkan_glslang_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::glslang APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::glslang
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}")
    endif()
    target_link_libraries(Vulkan::glslang
      INTERFACE
        Vulkan::glslang-spirv
        # OGLCompiler library has been fully removed since version 14.0.0
        # OSDependent, MachineIndependent, and GenericCodeGen may also be removed in the future.
        # See https://github.com/KhronosGroup/glslang/issues/3462
        $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-oglcompiler>
        $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-osdependent>
        $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-machineindependent>
        $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-genericcodegen>
    )
  endif()

  if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined)
    add_library(Vulkan::shaderc_combined STATIC IMPORTED)
    set_property(TARGET Vulkan::shaderc_combined
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_shaderc_combined_LIBRARY)
      set_property(TARGET Vulkan::shaderc_combined APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::shaderc_combined
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}")
    endif()
    if(Vulkan_shaderc_combined_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::shaderc_combined APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::shaderc_combined
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}")
    endif()

    if(UNIX)
      find_package(Threads REQUIRED)
      target_link_libraries(Vulkan::shaderc_combined
        INTERFACE
          Threads::Threads)
    endif()
  endif()

  if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools)
    add_library(Vulkan::SPIRV-Tools STATIC IMPORTED)
    set_property(TARGET Vulkan::SPIRV-Tools
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    if(Vulkan_SPIRV-Tools_LIBRARY)
      set_property(TARGET Vulkan::SPIRV-Tools APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Release)
      set_property(TARGET Vulkan::SPIRV-Tools
        PROPERTY
          IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}")
    endif()
    if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
      set_property(TARGET Vulkan::SPIRV-Tools APPEND
        PROPERTY
          IMPORTED_CONFIGURATIONS Debug)
      set_property(TARGET Vulkan::SPIRV-Tools
        PROPERTY
          IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}")
    endif()
  endif()

  if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk)
    add_library(Vulkan::volk STATIC IMPORTED)
    set_property(TARGET Vulkan::volk
            PROPERTY
              INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    set_property(TARGET Vulkan::volk APPEND
            PROPERTY
              IMPORTED_CONFIGURATIONS Release)
    set_property(TARGET Vulkan::volk APPEND
            PROPERTY
              IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}")

    if (NOT WIN32)
      set_property(TARGET Vulkan::volk APPEND
              PROPERTY
                IMPORTED_LINK_INTERFACE_LIBRARIES dl)
    endif()
  endif()

  if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib)
    add_library(Vulkan::dxc_lib STATIC IMPORTED)
    set_property(TARGET Vulkan::dxc_lib
      PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
    set_property(TARGET Vulkan::dxc_lib APPEND
      PROPERTY
        IMPORTED_CONFIGURATIONS Release)
    set_property(TARGET Vulkan::dxc_lib APPEND
      PROPERTY
        IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}")
  endif()

  if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe)
    add_executable(Vulkan::dxc_exe IMPORTED)
    set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}")
  endif()

endif()

if(Vulkan_MoltenVK_FOUND)
  if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK)
    add_library(Vulkan::MoltenVK SHARED IMPORTED)
    set_target_properties(Vulkan::MoltenVK
      PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}"
        IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}"
    )
  endif()
endif()

unset(_Vulkan_library_name)
unset(_Vulkan_hint_include_search_paths)
unset(_Vulkan_hint_executable_search_paths)
unset(_Vulkan_hint_library_search_paths)

cmake_policy(POP)


code:
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindWget
--------

Find wget

This module looks for wget.  This module defines the following values:

::

  WGET_EXECUTABLE: the full path to the wget tool.
  WGET_FOUND: True if wget has been found.
#]=======================================================================]

include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/FindMsys.cmake)

find_program(WGET_EXECUTABLE
  wget
  ${CYGWIN_INSTALL_PATH}/bin
  ${MSYS_INSTALL_PATH}/usr/bin
)

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Wget DEFAULT_MSG WGET_EXECUTABLE)

mark_as_advanced( WGET_EXECUTABLE )

# WGET option is deprecated.
# use WGET_EXECUTABLE instead.
set (WGET ${WGET_EXECUTABLE})

repo_name: lazytadpole/codenamesilverfish

license: mit


code:
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindWish
--------

Find wish installation

This module finds if TCL is installed and determines where the include
files and libraries are.  It also determines what the name of the
library is.  This code sets the following variables:

::

  TK_WISH = the path to the wish executable

if UNIX is defined, then it will look for the cygwin version first
#]=======================================================================]

if(UNIX)
  find_program(TK_WISH cygwish80 )
endif()

get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
string(REGEX REPLACE
  "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")

get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)

get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
string(REGEX REPLACE
  "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")

get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
string(REGEX REPLACE
  "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")

set(TCLTK_POSSIBLE_BIN_PATHS
  "${TCL_INCLUDE_PATH_PARENT}/bin"
  "${TK_INCLUDE_PATH_PARENT}/bin"
  "${TCL_LIBRARY_PATH_PARENT}/bin"
  "${TK_LIBRARY_PATH_PARENT}/bin"
  "${TCL_TCLSH_PATH_PARENT}/bin"
  )

if(WIN32)
  get_filename_component(
    ActiveTcl_CurrentVersion
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
    NAME)
  set(TCLTK_POSSIBLE_BIN_PATHS ${TCLTK_POSSIBLE_BIN_PATHS}
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/bin"
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/bin"
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/bin"
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/bin"
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/bin"
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/bin"
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/bin"
    )
endif()

set(TK_WISH_NAMES
  wish
  wish${TCL_LIBRARY_VERSION} wish${TK_LIBRARY_VERSION} wish${TCL_TCLSH_VERSION}
  wish86 wish8.6
  wish85 wish8.5
  wish84 wish8.4
  wish83 wish8.3
  wish82 wish8.2
  wish80 wish8.0
  )

find_program(TK_WISH
  NAMES ${TK_WISH_NAMES}
  HINTS ${TCLTK_POSSIBLE_BIN_PATHS}
  )

mark_as_advanced(TK_WISH)


code:
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindX11
-------

Find X11 installation

Try to find X11 on UNIX systems. The following values are defined

::

  X11_FOUND        - True if X11 is available
  X11_INCLUDE_DIR  - include directories to use X11
  X11_LIBRARIES    - link against these to use X11

and also the following more fine grained variables and targets:

.. versionadded:: 3.14
  Imported targets.

::

  X11_ICE_INCLUDE_PATH,            X11_ICE_LIB,            X11_ICE_FOUND,            X11::ICE
  X11_SM_INCLUDE_PATH,             X11_SM_LIB,             X11_SM_FOUND,             X11::SM
  X11_X11_INCLUDE_PATH,            X11_X11_LIB,                                      X11::X11
  X11_Xaccessrules_INCLUDE_PATH,
  X11_Xaccessstr_INCLUDE_PATH,                             X11_Xaccess_FOUND
  X11_Xau_INCLUDE_PATH,            X11_Xau_LIB,            X11_Xau_FOUND,            X11::Xau
  X11_xcb_INCLUDE_PATH,            X11_xcb_LIB,            X11_xcb_FOUND,            X11::xcb
  X11_X11_xcb_INCLUDE_PATH,        X11_X11_xcb_LIB,        X11_X11_xcb_FOUND,        X11::X11_xcb
  X11_xcb_composite_INCLUDE_PATH,  X11_xcb_composite_LIB,  X11_xcb_composite_FOUND,  X11::xcb_composite
  X11_xcb_cursor_INCLUDE_PATH,     X11_xcb_cursor_LIB,     X11_xcb_cursor_FOUND,     X11::xcb_cursor
  X11_xcb_damage_INCLUDE_PATH,     X11_xcb_damage_LIB,     X11_xcb_damage_FOUND,     X11::xcb_damage
  X11_xcb_dpms_INCLUDE_PATH,       X11_xcb_dpms_LIB,       X11_xcb_dpms_FOUND,       X11::xcb_dpms
  X11_xcb_dri2_INCLUDE_PATH,       X11_xcb_dri2_LIB,       X11_xcb_dri2_FOUND,       X11::xcb_dri2
  X11_xcb_dri3_INCLUDE_PATH,       X11_xcb_dri3_LIB,       X11_xcb_dri3_FOUND,       X11::xcb_dri3
  X11_xcb_errors_INCLUDE_PATH,     X11_xcb_errors_LIB,     X11_xcb_errors_FOUND,     X11::xcb_errors
  X11_xcb_ewmh_INCLUDE_PATH,       X11_xcb_ewmh_LIB,       X11_xcb_ewmh_FOUND,       X11::xcb_ewmh
  X11_xcb_glx_INCLUDE_PATH,        X11_xcb_glx_LIB,        X11_xcb_glx_FOUND,        X11::xcb_glx
  X11_xcb_icccm_INCLUDE_PATH,      X11_xcb_icccm_LIB,      X11_xcb_icccm_FOUND,      X11::xcb_icccm
  X11_xcb_image_INCLUDE_PATH,      X11_xcb_image_LIB,      X11_xcb_image_FOUND,      X11::xcb_image
  X11_xcb_keysyms_INCLUDE_PATH,    X11_xcb_keysyms_LIB,    X11_xcb_keysyms_FOUND,    X11::xcb_keysyms
  X11_xcb_present_INCLUDE_PATH,    X11_xcb_present_LIB,    X11_xcb_present_FOUND,    X11::xcb_present
  X11_xcb_randr_INCLUDE_PATH,      X11_xcb_randr_LIB,      X11_xcb_randr_FOUND,      X11::xcb_randr
  X11_xcb_record_INCLUDE_PATH,     X11_xcb_record_LIB,     X11_xcb_record_FOUND,     X11::xcb_record
  X11_xcb_render_INCLUDE_PATH,     X11_xcb_render_LIB,     X11_xcb_render_FOUND,     X11::xcb_render
  X11_xcb_render_util_INCLUDE_PATH,X11_xcb_render_util_LIB,X11_xcb_render_util_FOUND,X11::xcb_render_util
  X11_xcb_res_INCLUDE_PATH,        X11_xcb_res_LIB,        X11_xcb_res_FOUND,        X11::xcb_res
  X11_xcb_screensaver_INCLUDE_PATH,X11_xcb_screensaver_LIB,X11_xcb_screensaver_FOUND,X11::xcb_screensaver
  X11_xcb_shape_INCLUDE_PATH,      X11_xcb_shape_LIB,      X11_xcb_shape_FOUND,      X11::xcb_shape
  X11_xcb_shm_INCLUDE_PATH,        X11_xcb_shm_LIB,        X11_xcb_shm_FOUND,        X11::xcb_shm
  X11_xcb_sync_INCLUDE_PATH,       X11_xcb_sync_LIB,       X11_xcb_sync_FOUND,       X11::xcb_sync
  X11_xcb_util_INCLUDE_PATH,       X11_xcb_util_LIB,       X11_xcb_util_FOUND,       X11::xcb_util
  X11_xcb_xf86dri_INCLUDE_PATH,    X11_xcb_xf86dri_LIB,    X11_xcb_xf86dri_FOUND,    X11::xcb_xf86dri
  X11_xcb_xfixes_INCLUDE_PATH,     X11_xcb_xfixes_LIB,     X11_xcb_xfixes_FOUND,     X11::xcb_xfixes
  X11_xcb_xinerama_INCLUDE_PATH,   X11_xcb_xinerama_LIB,   X11_xcb_xinerama_FOUND,   X11::xcb_xinerama
  X11_xcb_xinput_INCLUDE_PATH,     X11_xcb_xinput_LIB,     X11_xcb_xinput_FOUND,     X11::xcb_xinput
  X11_xcb_xkb_INCLUDE_PATH,        X11_xcb_xkb_LIB,        X11_xcb_xkb_FOUND,        X11::xcb_xkb
  X11_xcb_xrm_INCLUDE_PATH,        X11_xcb_xrm_LIB,        X11_xcb_xrm_FOUND,        X11::xcb_xrm
  X11_xcb_xtest_INCLUDE_PATH,      X11_xcb_xtest_LIB,      X11_xcb_xtest_FOUND,      X11::xcb_xtest
  X11_xcb_xvmc_INCLUDE_PATH,       X11_xcb_xvmc_LIB,       X11_xcb_xvmc_FOUND,       X11::xcb_xvmc
  X11_xcb_xv_INCLUDE_PATH,         X11_xcb_xv_LIB,         X11_xcb_xv_FOUND          X11::xcb_xv
  X11_Xcomposite_INCLUDE_PATH,     X11_Xcomposite_LIB,     X11_Xcomposite_FOUND,     X11::Xcomposite
  X11_Xcursor_INCLUDE_PATH,        X11_Xcursor_LIB,        X11_Xcursor_FOUND,        X11::Xcursor
  X11_Xdamage_INCLUDE_PATH,        X11_Xdamage_LIB,        X11_Xdamage_FOUND,        X11::Xdamage
  X11_Xdmcp_INCLUDE_PATH,          X11_Xdmcp_LIB,          X11_Xdmcp_FOUND,          X11::Xdmcp
  X11_Xext_INCLUDE_PATH,           X11_Xext_LIB,           X11_Xext_FOUND,           X11::Xext
  X11_Xxf86misc_INCLUDE_PATH,      X11_Xxf86misc_LIB,      X11_Xxf86misc_FOUND,      X11::Xxf86misc
  X11_Xxf86vm_INCLUDE_PATH,        X11_Xxf86vm_LIB         X11_Xxf86vm_FOUND,        X11::Xxf86vm
  X11_Xfixes_INCLUDE_PATH,         X11_Xfixes_LIB,         X11_Xfixes_FOUND,         X11::Xfixes
  X11_Xft_INCLUDE_PATH,            X11_Xft_LIB,            X11_Xft_FOUND,            X11::Xft
  X11_Xi_INCLUDE_PATH,             X11_Xi_LIB,             X11_Xi_FOUND,             X11::Xi
  X11_Xinerama_INCLUDE_PATH,       X11_Xinerama_LIB,       X11_Xinerama_FOUND,       X11::Xinerama
  X11_Xkb_INCLUDE_PATH,
  X11_Xkblib_INCLUDE_PATH,                                 X11_Xkb_FOUND,            X11::Xkb
  X11_xkbcommon_INCLUDE_PATH,      X11_xkbcommon_LIB,      X11_xkbcommon_FOUND,      X11::xkbcommon
  X11_xkbcommon_X11_INCLUDE_PATH,  X11_xkbcommon_X11_LIB,  X11_xkbcommon_X11_FOUND,  X11::xkbcommon_X11
  X11_xkbfile_INCLUDE_PATH,        X11_xkbfile_LIB,        X11_xkbfile_FOUND,        X11::xkbfile
  X11_Xmu_INCLUDE_PATH,            X11_Xmu_LIB,            X11_Xmu_FOUND,            X11::Xmu
  X11_Xpm_INCLUDE_PATH,            X11_Xpm_LIB,            X11_Xpm_FOUND,            X11::Xpm
  X11_Xtst_INCLUDE_PATH,           X11_Xtst_LIB,           X11_Xtst_FOUND,           X11::Xtst
  X11_Xrandr_INCLUDE_PATH,         X11_Xrandr_LIB,         X11_Xrandr_FOUND,         X11::Xrandr
  X11_Xrender_INCLUDE_PATH,        X11_Xrender_LIB,        X11_Xrender_FOUND,        X11::Xrender
  X11_XRes_INCLUDE_PATH,           X11_XRes_LIB,           X11_XRes_FOUND,           X11::XRes
  X11_Xss_INCLUDE_PATH,            X11_Xss_LIB,            X11_Xss_FOUND,            X11::Xss
  X11_Xt_INCLUDE_PATH,             X11_Xt_LIB,             X11_Xt_FOUND,             X11::Xt
  X11_Xutil_INCLUDE_PATH,                                  X11_Xutil_FOUND,          X11::Xutil
  X11_Xv_INCLUDE_PATH,             X11_Xv_LIB,             X11_Xv_FOUND,             X11::Xv
  X11_dpms_INCLUDE_PATH,           (in X11_Xext_LIB),      X11_dpms_FOUND
  X11_Xdbe_INCLUDE_PATH,           (in X11_Xext_LIB),      X11_Xdbe_FOUND
  X11_XShm_INCLUDE_PATH,           (in X11_Xext_LIB),      X11_XShm_FOUND
  X11_Xshape_INCLUDE_PATH,         (in X11_Xext_LIB),      X11_Xshape_FOUND
  X11_XSync_INCLUDE_PATH,          (in X11_Xext_LIB),      X11_XSync_FOUND
  X11_Xaw_INCLUDE_PATH,            X11_Xaw_LIB             X11_Xaw_FOUND             X11::Xaw

.. versionadded:: 3.14
  Renamed ``Xxf86misc``, ``X11_Xxf86misc``, ``X11_Xxf86vm``, ``X11_xkbfile``,
  ``X11_Xtst``, and ``X11_Xss`` libraries to match their file names.
  Deprecated the ``X11_Xinput`` library.  Old names are still available
  for compatibility.

.. versionadded:: 3.14
  Added the ``X11_Xext_INCLUDE_PATH`` variable.

.. versionadded:: 3.18
  Added the ``xcb``, ``X11-xcb``, ``xcb-icccm``, ``xcb-xkb``, ``xkbcommon``,
  and ``xkbcommon-X11`` libraries.

.. versionadded:: 3.19
  Added the ``Xaw``, ``xcb_util``, and ``xcb_xfixes`` libraries.

.. versionadded:: 3.24
  Added the ``xcb_randr``, ``xcb_xtext``, and ``xcb_keysyms`` libraries.

.. versionadded:: 3.27
  Added the ``xcb_composite``, ``xcb_cursor``, ``xcb_damage``, ``xcb_dpms``,
  ``xcb_dri2``, ``xcb_dri3``, ``xcb_errors``, ``xcb_ewmh``, ``xcb_glx``,
  ``xcb_image``, ``xcb_present``, ``xcb_record``, ``xcb_render``,
  ``xcb_render_util``, ``xcb_res``, ``xcb_screensaver``, ``xcb_shape``,
  ``xcb_shm``, ``xcb_sync``, ``xcb_xf86dri``, ``xcb_xinerama``, ``xcb_xinput``,
  ``xcb_xrm``, ``xcb_xvmc``, and ``xcb_xv`` libraries.

.. versionadded:: 3.29
  Added coverage of double buffer extension (variables
  ``X11_Xdbe_INCLUDE_PATH`` and ``X11_Xdbe_FOUND``).

#]=======================================================================]

if (UNIX)
  set(X11_FOUND 0)
  # X11 is never a framework and some header files may be
  # found in tcl on the mac
  set(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK})
  set(CMAKE_FIND_FRAMEWORK NEVER)
  set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
  set(CMAKE_REQUIRED_QUIET ${X11_FIND_QUIETLY})
  set(X11_INC_SEARCH_PATH
    /usr/pkg/xorg/include
    /usr/X11R6/include
    /usr/X11R7/include
    /usr/include/X11
    /usr/openwin/include
    /usr/openwin/share/include
    /opt/graphics/OpenGL/include
    /opt/X11/include
  )

  set(X11_LIB_SEARCH_PATH
    /usr/pkg/xorg/lib
    /usr/X11R6/lib
    /usr/X11R7/lib
    /usr/openwin/lib
    /opt/X11/lib
  )

  find_path(X11_X11_INCLUDE_PATH X11/X.h                             ${X11_INC_SEARCH_PATH})
  find_path(X11_Xlib_INCLUDE_PATH X11/Xlib.h                         ${X11_INC_SEARCH_PATH})

  # Look for includes; keep the list sorted by name of the cmake *_INCLUDE_PATH
  # variable (which doesn't need to match the include file name).

  # Solaris lacks XKBrules.h, so we should skip kxkbd there.
  find_path(X11_ICE_INCLUDE_PATH X11/ICE/ICE.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_SM_INCLUDE_PATH X11/SM/SM.h                          ${X11_INC_SEARCH_PATH})
  find_path(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h  ${X11_INC_SEARCH_PATH})
  find_path(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h      ${X11_INC_SEARCH_PATH})
  find_path(X11_Xau_INCLUDE_PATH X11/Xauth.h                         ${X11_INC_SEARCH_PATH})
  find_path(X11_Xaw_INCLUDE_PATH X11/Xaw/Box.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_INCLUDE_PATH xcb/xcb.h                           ${X11_INC_SEARCH_PATH})
  find_path(X11_X11_xcb_INCLUDE_PATH X11/Xlib-xcb.h                  ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_composite_INCLUDE_PATH xcb/composite.h           ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_cursor_INCLUDE_PATH xcb/xcb_cursor.h             ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_damage_INCLUDE_PATH xcb/damage.h                 ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_dpms_INCLUDE_PATH xcb/dpms.h                     ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_dri2_INCLUDE_PATH xcb/dri2.h                     ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_dri3_INCLUDE_PATH xcb/dri3.h                     ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_errors_INCLUDE_PATH xcb/xcb_errors.h             ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_ewmh_INCLUDE_PATH xcb/xcb_ewmh.h                 ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_glx_INCLUDE_PATH xcb/glx.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_icccm_INCLUDE_PATH xcb/xcb_icccm.h               ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_image_INCLUDE_PATH xcb/xcb_image.h               ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_keysyms_INCLUDE_PATH xcb/xcb_keysyms.h           ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_present_INCLUDE_PATH xcb/present.h               ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_randr_INCLUDE_PATH xcb/randr.h                   ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_record_INCLUDE_PATH xcb/record.h                 ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_render_INCLUDE_PATH xcb/render.h                 ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_render_util_INCLUDE_PATH xcb/xcb_renderutil.h    ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_res_INCLUDE_PATH xcb/res.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_screensaver_INCLUDE_PATH xcb/screensaver.h       ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_shape_INCLUDE_PATH xcb/shape.h                   ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_shm_INCLUDE_PATH xcb/shm.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_sync_INCLUDE_PATH xcb/sync.h                     ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_util_INCLUDE_PATH xcb/xcb_aux.h                  ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xf86dri_INCLUDE_PATH xcb/xf86dri.h               ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xfixes_INCLUDE_PATH xcb/xfixes.h                 ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xinerama_INCLUDE_PATH xcb/xinerama.h             ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xinput_INCLUDE_PATH xcb/xinput.h                 ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xkb_INCLUDE_PATH xcb/xkb.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xrm_INCLUDE_PATH xcb/xcb_xrm.h                   ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xtest_INCLUDE_PATH xcb/xtest.h                   ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xvmc_INCLUDE_PATH xcb/xvmc.h                     ${X11_INC_SEARCH_PATH})
  find_path(X11_xcb_xv_INCLUDE_PATH xcb/xv.h                         ${X11_INC_SEARCH_PATH})
  find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h  ${X11_INC_SEARCH_PATH})
  find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h           ${X11_INC_SEARCH_PATH})
  find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h        ${X11_INC_SEARCH_PATH})
  find_path(X11_Xdbe_INCLUDE_PATH X11/extensions/Xdbe.h              ${X11_INC_SEARCH_PATH})
  find_path(X11_Xdmcp_INCLUDE_PATH X11/Xdmcp.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_Xext_INCLUDE_PATH X11/extensions/Xext.h              ${X11_INC_SEARCH_PATH})
  find_path(X11_dpms_INCLUDE_PATH X11/extensions/dpms.h              ${X11_INC_SEARCH_PATH})
  find_path(X11_Xxf86misc_INCLUDE_PATH X11/extensions/xf86misc.h     ${X11_INC_SEARCH_PATH})
  find_path(X11_Xxf86vm_INCLUDE_PATH X11/extensions/xf86vmode.h      ${X11_INC_SEARCH_PATH})
  find_path(X11_Xfixes_INCLUDE_PATH X11/extensions/Xfixes.h          ${X11_INC_SEARCH_PATH})
  find_path(X11_Xft_INCLUDE_PATH X11/Xft/Xft.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_Xi_INCLUDE_PATH X11/extensions/XInput.h              ${X11_INC_SEARCH_PATH})
  find_path(X11_Xinerama_INCLUDE_PATH X11/extensions/Xinerama.h      ${X11_INC_SEARCH_PATH})
  find_path(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h                ${X11_INC_SEARCH_PATH})
  find_path(X11_xkbcommon_INCLUDE_PATH xkbcommon/xkbcommon.h         ${X11_INC_SEARCH_PATH})
  find_path(X11_xkbcommon_X11_INCLUDE_PATH xkbcommon/xkbcommon-x11.h ${X11_INC_SEARCH_PATH})
  find_path(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h                     ${X11_INC_SEARCH_PATH})
  find_path(X11_xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h        ${X11_INC_SEARCH_PATH})
  find_path(X11_Xmu_INCLUDE_PATH X11/Xmu/Xmu.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_Xpm_INCLUDE_PATH X11/xpm.h                           ${X11_INC_SEARCH_PATH})
  find_path(X11_Xtst_INCLUDE_PATH X11/extensions/XTest.h             ${X11_INC_SEARCH_PATH})
  find_path(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h              ${X11_INC_SEARCH_PATH})
  find_path(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h          ${X11_INC_SEARCH_PATH})
  find_path(X11_Xrender_INCLUDE_PATH X11/extensions/Xrender.h        ${X11_INC_SEARCH_PATH})
  find_path(X11_XRes_INCLUDE_PATH X11/extensions/XRes.h              ${X11_INC_SEARCH_PATH})
  find_path(X11_Xss_INCLUDE_PATH X11/extensions/scrnsaver.h          ${X11_INC_SEARCH_PATH})
  find_path(X11_Xshape_INCLUDE_PATH X11/extensions/shape.h           ${X11_INC_SEARCH_PATH})
  find_path(X11_Xutil_INCLUDE_PATH X11/Xutil.h                       ${X11_INC_SEARCH_PATH})
  find_path(X11_Xt_INCLUDE_PATH X11/Intrinsic.h                      ${X11_INC_SEARCH_PATH})
  find_path(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h               ${X11_INC_SEARCH_PATH})
  find_path(X11_XSync_INCLUDE_PATH X11/extensions/sync.h             ${X11_INC_SEARCH_PATH})

  # Backwards compatibility.
  set(X11_Xinput_INCLUDE_PATH "${X11_Xi_INCLUDE_PATH}")
  set(X11_xf86misc_INCLUDE_PATH "${X11_Xxf86misc_INCLUDE_PATH}")
  set(X11_xf86vmode_INCLUDE_PATH "${X11_Xxf8vm_INCLUDE_PATH}")
  set(X11_Xkbfile_INCLUDE_PATH "${X11_xkbfile_INCLUDE_PATH}")
  set(X11_XTest_INCLUDE_PATH "${X11_Xtst_INCLUDE_PATH}")
  set(X11_Xscreensaver_INCLUDE_PATH "${X11_Xss_INCLUDE_PATH}")

  find_library(X11_X11_LIB X11               ${X11_LIB_SEARCH_PATH})

  # Find additional X libraries. Keep list sorted by library name.
  find_library(X11_ICE_LIB ICE                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_SM_LIB SM                           ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xau_LIB Xau                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xaw_LIB Xaw                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_LIB xcb                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_X11_xcb_LIB X11-xcb                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_composite_LIB xcb-composite     ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_cursor_LIB xcb-cursor           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_damage_LIB xcb-damage           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_dpms_LIB xcb-dpms               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_dri2_LIB xcb-dri2               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_dri3_LIB xcb-dri3               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_errors_LIB xcb-errors           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_ewmh_LIB xcb-ewmh               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_glx_LIB xcb-glx                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_icccm_LIB xcb-icccm             ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_image_LIB xcb-image             ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_keysyms_LIB xcb-keysyms         ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_present_LIB xcb-present         ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_randr_LIB xcb-randr             ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_record_LIB xcb-record           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_render_LIB xcb-render           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_render_util_LIB xcb-render-util ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_res_LIB xcb-res                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_screensaver_LIB xcb-screensaver ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_shape_LIB xcb-shape             ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_shm_LIB xcb-shm                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_sync_LIB xcb-sync               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_util_LIB xcb-util               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xf86dri_LIB xcb-xf86dri         ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xfixes_LIB xcb-xfixes           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xinerama_LIB xcb-xinerama       ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xinput_LIB xcb-xinput           ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xkb_LIB xcb-xkb                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xrm_LIB xcb-xrm                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xtest_LIB xcb-xtest             ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xvmc_LIB xcb-xvmc               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xcb_xv_LIB xcb-xv                   ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xcomposite_LIB Xcomposite           ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xcursor_LIB Xcursor                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xdamage_LIB Xdamage                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xdmcp_LIB Xdmcp                     ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xext_LIB Xext                       ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xfixes_LIB Xfixes                   ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xft_LIB Xft                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xi_LIB Xi                           ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xinerama_LIB Xinerama               ${X11_LIB_SEARCH_PATH})
  find_library(X11_xkbcommon_LIB xkbcommon             ${X11_LIB_SEARCH_PATH})
  find_library(X11_xkbcommon_X11_LIB xkbcommon-x11     ${X11_LIB_SEARCH_PATH})
  find_library(X11_xkbfile_LIB xkbfile                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xmu_LIB Xmu                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xpm_LIB Xpm                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xrandr_LIB Xrandr                   ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xrender_LIB Xrender                 ${X11_LIB_SEARCH_PATH})
  find_library(X11_XRes_LIB XRes                       ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xss_LIB Xss                         ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xt_LIB Xt                           ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xtst_LIB Xtst                       ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xv_LIB Xv                           ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xxf86misc_LIB Xxf86misc             ${X11_LIB_SEARCH_PATH})
  find_library(X11_Xxf86vm_LIB Xxf86vm                 ${X11_LIB_SEARCH_PATH})

  # Backwards compatibility.
  set(X11_Xinput_LIB "${X11_Xi_LIB}")
  set(X11_Xkbfile_LIB "${X11_xkbfile_LIB}")
  set(X11_XTest_LIB "${X11_Xtst_LIB}")
  set(X11_Xscreensaver_LIB "${X11_Xss_LIB}")

  set(X11_LIBRARY_DIR "")
  if(X11_X11_LIB)
    get_filename_component(X11_LIBRARY_DIR ${X11_X11_LIB} PATH)
  endif()

  set(X11_INCLUDE_DIR) # start with empty list
  if(X11_X11_INCLUDE_PATH)
    list(APPEND X11_INCLUDE_DIR ${X11_X11_INCLUDE_PATH})
  endif()

  if(X11_Xlib_INCLUDE_PATH)
    list(APPEND X11_INCLUDE_DIR ${X11_Xlib_INCLUDE_PATH})
  endif()

  if(X11_Xutil_INCLUDE_PATH)
    set(X11_Xutil_FOUND TRUE)
    list(APPEND X11_INCLUDE_DIR ${X11_Xutil_INCLUDE_PATH})
  endif()

  if(X11_Xshape_INCLUDE_PATH)
    set(X11_Xshape_FOUND TRUE)
    list(APPEND X11_INCLUDE_DIR ${X11_Xshape_INCLUDE_PATH})
  endif()

  set(X11_LIBRARIES) # start with empty list
  if(X11_X11_LIB)
    list(APPEND X11_LIBRARIES ${X11_X11_LIB})
  endif()

  if(X11_Xext_LIB)
    set(X11_Xext_FOUND TRUE)
    list(APPEND X11_LIBRARIES ${X11_Xext_LIB})
  endif()

  if(X11_Xt_LIB AND X11_Xt_INCLUDE_PATH)
    set(X11_Xt_FOUND TRUE)
  endif()

  if(X11_Xft_LIB AND X11_Xft_INCLUDE_PATH)
    find_package(Freetype QUIET)
    find_package(Fontconfig QUIET)
    if (FREETYPE_FOUND AND Fontconfig_FOUND)
      set(X11_Xft_FOUND TRUE)
    endif ()
    list(APPEND X11_INCLUDE_DIR ${X11_Xft_INCLUDE_PATH})
  endif()

  if(X11_Xv_LIB AND X11_Xv_INCLUDE_PATH)
    set(X11_Xv_FOUND TRUE)
    list(APPEND X11_INCLUDE_DIR ${X11_Xv_INCLUDE_PATH})
  endif()

  if (X11_Xau_LIB AND X11_Xau_INCLUDE_PATH)
    set(X11_Xau_FOUND TRUE)
  endif ()

  if (X11_xcb_LIB AND X11_xcb_INCLUDE_PATH)
    set(X11_xcb_FOUND TRUE)
  endif ()

  if (X11_X11_xcb_LIB AND X11_X11_xcb_INCLUDE_PATH)
    set(X11_X11_xcb_FOUND TRUE)
  endif ()

  if (X11_xcb_composite_LIB AND X11_xcb_composite_INCLUDE_PATH)
    set(X11_xcb_composite_FOUND TRUE)
  endif ()

  if (X11_xcb_cursor_LIB AND X11_xcb_cursor_INCLUDE_PATH)
    set(X11_xcb_cursor_FOUND TRUE)
  endif ()

  if (X11_xcb_damage_LIB AND X11_xcb_damage_INCLUDE_PATH)
    set(X11_xcb_damage_FOUND TRUE)
  endif ()

  if (X11_xcb_dpms_LIB AND X11_xcb_dpms_INCLUDE_PATH)
    set(X11_xcb_dpms_FOUND TRUE)
  endif ()

  if (X11_xcb_dri2_LIB AND X11_xcb_dri2_INCLUDE_PATH)
    set(X11_xcb_dri2_FOUND TRUE)
  endif ()

  if (X11_xcb_dri3_LIB AND X11_xcb_dri3_INCLUDE_PATH)
    set(X11_xcb_dri3_FOUND TRUE)
  endif ()

  if (X11_xcb_errors_LIB AND X11_xcb_errors_INCLUDE_PATH)
    set(X11_xcb_errors_FOUND TRUE)
  endif ()

  if (X11_xcb_ewmh_LIB AND X11_xcb_ewmh_INCLUDE_PATH)
    set(X11_xcb_ewmh_FOUND TRUE)
  endif ()

  if (X11_xcb_glx_LIB AND X11_xcb_glx_INCLUDE_PATH)
    set(X11_xcb_glx_FOUND TRUE)
  endif ()

  if (X11_xcb_icccm_LIB AND X11_xcb_icccm_INCLUDE_PATH)
    set(X11_xcb_icccm_FOUND TRUE)
  endif ()

  if (X11_xcb_image_LIB AND X11_xcb_image_INCLUDE_PATH)
    set(X11_xcb_image_FOUND TRUE)
  endif ()

  if (X11_xcb_keysyms_LIB AND X11_xcb_keysyms_INCLUDE_PATH)
    set(X11_xcb_keysyms_FOUND TRUE)
  endif ()

  if (X11_xcb_present_LIB AND X11_xcb_present_INCLUDE_PATH)
    set(X11_xcb_present_FOUND TRUE)
  endif ()

  if (X11_xcb_randr_LIB AND X11_xcb_randr_INCLUDE_PATH)
    set(X11_xcb_randr_FOUND TRUE)
  endif ()

  if (X11_xcb_record_LIB AND X11_xcb_record_INCLUDE_PATH)
    set(X11_xcb_record_FOUND TRUE)
  endif ()

  if (X11_xcb_render_LIB AND X11_xcb_render_INCLUDE_PATH)
    set(X11_xcb_render_FOUND TRUE)
  endif ()

  if (X11_xcb_render_util_LIB AND X11_xcb_render_util_INCLUDE_PATH)
    set(X11_xcb_render_util_FOUND TRUE)
  endif ()

  if (X11_xcb_res_LIB AND X11_xcb_res_INCLUDE_PATH)
    set(X11_xcb_res_FOUND TRUE)
  endif ()

  if (X11_xcb_screensaver_LIB AND X11_xcb_screensaver_INCLUDE_PATH)
    set(X11_xcb_screensaver_FOUND TRUE)
  endif ()

  if (X11_xcb_shape_LIB AND X11_xcb_shape_INCLUDE_PATH)
    set(X11_xcb_shape_FOUND TRUE)
  endif ()

  if (X11_xcb_shm_LIB AND X11_xcb_shm_INCLUDE_PATH)
    set(X11_xcb_shm_FOUND TRUE)
  endif ()

  if (X11_xcb_sync_LIB AND X11_xcb_sync_INCLUDE_PATH)
    set(X11_xcb_sync_FOUND TRUE)
  endif ()

  if (X11_xcb_util_LIB AND X11_xcb_util_INCLUDE_PATH)
    set(X11_xcb_util_FOUND TRUE)
  endif ()

  if (X11_xcb_xf86dri_LIB AND X11_xcb_xf86dri_INCLUDE_PATH)
    set(X11_xcb_xf86dri_FOUND TRUE)
  endif ()

  if (X11_xcb_xfixes_LIB AND X11_xcb_xfixes_INCLUDE_PATH)
    set(X11_xcb_xfixes_FOUND TRUE)
  endif ()

  if (X11_xcb_xinerama_LIB AND X11_xcb_xinerama_INCLUDE_PATH)
    set(X11_xcb_xinerama_FOUND TRUE)
  endif ()

  if (X11_xcb_xinput_LIB AND X11_xcb_xinput_INCLUDE_PATH)
    set(X11_xcb_xinput_FOUND TRUE)
  endif ()

  if (X11_xcb_xkb_LIB AND X11_xcb_xkb_INCLUDE_PATH)
    set(X11_xcb_xkb_FOUND TRUE)
  endif ()

  if (X11_xcb_xrm_LIB AND X11_xcb_xrm_INCLUDE_PATH)
    set(X11_xcb_xrm_FOUND TRUE)
  endif ()

  if (X11_xcb_xtest_LIB AND X11_xcb_xtest_INCLUDE_PATH)
    set(X11_xcb_xtest_FOUND TRUE)
  endif ()

  if (X11_xcb_xvmc_LIB AND X11_xcb_xvmc_INCLUDE_PATH)
    set(X11_xcb_xvmc_FOUND TRUE)
  endif ()

  if (X11_xcb_xv_LIB AND X11_xcb_xv_INCLUDE_PATH)
    set(X11_xcb_xv_FOUND TRUE)
  endif ()

  if (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB)
      set(X11_Xdmcp_FOUND TRUE)
      list(APPEND X11_INCLUDE_DIR ${X11_Xdmcp_INCLUDE_PATH})
  endif ()

  if (X11_Xaccessrules_INCLUDE_PATH AND X11_Xaccessstr_INCLUDE_PATH)
      set(X11_Xaccess_FOUND TRUE)
      set(X11_Xaccess_INCLUDE_PATH ${X11_Xaccessstr_INCLUDE_PATH})
      list(APPEND X11_INCLUDE_DIR ${X11_Xaccess_INCLUDE_PATH})
  endif ()

  if (X11_Xpm_INCLUDE_PATH AND X11_Xpm_LIB)
      set(X11_Xpm_FOUND TRUE)
      list(APPEND X11_INCLUDE_DIR ${X11_Xpm_INCLUDE_PATH})
  endif ()

  if (X11_Xcomposite_INCLUDE_PATH AND X11_Xcomposite_LIB)
     set(X11_Xcomposite_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xcomposite_INCLUDE_PATH})
  endif ()

  if (X11_Xdamage_INCLUDE_PATH AND X11_Xdamage_LIB)
     set(X11_Xdamage_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xdamage_INCLUDE_PATH})
  endif ()

  if (X11_XShm_INCLUDE_PATH)
     set(X11_XShm_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_XShm_INCLUDE_PATH})
  endif ()

  if (X11_Xtst_INCLUDE_PATH AND X11_Xtst_LIB)
      set(X11_Xtst_FOUND TRUE)
      # Backwards compatibility.
      set(X11_XTest_FOUND TRUE)
      list(APPEND X11_INCLUDE_DIR ${X11_Xtst_INCLUDE_PATH})
  endif ()

  if (X11_Xi_INCLUDE_PATH AND X11_Xi_LIB)
     set(X11_Xi_FOUND TRUE)
     # Backwards compatibility.
     set(X11_Xinput_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xi_INCLUDE_PATH})
  endif ()

  if (X11_Xinerama_INCLUDE_PATH AND X11_Xinerama_LIB)
     set(X11_Xinerama_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xinerama_INCLUDE_PATH})
  endif ()

  if (X11_Xfixes_INCLUDE_PATH AND X11_Xfixes_LIB)
     set(X11_Xfixes_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xfixes_INCLUDE_PATH})
  endif ()

  if (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB)
     set(X11_Xrender_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xrender_INCLUDE_PATH})
  endif ()

  if (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB)
     set(X11_XRes_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_XRes_INCLUDE_PATH})
  endif ()

  if (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB)
     set(X11_Xrandr_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xrandr_INCLUDE_PATH})
  endif ()

  if (X11_Xxf86misc_INCLUDE_PATH AND X11_Xxf86misc_LIB)
     set(X11_Xxf86misc_FOUND TRUE)
     # Backwards compatibility.
     set(X11_xf86misc_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xxf86misc_INCLUDE_PATH})
  endif ()

  if (X11_Xxf86vm_INCLUDE_PATH AND X11_Xxf86vm_LIB)
     set(X11_Xxf86vm_FOUND TRUE)
     # Backwards compatibility.
     set(X11_xf86vmode_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xxf86vm_INCLUDE_PATH})
  endif ()

  if (X11_Xcursor_INCLUDE_PATH AND X11_Xcursor_LIB)
     set(X11_Xcursor_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xcursor_INCLUDE_PATH})
  endif ()

  if (X11_Xss_INCLUDE_PATH AND X11_Xss_LIB)
     set(X11_Xss_FOUND TRUE)
     set(X11_Xscreensaver_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xss_INCLUDE_PATH})
  endif ()

  if (X11_dpms_INCLUDE_PATH)
     set(X11_dpms_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_dpms_INCLUDE_PATH})
  endif ()

  if (X11_Xkb_INCLUDE_PATH AND X11_Xkblib_INCLUDE_PATH AND X11_Xlib_INCLUDE_PATH)
     set(X11_Xkb_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH} )
  endif ()

  if (X11_xkbcommon_INCLUDE_PATH AND X11_xkbcommon_LIB)
     set(X11_xkbcommon_FOUND TRUE)
  endif ()

  if (X11_xkbcommon_X11_INCLUDE_PATH AND X11_xkbcommon_X11_LIB)
     set(X11_xkbcommon_X11_FOUND TRUE)
  endif ()

  if (X11_xkbfile_INCLUDE_PATH AND X11_xkbfile_LIB AND X11_Xlib_INCLUDE_PATH)
     set(X11_xkbfile_FOUND TRUE)
     # Backwards compatibility.
     set(X11_Xkbfile_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_xkbfile_INCLUDE_PATH} )
  endif ()

  if (X11_Xmu_INCLUDE_PATH AND X11_Xmu_LIB)
     set(X11_Xmu_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xmu_INCLUDE_PATH})
  endif ()

  if (X11_XSync_INCLUDE_PATH)
     set(X11_XSync_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_XSync_INCLUDE_PATH})
  endif ()

  if(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH)
     set(X11_ICE_FOUND TRUE)
  endif()

  if(X11_SM_LIB AND X11_SM_INCLUDE_PATH)
     set(X11_SM_FOUND TRUE)
  endif()

  if(X11_Xaw_LIB AND X11_Xaw_INCLUDE_PATH)
      set(X11_Xaw_FOUND TRUE)
  endif()

  if (X11_Xdbe_INCLUDE_PATH)
     set(X11_Xdbe_FOUND TRUE)
     list(APPEND X11_INCLUDE_DIR ${X11_Xdbe_INCLUDE_PATH})
  endif ()

  # Most of the X11 headers will be in the same directories, avoid
  # creating a huge list of duplicates.
  if (X11_INCLUDE_DIR)
     list(REMOVE_DUPLICATES X11_INCLUDE_DIR)
  endif ()

  # Deprecated variable for backwards compatibility with CMake 1.4
  if (X11_X11_INCLUDE_PATH AND X11_LIBRARIES)
    set(X11_FOUND 1)
  endif ()

  include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  if (CMAKE_FIND_PACKAGE_NAME STREQUAL "FLTK")
    # FindFLTK include()'s this module. It's an old pattern, but rather than
    # trying to suppress this from outside the module (which is then sensitive
    # to the contents, detect the case in this module and suppress it
    # explicitly.
    set(FPHSA_NAME_MISMATCHED 1)
  endif ()
  find_package_handle_standard_args(X11
    REQUIRED_VARS X11_X11_INCLUDE_PATH X11_X11_LIB
    HANDLE_COMPONENTS)
  unset(FPHSA_NAME_MISMATCHED)

  if(X11_FOUND)
    include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
    include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)

    # Translated from an autoconf-generated configure script.
    # See libs.m4 in autoconf's m4 directory.
    if($ENV{ISC} MATCHES "^yes$")
      set(X11_X_EXTRA_LIBS -lnsl_s -linet)
    else()
      set(X11_X_EXTRA_LIBS "")

      # See if XOpenDisplay in X11 works by itself.
      check_library_exists("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO)
      if(NOT X11_LIB_X11_SOLO)
        # Find library needed for dnet_ntoa.
        check_library_exists("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA)
        if (X11_LIB_DNET_HAS_DNET_NTOA)
          list(APPEND X11_X_EXTRA_LIBS -ldnet)
        else ()
          check_library_exists("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA)
          if (X11_LIB_DNET_STUB_HAS_DNET_NTOA)
            list(APPEND X11_X_EXTRA_LIBS -ldnet_stub)
          endif ()
        endif ()
      endif()

      # Find library needed for gethostbyname.
      check_function_exists("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME)
      if(NOT CMAKE_HAVE_GETHOSTBYNAME)
        check_library_exists("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
        if (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
          list(APPEND X11_X_EXTRA_LIBS -lnsl)
        else ()
          check_library_exists("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
          if (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
            list(APPEND X11_X_EXTRA_LIBS -lbsd)
          endif ()
        endif ()
      endif()

      # Find library needed for connect.
      check_function_exists("connect" CMAKE_HAVE_CONNECT)
      if(NOT CMAKE_HAVE_CONNECT)
        check_library_exists("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT)
        if (CMAKE_LIB_SOCKET_HAS_CONNECT)
          list(INSERT X11_X_EXTRA_LIBS 0 -lsocket)
        endif ()
      endif()

      # Find library needed for remove.
      check_function_exists("remove" CMAKE_HAVE_REMOVE)
      if(NOT CMAKE_HAVE_REMOVE)
        check_library_exists("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE)
        if (CMAKE_LIB_POSIX_HAS_REMOVE)
          list(APPEND X11_X_EXTRA_LIBS -lposix)
        endif ()
      endif()

      # Find library needed for shmat.
      check_function_exists("shmat" CMAKE_HAVE_SHMAT)
      if(NOT CMAKE_HAVE_SHMAT)
        check_library_exists("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT)
        if (CMAKE_LIB_IPS_HAS_SHMAT)
          list(APPEND X11_X_EXTRA_LIBS -lipc)
        endif ()
      endif()
    endif()

    if (X11_ICE_FOUND)
      check_library_exists("ICE" "IceConnectionNumber" "${X11_LIBRARY_DIR}"
                            CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
      if(CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
        set (X11_X_PRE_LIBS ${X11_ICE_LIB})
        if(X11_SM_LIB)
          list(INSERT X11_X_PRE_LIBS 0 ${X11_SM_LIB})
        endif()
      endif()
    endif ()

    # Build the final list of libraries.
    set(X11_LIBRARIES ${X11_X_PRE_LIBS} ${X11_LIBRARIES} ${X11_X_EXTRA_LIBS})

    if (NOT TARGET X11::X11)
      add_library(X11::X11 UNKNOWN IMPORTED)
      set_target_properties(X11::X11 PROPERTIES
        IMPORTED_LOCATION "${X11_X11_LIB}"
        INTERFACE_INCLUDE_DIRECTORIES "${X11_X11_INCLUDE_PATH}")
    endif ()
  endif ()

  if (X11_ICE_FOUND AND NOT TARGET X11::ICE)
    add_library(X11::ICE UNKNOWN IMPORTED)
    set_target_properties(X11::ICE PROPERTIES
      IMPORTED_LOCATION "${X11_ICE_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_ICE_INCLUDE_PATH}")
  endif ()

  if (X11_SM_FOUND AND NOT TARGET X11::SM)
    add_library(X11::SM UNKNOWN IMPORTED)
    set_target_properties(X11::SM PROPERTIES
      IMPORTED_LOCATION "${X11_SM_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_SM_INCLUDE_PATH}")
  endif ()

  if (X11_Xau_FOUND AND NOT TARGET X11::Xau)
    add_library(X11::Xau UNKNOWN IMPORTED)
    set_target_properties(X11::Xau PROPERTIES
      IMPORTED_LOCATION "${X11_Xau_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xau_INCLUDE_PATH}")
  endif ()

  if (X11_Xaw_FOUND AND NOT TARGET X11::Xaw)
    add_library(X11::Xaw UNKNOWN IMPORTED)
    set_target_properties(X11::Xaw PROPERTIES
      IMPORTED_LOCATION "${X11_Xaw_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xaw_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xext;X11::Xmu;X11::Xt;X11::Xpm;X11::X11")
  endif ()

  if (X11_xcb_FOUND AND NOT TARGET X11::xcb)
    add_library(X11::xcb UNKNOWN IMPORTED)
    set_target_properties(X11::xcb PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_xcb_INCLUDE_PATH}")
  endif ()

  if (X11_X11_xcb_FOUND AND NOT TARGET X11::X11_xcb)
    add_library(X11::X11_xcb UNKNOWN IMPORTED)
    set_target_properties(X11::X11_xcb PROPERTIES
      IMPORTED_LOCATION "${X11_X11_xcb_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_X11_xcb_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::xcb;X11::X11")
  endif ()

  if (X11_xcb_composite_FOUND AND NOT TARGET X11::xcb_composite)
    add_library(X11::xcb_composite UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_composite PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_composite_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_cursor_FOUND AND NOT TARGET X11::xcb_cursor)
    add_library(X11::xcb_cursor UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_cursor PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_cursor_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_damage_FOUND AND NOT TARGET X11::xcb_damage)
    add_library(X11::xcb_damage UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_damage PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_damage_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_dpms_FOUND AND NOT TARGET X11::xcb_dpms)
    add_library(X11::xcb_dpms UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_dpms PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_dpms_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_dri2_FOUND AND NOT TARGET X11::xcb_dri2)
    add_library(X11::xcb_dri2 UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_dri2 PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_dri2_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_dri3_FOUND AND NOT TARGET X11::xcb_dri3)
    add_library(X11::xcb_dri3 UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_dri3 PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_dri3_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_errors_FOUND AND NOT TARGET X11::xcb_errors)
    add_library(X11::xcb_errors UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_errors PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_errors_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_ewmh_FOUND AND NOT TARGET X11::xcb_ewmh)
    add_library(X11::xcb_ewmh UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_ewmh PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_ewmh_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_glx_FOUND AND NOT TARGET X11::xcb_glx)
    add_library(X11::xcb_glx UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_glx PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_glx_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_icccm_FOUND AND NOT TARGET X11::xcb_icccm)
    add_library(X11::xcb_icccm UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_icccm PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_icccm_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_image_FOUND AND NOT TARGET X11::xcb_image)
    add_library(X11::xcb_image UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_image PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_image_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_keysyms_FOUND AND NOT TARGET X11::xcb_keysyms)
    add_library(X11::xcb_keysyms UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_keysyms PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_keysyms_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_present_FOUND AND NOT TARGET X11::xcb_present)
    add_library(X11::xcb_present UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_present PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_present_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_randr_FOUND AND NOT TARGET X11::xcb_randr)
    add_library(X11::xcb_randr UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_randr PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_randr_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_record_FOUND AND NOT TARGET X11::xcb_record)
    add_library(X11::xcb_record UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_record PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_record_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_render_FOUND AND NOT TARGET X11::xcb_render)
    add_library(X11::xcb_render UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_render PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_render_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_render_util_FOUND AND NOT TARGET X11::xcb_render_util)
    add_library(X11::xcb_render_util UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_render_util PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_render_util_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_res_FOUND AND NOT TARGET X11::xcb_res)
    add_library(X11::xcb_res UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_res PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_res_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_screensaver_FOUND AND NOT TARGET X11::xcb_screensaver)
    add_library(X11::xcb_screensaver UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_screensaver PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_screensaver_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_shape_FOUND AND NOT TARGET X11::xcb_shape)
    add_library(X11::xcb_shape UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_shape PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_shape_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_shm_FOUND AND NOT TARGET X11::xcb_shm)
    add_library(X11::xcb_shm UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_shm PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_shm_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_sync_FOUND AND NOT TARGET X11::xcb_sync)
    add_library(X11::xcb_sync UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_sync PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_sync_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_util_FOUND AND NOT TARGET X11::xcb_util)
    add_library(X11::xcb_util UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_util PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_util_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xf86dri_FOUND AND NOT TARGET X11::xcb_xf86dri)
    add_library(X11::xcb_xf86dri UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xf86dri PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xf86dri_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xfixes_FOUND AND NOT TARGET X11::xcb_xfixes)
    add_library(X11::xcb_xfixes UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xfixes PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xfixes_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xinerama_FOUND AND NOT TARGET X11::xcb_xinerama)
    add_library(X11::xcb_xinerama UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xinerama PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xinerama_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xinput_FOUND AND NOT TARGET X11::xcb_xinput)
    add_library(X11::xcb_xinput UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xinput PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xinput_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb)
    add_library(X11::xcb_xkb UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xkb PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xkb_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xrm_FOUND AND NOT TARGET X11::xcb_xrm)
    add_library(X11::xcb_xrm UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xrm PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xrm_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xtest_FOUND AND NOT TARGET X11::xcb_xtest)
  add_library(X11::xcb_xtest UNKNOWN IMPORTED)
  set_target_properties(X11::xcb_xtest PROPERTIES
    IMPORTED_LOCATION "${X11_xcb_xtest_LIB}"
    INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xvmc_FOUND AND NOT TARGET X11::xcb_xvmc)
    add_library(X11::xcb_xvmc UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xvmc PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xvmc_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_xcb_xv_FOUND AND NOT TARGET X11::xcb_xv)
    add_library(X11::xcb_xv UNKNOWN IMPORTED)
    set_target_properties(X11::xcb_xv PROPERTIES
      IMPORTED_LOCATION "${X11_xcb_xv_LIB}"
      INTERFACE_LINK_LIBRARIES "X11::xcb")
  endif ()

  if (X11_Xcomposite_FOUND AND NOT TARGET X11::Xcomposite)
    add_library(X11::Xcomposite UNKNOWN IMPORTED)
    set_target_properties(X11::Xcomposite PROPERTIES
      IMPORTED_LOCATION "${X11_Xcomposite_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xcomposite_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_Xcursor_FOUND AND NOT TARGET X11::Xcursor)
    add_library(X11::Xcursor UNKNOWN IMPORTED)
    set_target_properties(X11::Xcursor PROPERTIES
      IMPORTED_LOCATION "${X11_Xcursor_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xcursor_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xrender;X11::Xfixes;X11::X11")
  endif ()

  if (X11_Xdamage_FOUND AND NOT TARGET X11::Xdamage)
    add_library(X11::Xdamage UNKNOWN IMPORTED)
    set_target_properties(X11::Xdamage PROPERTIES
      IMPORTED_LOCATION "${X11_Xdamage_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xdamage_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xfixes;X11::X11")
  endif ()

  if (X11_Xdmcp_FOUND AND NOT TARGET X11::Xdmcp)
    add_library(X11::Xdmcp UNKNOWN IMPORTED)
    set_target_properties(X11::Xdmcp PROPERTIES
      IMPORTED_LOCATION "${X11_Xdmcp_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xdmcp_INCLUDE_PATH}")
  endif ()

  if (X11_Xext_FOUND AND NOT TARGET X11::Xext)
    add_library(X11::Xext UNKNOWN IMPORTED)
    set_target_properties(X11::Xext PROPERTIES
      IMPORTED_LOCATION "${X11_Xext_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xext_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_Xxf86misc_FOUND AND NOT TARGET X11::Xxf86misc)
    add_library(X11::Xxf86misc UNKNOWN IMPORTED)
    set_target_properties(X11::Xxf86misc PROPERTIES
      IMPORTED_LOCATION "${X11_Xxf86misc_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xxf86misc_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11;X11::Xext")
  endif ()

  if (X11_Xxf86vm_FOUND AND NOT TARGET X11::Xxf86vm)
    add_library(X11::Xxf86vm UNKNOWN IMPORTED)
    set_target_properties(X11::Xxf86vm PROPERTIES
      IMPORTED_LOCATION "${X11_Xxf86vm_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xxf86vm_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11;X11::Xext")
  endif ()

  if (X11_Xfixes_FOUND AND NOT TARGET X11::Xfixes)
    add_library(X11::Xfixes UNKNOWN IMPORTED)
    set_target_properties(X11::Xfixes PROPERTIES
      IMPORTED_LOCATION "${X11_Xfixes_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xfixes_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_Xft_FOUND AND NOT TARGET X11::Xft)
    add_library(X11::Xft UNKNOWN IMPORTED)
    set_target_properties(X11::Xft PROPERTIES
      IMPORTED_LOCATION "${X11_Xft_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xft_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xrender;X11::X11;Fontconfig::Fontconfig;Freetype::Freetype")
  endif ()

  if (X11_Xi_FOUND AND NOT TARGET X11::Xi)
    add_library(X11::Xi UNKNOWN IMPORTED)
    set_target_properties(X11::Xi PROPERTIES
      IMPORTED_LOCATION "${X11_Xi_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xi_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
  endif ()

  if (X11_Xinerama_FOUND AND NOT TARGET X11::Xinerama)
    add_library(X11::Xinerama UNKNOWN IMPORTED)
    set_target_properties(X11::Xinerama PROPERTIES
      IMPORTED_LOCATION "${X11_Xinerama_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xinerama_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
  endif ()

  if (X11_Xkb_FOUND AND NOT TARGET X11::Xkb)
    add_library(X11::Xkb INTERFACE IMPORTED)
    set_target_properties(X11::Xkb PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xkb_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_xkbcommon_FOUND AND NOT TARGET X11::xkbcommon)
    add_library(X11::xkbcommon UNKNOWN IMPORTED)
    set_target_properties(X11::xkbcommon PROPERTIES
      IMPORTED_LOCATION "${X11_xkbcommon_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_xkbcommon_INCLUDE_PATH}")
  endif ()

  if (X11_xkbcommon_X11_FOUND AND NOT TARGET X11::xkbcommon_X11)
    add_library(X11::xkbcommon_X11 UNKNOWN IMPORTED)
    set_target_properties(X11::xkbcommon_X11 PROPERTIES
      IMPORTED_LOCATION "${X11_xkbcommon_X11_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_xkbcommon_X11_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11;X11::xkbcommon")
  endif ()

  if (X11_xkbfile_FOUND AND NOT TARGET X11::xkbfile)
    add_library(X11::xkbfile UNKNOWN IMPORTED)
    set_target_properties(X11::xkbfile PROPERTIES
      IMPORTED_LOCATION "${X11_xkbfile_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_xkbfile_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_Xmu_FOUND AND NOT TARGET X11::Xmu)
    add_library(X11::Xmu UNKNOWN IMPORTED)
    set_target_properties(X11::Xmu PROPERTIES
      IMPORTED_LOCATION "${X11_Xmu_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xmu_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xt;X11::Xext;X11::X11")
  endif ()

  if (X11_Xpm_FOUND AND NOT TARGET X11::Xpm)
    add_library(X11::Xpm UNKNOWN IMPORTED)
    set_target_properties(X11::Xpm PROPERTIES
      IMPORTED_LOCATION "${X11_Xpm_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xpm_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_Xtst_FOUND AND NOT TARGET X11::Xtst)
    add_library(X11::Xtst UNKNOWN IMPORTED)
    set_target_properties(X11::Xtst PROPERTIES
      IMPORTED_LOCATION "${X11_Xtst_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xtst_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xi;X11::Xext;X11::X11")
  endif ()

  if (X11_Xrandr_FOUND AND NOT TARGET X11::Xrandr)
    add_library(X11::Xrandr UNKNOWN IMPORTED)
    set_target_properties(X11::Xrandr PROPERTIES
      IMPORTED_LOCATION "${X11_Xrandr_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xrandr_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xrender;X11::Xext;X11::X11")
  endif ()

  if (X11_Xrender_FOUND AND NOT TARGET X11::Xrender)
    add_library(X11::Xrender UNKNOWN IMPORTED)
    set_target_properties(X11::Xrender PROPERTIES
      IMPORTED_LOCATION "${X11_Xrender_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xrender_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_XRes_FOUND AND NOT TARGET X11::XRes)
    add_library(X11::XRes UNKNOWN IMPORTED)
    set_target_properties(X11::XRes PROPERTIES
      IMPORTED_LOCATION "${X11_XRes_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_XRes_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
  endif ()

  if (X11_Xss_FOUND AND NOT TARGET X11::Xss)
    add_library(X11::Xss UNKNOWN IMPORTED)
    set_target_properties(X11::Xss PROPERTIES
      IMPORTED_LOCATION "${X11_Xss_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xss_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
  endif ()

  if (X11_Xt_FOUND AND NOT TARGET X11::Xt)
    add_library(X11::Xt UNKNOWN IMPORTED)
    set_target_properties(X11::Xt PROPERTIES
      IMPORTED_LOCATION "${X11_Xt_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xt_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::ICE;X11::SM;X11::X11")
  endif ()

  if (X11_Xutil_FOUND AND NOT TARGET X11::Xutil)
    add_library(X11::Xutil INTERFACE IMPORTED)
    set_target_properties(X11::Xutil PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xutil_INCLUDE_PATH}"
      # libX11 contains the implementations for functions in the Xutil.h
      # header.
      INTERFACE_LINK_LIBRARIES "X11::X11")
  endif ()

  if (X11_Xv_FOUND AND NOT TARGET X11::Xv)
    add_library(X11::Xv UNKNOWN IMPORTED)
    set_target_properties(X11::Xv PROPERTIES
      IMPORTED_LOCATION "${X11_Xv_LIB}"
      INTERFACE_INCLUDE_DIRECTORIES "${X11_Xv_INCLUDE_PATH}"
      INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
  endif ()

  mark_as_advanced(
    X11_X11_INCLUDE_PATH
    X11_X11_LIB
    X11_Xext_INCLUDE_PATH
    X11_Xext_LIB
    X11_Xau_LIB
    X11_Xau_INCLUDE_PATH
    X11_xcb_LIB
    X11_xcb_INCLUDE_PATH
    X11_xcb_composite_LIB
    X11_xcb_composite_INCLUDE_PATH
    X11_xcb_cursor_LIB
    X11_xcb_cursor_INCLUDE_PATH
    X11_xcb_damage_LIB
    X11_xcb_damage_INCLUDE_PATH
    X11_xcb_dpms_LIB
    X11_xcb_dpms_INCLUDE_PATH
    X11_xcb_dri2_LIB
    X11_xcb_dri2_INCLUDE_PATH
    X11_xcb_dri3_LIB
    X11_xcb_dri3_INCLUDE_PATH
    X11_xcb_errors_LIB
    X11_xcb_errors_INCLUDE_PATH
    X11_xcb_ewmh_LIB
    X11_xcb_ewmh_INCLUDE_PATH
    X11_xcb_glx_LIB
    X11_xcb_glx_INCLUDE_PATH
    X11_xcb_icccm_LIB
    X11_xcb_icccm_INCLUDE_PATH
    X11_xcb_image_LIB
    X11_xcb_image_INCLUDE_PATH
    X11_xcb_keysyms_LIB
    X11_xcb_keysyms_INCLUDE_PATH
    X11_xcb_present_LIB
    X11_xcb_present_INCLUDE_PATH
    X11_xcb_randr_LIB
    X11_xcb_randr_INCLUDE_PATH
    X11_xcb_record_LIB
    X11_xcb_record_INCLUDE_PATH
    X11_xcb_render_LIB
    X11_xcb_render_INCLUDE_PATH
    X11_xcb_render_util_LIB
    X11_xcb_render_util_INCLUDE_PATH
    X11_xcb_res_LIB
    X11_xcb_res_INCLUDE_PATH
    X11_xcb_screensaver_LIB
    X11_xcb_screensaver_INCLUDE_PATH
    X11_xcb_shape_LIB
    X11_xcb_shape_INCLUDE_PATH
    X11_xcb_shm_LIB
    X11_xcb_shm_INCLUDE_PATH
    X11_xcb_sync_LIB
    X11_xcb_sync_INCLUDE_PATH
    X11_xcb_util_LIB
    X11_xcb_util_INCLUDE_PATH
    X11_xcb_xf86dri_LIB
    X11_xcb_xf86dri_INCLUDE_PATH
    X11_xcb_xfixes_LIB
    X11_xcb_xfixes_INCLUDE_PATH
    X11_xcb_xinerama_LIB
    X11_xcb_xinerama_INCLUDE_PATH
    X11_xcb_xinput_LIB
    X11_xcb_xinput_INCLUDE_PATH
    X11_xcb_xkb_LIB
    X11_X11_xcb_LIB
    X11_xcb_xrm_LIB
    X11_xcb_xrm_INCLUDE_PATH
    X11_xcb_xtest_LIB
    X11_xcb_xtest_INCLUDE_PATH
    X11_xcb_xvmc_LIB
    X11_xcb_xvmc_INCLUDE_PATH
    X11_xcb_xv_LIB
    X11_xcb_xv_INCLUDE_PATH
    X11_X11_xcb_INCLUDE_PATH
    X11_Xlib_INCLUDE_PATH
    X11_Xutil_INCLUDE_PATH
    X11_Xcomposite_INCLUDE_PATH
    X11_Xcomposite_LIB
    X11_Xfixes_LIB
    X11_Xfixes_INCLUDE_PATH
    X11_Xrandr_LIB
    X11_Xrandr_INCLUDE_PATH
    X11_Xdamage_LIB
    X11_Xdamage_INCLUDE_PATH
    X11_Xrender_LIB
    X11_Xrender_INCLUDE_PATH
    X11_XRes_LIB
    X11_XRes_INCLUDE_PATH
    X11_Xxf86misc_LIB
    X11_Xxf86misc_INCLUDE_PATH
    X11_Xxf86vm_LIB
    X11_Xxf86vm_INCLUDE_PATH
    X11_Xi_LIB
    X11_Xi_INCLUDE_PATH
    X11_Xinerama_LIB
    X11_Xinerama_INCLUDE_PATH
    X11_Xtst_LIB
    X11_Xtst_INCLUDE_PATH
    X11_Xcursor_LIB
    X11_Xcursor_INCLUDE_PATH
    X11_dpms_INCLUDE_PATH
    X11_Xt_LIB
    X11_Xt_INCLUDE_PATH
    X11_Xdmcp_LIB
    X11_LIBRARIES
    X11_Xaccessrules_INCLUDE_PATH
    X11_Xaccessstr_INCLUDE_PATH
    X11_Xdmcp_INCLUDE_PATH
    X11_Xkb_INCLUDE_PATH
    X11_Xkblib_INCLUDE_PATH
    X11_xkbcommon_INCLUDE_PATH
    X11_xkbcommon_LIB
    X11_xkbcommon_X11_INCLUDE_PATH
    X11_xkbcommon_X11_LIB
    X11_xkbfile_INCLUDE_PATH
    X11_xkbfile_LIB
    X11_Xmu_INCLUDE_PATH
    X11_Xmu_LIB
    X11_Xss_INCLUDE_PATH
    X11_Xss_LIB
    X11_Xpm_INCLUDE_PATH
    X11_Xpm_LIB
    X11_Xft_LIB
    X11_Xft_INCLUDE_PATH
    X11_Xshape_INCLUDE_PATH
    X11_Xv_LIB
    X11_Xv_INCLUDE_PATH
    X11_XShm_INCLUDE_PATH
    X11_ICE_LIB
    X11_ICE_INCLUDE_PATH
    X11_SM_LIB
    X11_SM_INCLUDE_PATH
    X11_XSync_INCLUDE_PATH
    X11_Xaw_LIB
    X11_Xaw_INCLUDE_PATH
    X11_Xdbe_INCLUDE_PATH
  )
  set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE})
  set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()


code:
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindXCTest
----------

.. versionadded:: 3.3

Functions to help creating and executing XCTest bundles.

An XCTest bundle is a CFBundle with a special product-type
and bundle extension. The Mac Developer Library provides more
information in the `Testing with Xcode`_ document.

.. _Testing with Xcode: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/

Module Functions
^^^^^^^^^^^^^^^^

.. command:: xctest_add_bundle

  The ``xctest_add_bundle`` function creates a XCTest bundle named
  <target> which will test the target <testee>. Supported target types
  for testee are Frameworks and App Bundles::

    xctest_add_bundle(
      <target>  # Name of the XCTest bundle
      <testee>  # Target name of the testee
      )

.. command:: xctest_add_test

  The ``xctest_add_test`` function adds an XCTest bundle to the
  project to be run by :manual:`ctest(1)`. The test will be named
  <name> and tests <bundle>::

    xctest_add_test(
      <name>    # Test name
      <bundle>  # Target name of XCTest bundle
      )

Module Variables
^^^^^^^^^^^^^^^^

The following variables are set by including this module:

.. variable:: XCTest_FOUND

  True if the XCTest Framework and executable were found.

.. variable:: XCTest_EXECUTABLE

  The path to the xctest command line tool used to execute XCTest bundles.

.. variable:: XCTest_INCLUDE_DIRS

  The directory containing the XCTest Framework headers.

.. variable:: XCTest_LIBRARIES

  The location of the XCTest Framework.

#]=======================================================================]

set(_PRESERVED_CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}")

if(CMAKE_EFFECTIVE_SYSTEM_NAME STREQUAL "Apple"
   AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  # Non-macos systems set the CMAKE_FIND_ROOT_PATH_MODE to "ONLY" which
  # restricts the search paths too much to find XCTest.framework. In
  # contrast to the regular system frameworks which reside within the
  # SDK direectory the XCTest framework is located in the respective
  # platform directory which is not added to the CMAKE_FIND_ROOT_PATH
  # (only to CMAKE_SYSTEM_FRAMEWORK_PATH) and therefore not searched.
  #
  # Until this is properly addressed, temporarily add the platform
  # directory to CMAKE_FIND_ROOT_PATH.
  list(APPEND CMAKE_FIND_ROOT_PATH "${_CMAKE_OSX_SYSROOT_PATH}/../..")
endif()

find_path(XCTest_INCLUDE_DIR
  NAMES "XCTest/XCTest.h"
  DOC "XCTest include directory")
mark_as_advanced(XCTest_INCLUDE_DIR)

find_library(XCTest_LIBRARY
  NAMES XCTest
  DOC "XCTest Framework library")
mark_as_advanced(XCTest_LIBRARY)

set(CMAKE_FIND_ROOT_PATH "${_PRESERVED_CMAKE_FIND_ROOT_PATH}")
unset(_PRESERVED_CMAKE_FIND_ROOT_PATH)

execute_process(
  COMMAND xcrun --find xctest
  OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_VARIABLE _xcrun_err)
if(_xcrun_out)
  set(XCTest_EXECUTABLE "${_xcrun_out}" CACHE FILEPATH "XCTest executable")
  mark_as_advanced(XCTest_EXECUTABLE)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(XCTest
  FOUND_VAR XCTest_FOUND
  REQUIRED_VARS XCTest_LIBRARY XCTest_INCLUDE_DIR XCTest_EXECUTABLE)

if(XCTest_FOUND)
  set(XCTest_INCLUDE_DIRS "${XCTest_INCLUDE_DIR}")
  set(XCTest_LIBRARIES "${XCTest_LIBRARY}")
endif(XCTest_FOUND)

function(xctest_add_bundle target testee)
  if(NOT XCTest_FOUND)
    message(FATAL_ERROR "XCTest is required to create a XCTest Bundle.")
  endif(NOT XCTest_FOUND)

  if(NOT CMAKE_OSX_SYSROOT)
    message(FATAL_ERROR "Adding XCTest bundles requires CMAKE_OSX_SYSROOT to be set.")
  endif()

  add_library(${target} MODULE ${ARGN})

  set_target_properties(${target} PROPERTIES
    BUNDLE TRUE
    XCTEST TRUE
    XCTEST_TESTEE ${testee})

  target_link_libraries(${target} PRIVATE "-framework Foundation")
  target_link_libraries(${target} PRIVATE ${XCTest_LIBRARIES})
  target_include_directories(${target} PRIVATE ${XCTest_INCLUDE_DIRS})

  # retrieve testee target type
  if(NOT TARGET ${testee})
    message(FATAL_ERROR "${testee} is not a target.")
  endif()
  get_property(_testee_type TARGET ${testee} PROPERTY TYPE)
  get_property(_testee_framework TARGET ${testee} PROPERTY FRAMEWORK)
  get_property(_testee_macosx_bundle TARGET ${testee} PROPERTY MACOSX_BUNDLE)

  if(_testee_type STREQUAL "SHARED_LIBRARY" AND _testee_framework)
    # testee is a Framework
    target_link_libraries(${target} PRIVATE ${testee})

  elseif(_testee_type STREQUAL "STATIC_LIBRARY")
    # testee is a static library
    target_link_libraries(${target} PRIVATE ${testee})

  elseif(_testee_type STREQUAL "EXECUTABLE" AND _testee_macosx_bundle)
    # testee is an App Bundle
    add_dependencies(${target} ${testee})
    if(XCODE)
      set_target_properties(${target} PROPERTIES
        XCODE_ATTRIBUTE_BUNDLE_LOADER "$(TEST_HOST)"
        XCODE_ATTRIBUTE_TEST_HOST "$<TARGET_FILE:${testee}>")
      if(XCODE_VERSION VERSION_GREATER_EQUAL 7.3)
        # The Xcode "new build system" used a different path until Xcode 12.5.
        if(CMAKE_XCODE_BUILD_SYSTEM EQUAL 12 AND
           XCODE_VERSION VERSION_LESS 12.5 AND
           NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
          set(_output_directory "$<TARGET_BUNDLE_CONTENT_DIR:${testee}>")
        else()
          set(_output_directory "$<TARGET_BUNDLE_CONTENT_DIR:${testee}>/PlugIns")
        endif()
        set_target_properties(${target} PROPERTIES
          LIBRARY_OUTPUT_DIRECTORY "${_output_directory}")
      endif()
    else(XCODE)
      target_link_libraries(${target}
        PRIVATE -bundle_loader $<TARGET_FILE:${testee}>)
    endif(XCODE)

  else()
    message(FATAL_ERROR "Testee ${testee} is of unsupported type.")
  endif()
endfunction(xctest_add_bundle)

function(xctest_add_test name bundle)
  if(NOT XCTest_EXECUTABLE)
    message(FATAL_ERROR "XCTest executable is required to register a test.")
  endif()

  # check that bundle is a XCTest Bundle

  if(NOT TARGET ${bundle})
    message(FATAL_ERROR "${bundle} is not a target.")
  endif(NOT TARGET ${bundle})

  get_property(_test_type TARGET ${bundle} PROPERTY TYPE)
  get_property(_test_bundle TARGET ${bundle} PROPERTY BUNDLE)
  get_property(_test_xctest TARGET ${bundle} PROPERTY XCTEST)

  if(NOT _test_type STREQUAL "MODULE_LIBRARY"
       OR NOT _test_xctest OR NOT _test_bundle)
    message(FATAL_ERROR "Test ${bundle} is not an XCTest Bundle")
  endif()

  # get and check testee properties

  get_property(_testee TARGET ${bundle} PROPERTY XCTEST_TESTEE)
  if(NOT TARGET ${_testee})
    message(FATAL_ERROR "${_testee} is not a target.")
  endif()

  get_property(_testee_type TARGET ${_testee} PROPERTY TYPE)
  get_property(_testee_framework TARGET ${_testee} PROPERTY FRAMEWORK)

  # register test

  add_test(
    NAME ${name}
    COMMAND ${XCTest_EXECUTABLE} $<TARGET_BUNDLE_DIR:${bundle}>)

  # point loader to testee in case rpath is disabled

  if(_testee_type STREQUAL "SHARED_LIBRARY" AND _testee_framework)
    set_property(TEST ${name} APPEND PROPERTY
      ENVIRONMENT DYLD_FRAMEWORK_PATH=$<TARGET_LINKER_FILE_DIR:${_testee}>/..)
  endif()
endfunction(xctest_add_test)