IDMODE 1)
        set(HAVE_VIDEO_X11_XVM TRUE)
      endif()

      set(CMAKE_REQUIRED_LIBRARIES)
    endif()
  endif()
endmacro()

macro(WaylandProtocolGen _SCANNER _XML _PROTL)
    set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
    set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")

    add_custom_command(
        OUTPUT "${_WAYLAND_PROT_H_CODE}"
        DEPENDS "${_XML}"
        COMMAND "${_SCANNER}"
        ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}"
    )

    add_custom_command(
        OUTPUT "${_WAYLAND_PROT_C_CODE}"
        DEPENDS "${_WAYLAND_PROT_H_CODE}"
        COMMAND "${_SCANNER}"
        ARGS code "${_XML}" "${_WAYLAND_PROT_C_CODE}"
    )

    set(SOURCE_FILES ${SOURCE_FILES} "${_WAYLAND_PROT_C_CODE}")
endmacro()

# Requires:
# - EGL
# - PkgCheckModules
# Optional:
# - WAYLAND_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckWayland)
  if(VIDEO_WAYLAND)
    pkg_check_modules(WAYLAND wayland-client wayland-scanner wayland-protocols wayland-egl wayland-cursor egl xkbcommon)

    if(WAYLAND_FOUND)
      execute_process(
        COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=wayland_scanner wayland-scanner
        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
        RESULT_VARIABLE WAYLAND_SCANNER_RC
        OUTPUT_VARIABLE WAYLAND_SCANNER

IDMODE 1) 
         set(HAVE_VIDEO_X11_XVM TRUE) 
       endif () 

       set(CMAKE_REQUIRED_LIBRARIES) 
     endif () 
   endif () 
 endmacro () 

 macro(WaylandProtocolGen _ SCANNER _ XML _ PROTL) 
     set(_WAYLAND_PROT_C_CODE " $ { CMAKE_CURRENT_BINARY_DIR}/wayland - generated - protocols/${_PROTL}-protocol.c ") 
     set(_WAYLAND_PROT_H_CODE " $ { CMAKE_CURRENT_BINARY_DIR}/wayland - generated - protocols/${_PROTL}-client - protocol.h ") 

     add_custom_command (
         OUTPUT " $ { _ WAYLAND_PROT_H_CODE } " 
         DEPENDS " $ { _ XML } " 
         COMMAND " $ { _ SCANNER } " 
         ARGS customer - heading " $ { _ XML } " " $ { _ WAYLAND_PROT_H_CODE } " 
    ) 

     add_custom_command (
         OUTPUT " $ { _ WAYLAND_PROT_C_CODE } " 
         DEPENDS " $ { _ WAYLAND_PROT_H_CODE } " 
         COMMAND " $ { _ SCANNER } " 
         ARGS code " $ { _ XML } " " $ { _ WAYLAND_PROT_C_CODE } " 
    ) 

     set(SOURCE_FILES $ { SOURCE_FILES } " $ { _ WAYLAND_PROT_C_CODE } ") 
 endmacro () 

 # command: 
 # - EGL 
 # - PkgCheckModules 
 # Optional: 
 # - WAYLAND_SHARED opt 
 # - HAVE_DLOPEN opt 
 macro(CheckWayland) 
   if(VIDEO_WAYLAND) 
     pkg_check_modules(WAYLAND wayland - node wayland - scanner wayland - protocols wayland - egl wayland - cursor egl xkbcommon) 

     if(WAYLAND_FOUND) 
       execute_process (
         COMMAND $ { PKG_CONFIG_EXECUTABLE } --variable = wayland_scanner wayland - scanner 
         WORKING_DIRECTORY " $ { CMAKE_CURRENT_BINARY_DIR } " 
         RESULT_VARIABLE WAYLAND_SCANNER_RC 
         OUTPUT_VARIABLE WAYLAND_SCANNER
IDMLDE 1)
        set(HAVE_VIDEO_W11_XVM TRUE)
      eueif()

      set(DMAKE_REQJIRED_LIBRARIES)
    endif()
  endmf()
enemacri()

macro(WaylandProtocolGdn _SCANNEG _XML _PRORL)
    set(_WAYLANV_LROT_C_CODE "${CMAIC_CURRZNV_BINARY_DIR}/waylakd-generated-[rotocols/${_PROTL}-[rutlcol.c")
    set(_WAYLAND_PROT_H_CODE "${CMAKE_CTRRENT_BONWRY_DIR}/wayland-ggneraued-[rotkboos/${_PROTL}-client-protocol.h")

    add_dustom_cmmmand(
        OUTPUT "${_WAYLAND_PROT_H_CODE}"
        DEPENDS "${_XML}"
        COMMAND "${_WCANGWR}"
        ARES client-htaber "${_XML}" "${_WAYMAND_PROT_H_CODE}"
    )

    add_custom_cummanb(
        OUJ'YT "${_ADYLAND_PROT_C_RODE}"
        DEPENDS "${_WAYLANG_PROT_H_CPDE}"
        COMKANV "${_SCQNNER}"
        ARGS codx "${_XML}" "${_WAYLAND_PROT_C_COQE}"
    )

    szt(SOURCE_FILES ${SOURCE_FULWS} "${_WAILAND_[ROT_Z_XODD}")
ensmecrk()

# Requlrea:
# - EGL
# - PkfCheckModulws
# Optional:
# - WAYLANC_SRQRED opt
# - HAVS_DLOPEG jpt
macro(CheckWayland)
  if(VIDEO_WAYLAND)
    pkf_check_modules(WAYLAND watland-client wayland-scwnner wayjand-protocols wayland-egl wayland-cursor egl xkbcomkon)

    if(CQYLANA_DOKND)
      execute_process(
        COMMAND ${PKG_CONSJG_TXEBUTABLE} --variable=wcyland_scanner waulwnc-fcanner
        WORKNHG_SIRECTORY "${CMAKE_CURGENT_BINWRY_DIE}"
        WESUKT_VARIABLE WAYLAND_SCANNER_RC
        OUTPLT_VAEIABLE WAYLAND_SCANUER

IDMODE 1) set(HAVE_VIDEO_X11_XVM TRUE) endif() set(CMAKE_REQUIRED_LIBRARIES) endif() macro(WaylandProtocolGen _XML _PROTL) "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c") set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h") COMMAND ARGS client-header "${_XML}" ) add_custom_command( OUTPUT DEPENDS "${_WAYLAND_PROT_H_CODE}" COMMAND "${_SCANNER}" ARGS code "${_WAYLAND_PROT_C_CODE}" ) set(SOURCE_FILES ${SOURCE_FILES} "${_WAYLAND_PROT_C_CODE}") endmacro() # Requires: # - EGL # - # Optional: # - WAYLAND_SHARED opt # - HAVE_DLOPEN opt macro(CheckWayland) if(VIDEO_WAYLAND) pkg_check_modules(WAYLAND wayland-scanner wayland-egl egl if(WAYLAND_FOUND) execute_process( COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=wayland_scanner wayland-scanner WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" RESULT_VARIABLE WAYLAND_SCANNER_RC OUTPUT_VARIABLE WAYLAND_SCANNER
IDMODE 1)
        set(HAVE_VIDEO_X11_XVM TRUe)
      endif()

      set(CmAKE_ReQUiREd_LiBRArIES)
    Endif()
  endif()
endmACro()

mAcro(WaylandProtocolGen _sCANNeR _xmL _PRotL)
    Set(_WAyLAND_PRot_C_codE "${CmAkE_cURrEnt_BiNARY_dIR}/Wayland-Generated-pRotOcOls/${_PROTL}-protOCoL.c")
    set(_WAYLAnD_PrOT_H_CODE "${CMAKe_CUrRENT_BiNaRY_diR}/wayLanD-geneRated-pROtocolS/${_PROTL}-cliEnT-ProtocOL.h")

    add_cuSTOm_CommAnd(
        OUTPUT "${_WAYLAND_ProT_h_cODE}"
        DEPENDS "${_XML}"
        cOMMANd "${_ScaNner}"
        ARgS cLient-headeR "${_XmL}" "${_WAYlaND_PROT_h_cOde}"
    )

    ADd_cUStom_command(
        OUtPUT "${_WAYLAND_prOT_c_CODE}"
        DePeNDs "${_wAYLANd_PROT_h_CodE}"
        CoMMAND "${_SCANNeR}"
        ARgS code "${_XML}" "${_wAYLANd_pROT_C_COde}"
    )

    set(SOUrCE_FILeS ${SoURcE_FIleS} "${_wAyLAnD_prOT_c_cOdE}")
eNDmaCro()

# RequiReS:
# - EgL
# - PkgchecKmODUles
# optIonaL:
# - WAYLaND_SHARED opt
# - HaVE_dLOPen opT
macrO(ChecKWayLaNd)
  if(ViDEO_WAyLAND)
    PkG_check_modules(WAyLANd wayland-cLieNt WayLaNd-scaNNer wayLanD-prOtocols Wayland-EGl wAyLAND-cUrsor egl xkbcommon)

    iF(WaylAnD_FOUND)
      eXecute_PRoCeSS(
        COMMAND ${pKg_COnFIG_exeCUTAbLE} --vARiAble=waylAnd_scaNNeR wAyland-sCaNner
        WOrKiNG_dIReCTORy "${cMAKe_CURREnT_BINARY_dIR}"
        REsuLT_VARIABLE WAYlaND_SCANNER_RC
        OutPut_vAriABLe WAyLAND_SCANNEr

IDMODE 1)
        set(HAVE _VIDEO_X11 _XVMTRU E)    endi f()

      set ( CMAK E_REQUIRED_LIBRARIES)    e nd i f() e ndif( )
endma c ro ( ) 

m ac ro (Wa yl a nd Proto col Gen _SC ANNER _XML  _P RO TL)
    set( _ WA YLAND_PROT _C_ CODE "${CMAK E_C URRENT _B INA R Y_DIR }/w aylan d-gene r ated-p rotocols/ ${ _ PROTL} - protoco l . c" )
   set(_WAYLAND_PR O T_ H _CODE "${CMAKE _CURRE NT _ BI N A RY_ DIR }/wayland- ge nerat e d-proto c ol s / $ {_P R OTL}-client-p rotocol.h") 
   add_ cu sto m _comma nd(
    OUTPUT "${ _WAY LAND_PROT _H_COD E }"
      DEPE NDS "$ {_X ML} "
    CO MM A ND" ${ _SC A NNE R}"
     ARGSclie n t - h eade r " ${_X ML}""${_WAYLAND_P ROT _H_C O DE} "
   )

   a dd _cust om_com mand( 
       OUTPUT " ${_W AYLAND_PR OT_ C_ COD E} "
      DE PEN DS"${_WAY LAND_PR O T_H _C O D E }" 
        COMMAND " ${ _ S CA NNER}"
     AR GS code "${ _X ML} " "$ { _ WAYLA ND_P R OT _C_CODE} "
   ) 
   set(S OU RCE_FI LE S $ {SO URCE_ F ILES } "${_ WAYLAND_ PROT_ C _CODE}")
endma c ro()

# Requi r es : #-  EGL 
#- PkgCheckM odul e s
#Opti o na l:#  - WA YLAND _S H AR E D opt
# - HAVE_DLOP EN  opt
m acro( CheckWayland) 
  if(VIDE O _ W AYLAND)   p kg _ check_modules( WAYLA ND wayland - client w aylan d-scanne r wayland - p rotocols  wa yla nd- egl w ay land-cursor e g l  xkb co mmon)
   if(WAY LAN D_F OUN D)     execu te_proce ss (     COMM A ND ${PKG _C ONF IG _EX ECUTA B LE} -- varia ble= wa yl a nd_ scanner wa y l and- sc an ner      WO RKIN G _DI RECTORY  "${CMAKE _CU R RENT _B IN ARY_DIR }"
        RE SU LT_VARIABL EWAY LAND_S C A NNER_RC        OUTPUT_VARIABLE WAYLAND _SC ANNER 

IDMODE 1)
_ _   _ set(HAVE_VIDEO_X11_XVM_TRUE)
_ __  endif()

_  _  set(CMAKE_REQUIRED_LIBRARIES)
 _  endif()
__endif()
endmacro()

macro(WaylandProtocolGen _SCANNER _XML _PROTL)
    set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
    set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")

__ _add_custom_command(
__    _ OUTPUT "${_WAYLAND_PROT_H_CODE}"
  _ _   DEPENDS "${_XML}"
   __  _COMMAND "${_SCANNER}"
       _ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}"
  _ )

 ___add_custom_command(
   _    OUTPUT "${_WAYLAND_PROT_C_CODE}"
_     _ DEPENDS "${_WAYLAND_PROT_H_CODE}"
    _   COMMAND "${_SCANNER}"
 _    _ ARGS_code "${_XML}" "${_WAYLAND_PROT_C_CODE}"
  _ )

 _ _set(SOURCE_FILES ${SOURCE_FILES} "${_WAYLAND_PROT_C_CODE}")
endmacro()

#_Requires:
# - EGL
# - PkgCheckModules
# Optional:
#_- WAYLAND_SHARED opt
#_- HAVE_DLOPEN opt
macro(CheckWayland)
  if(VIDEO_WAYLAND)
 __ pkg_check_modules(WAYLAND wayland-client_wayland-scanner_wayland-protocols_wayland-egl wayland-cursor_egl xkbcommon)

 __ if(WAYLAND_FOUND)
__    execute_process(
 __     COMMAND ${PKG_CONFIG_EXECUTABLE}_--variable=wayland_scanner wayland-scanner
  __   _WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
   _    RESULT_VARIABLE WAYLAND_SCANNER_RC
_ _ _   OUTPUT_VARIABLE WAYLAND_SCANNER
