mirror of
https://github.com/obsproject/obs-studio
synced 2025-04-29 15:57:26 +08:00
cmake: Replace Xcb CMake finders with ECM
This commit is contained in:
parent
190389ec11
commit
1bf84a6901
@ -1,106 +0,0 @@
|
||||
#[=======================================================================[.rst
|
||||
FindX11-xcb
|
||||
-----------
|
||||
|
||||
FindModule for x11-xcb and associated libraries
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
Updated FindModule to CMake standards
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
This module defines the :prop_tgt:`IMPORTED` target ``X11::x11-xcb``.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module sets the following variables:
|
||||
|
||||
``X11-xcb_FOUND``
|
||||
True, if all required components and the core library were found.
|
||||
``X11-xcb_VERSION``
|
||||
Detected version of found x11-xcb libraries.
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``X11-xcb_LIBRARY``
|
||||
Path to the library component of x11-xcb.
|
||||
``X11-xcb_INCLUDE_DIR``
|
||||
Directory containing ``Xlib-xcb.h``.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_search_module(PC_X11-xcb QUIET x11-xcb)
|
||||
endif()
|
||||
|
||||
find_path(
|
||||
X11-xcb_INCLUDE_DIR
|
||||
NAMES X11/Xlib-xcb.h
|
||||
HINTS ${PC_X11-xcb_INCLUDE_DIRS}
|
||||
PATHS /usr/include /usr/local/include
|
||||
DOC "X11-xcb include directory"
|
||||
)
|
||||
|
||||
find_library(
|
||||
X11-xcb_LIBRARY
|
||||
NAMES X11-xcb
|
||||
HINTS ${PC_x11-xcb-LIBRARY_DIRS}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
DOC "X11-xcb location"
|
||||
)
|
||||
|
||||
if(PC_X11-xcb_VERSION VERSION_GREATER 0)
|
||||
set(X11-xcb_VERSION ${PC_X11-xcb_VERSION})
|
||||
else()
|
||||
if(NOT X11-xcb_FIND_QUIETLY)
|
||||
message(AUTHOR_WARNING "Failed to find X11-xcb version.")
|
||||
endif()
|
||||
set(X11-xcb_VERSION 0.0.0)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(
|
||||
X11-xcb
|
||||
REQUIRED_VARS X11-xcb_LIBRARY X11-xcb_INCLUDE_DIR
|
||||
VERSION_VAR X11-xcb_VERSION
|
||||
REASON_FAILURE_MESSAGE "Ensure that X11-xcb is installed on the system."
|
||||
)
|
||||
mark_as_advanced(X11-xcb_INCLUDE_DIR X11-xcb_LIBRARY)
|
||||
|
||||
if(X11-xcb_FOUND)
|
||||
if(NOT TARGET X11::x11-xcb)
|
||||
if(IS_ABSOLUTE "${X11-xcb_LIBRARY}")
|
||||
add_library(X11::x11-xcb UNKNOWN IMPORTED)
|
||||
set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LOCATION "${X11-xcb_LIBRARY}")
|
||||
else()
|
||||
add_library(X11::x11-xcb INTERFACE IMPORTED)
|
||||
set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LIBNAME "${X11-xcb_LIBRARY}")
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
X11::x11-xcb
|
||||
PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "${PC_X11-xcb_CFLAGS_OTHER}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${X11-xcb_INCLUDE_DIR}"
|
||||
VERSION ${X11-xcb_VERSION}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FeatureSummary)
|
||||
set_package_properties(
|
||||
X11-xcb
|
||||
PROPERTIES
|
||||
URL "https://www.X.org"
|
||||
DESCRIPTION
|
||||
"Provides functions needed by clients which take advantage of Xlib/XCB to mix calls to both Xlib and XCB over the same X connection."
|
||||
)
|
@ -1,305 +0,0 @@
|
||||
#[=======================================================================[.rst
|
||||
FindXcb
|
||||
-------
|
||||
|
||||
FindModule for XCB and associated libraries
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
Updated FindModule to CMake standards
|
||||
|
||||
Components
|
||||
^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 1.0
|
||||
|
||||
This module contains provides several components:
|
||||
|
||||
``xcb-xcb``
|
||||
``xcb-composite``
|
||||
``xcb-damage``
|
||||
``xcb-dri2,``
|
||||
``xcb-ewmh``
|
||||
``xcb-glx``
|
||||
``xcb-icccm``
|
||||
``xcb-image``
|
||||
``xcb-keysyms
|
||||
``xcb-randr``
|
||||
``xcb-render``
|
||||
``xcb-renderutil``
|
||||
``xcb-shape``
|
||||
``xcb-shm``
|
||||
``xcb-sync``
|
||||
``xcb-util
|
||||
``xcb-xfixes``
|
||||
``xcb-xtest``
|
||||
``xcb-xv``
|
||||
``xcb-xinput``
|
||||
``xcb-xinerama``
|
||||
|
||||
Import targets exist for each component.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
This module defines the :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``xcb::xcb``
|
||||
xcb component
|
||||
|
||||
``xcb::xcb-composite``
|
||||
xcb-composite component
|
||||
|
||||
``xcb::xcb-damage``
|
||||
xcb-damage component
|
||||
|
||||
``xcb::xcb-dri2``
|
||||
xcb-dri2 component
|
||||
|
||||
``xcb::xcb-ewmh``
|
||||
xcb-ewmh component
|
||||
|
||||
``xcb::xcb-glx``
|
||||
xcb-glx component
|
||||
|
||||
``xcb::xcb-icccm``
|
||||
xcb-icccm component
|
||||
|
||||
``xcb::xcb-image``
|
||||
xcb-image component
|
||||
|
||||
``xcb::xcb-keysyms``
|
||||
xcb-keysyms component
|
||||
|
||||
``xcb::xcb-randr``
|
||||
xcb-randr component
|
||||
|
||||
``xcb::xcb-render``
|
||||
xcb-render component
|
||||
|
||||
``xcb::xcb-renderutil``
|
||||
xcb-renderutil component
|
||||
|
||||
``xcb::xcb-shape``
|
||||
xcb-shape component
|
||||
|
||||
``xcb::xcb-shm``
|
||||
xcb-shm component
|
||||
|
||||
``xcb::xcb-sync``
|
||||
xcb-sync component
|
||||
|
||||
``xcb::xcb-util``
|
||||
xcb-util component
|
||||
|
||||
``xcb::xcb-xfixes``
|
||||
xcb-xfixes component
|
||||
|
||||
``xcb::xcb-xtest``
|
||||
xcb-xtest component
|
||||
|
||||
``xcb::xcb-xv``
|
||||
xcb-xv component
|
||||
|
||||
``xcb::xcb-xinput``
|
||||
xcb-xinput component
|
||||
|
||||
``xcb::xcb-xinerema``
|
||||
xcb-xinerema component
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module sets the following variables:
|
||||
|
||||
``Xcb_<COMPONENT>_FOUND``
|
||||
True, if required component was found.
|
||||
``Xcb_<COMPONENT>_VERSION``
|
||||
Detected version of found XCB component library.
|
||||
``Xcb_<COMPONENT>_INCLUDE_DIRS``
|
||||
Include directories needed for XCB component.
|
||||
``Xcb_<COMPONENT>_LIBRARIES``
|
||||
Libraries needed to link to XCB component.
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``Xcb_<COMPONENT>_LIBRARY``
|
||||
Path to the library component of XCB.
|
||||
``Xcb_<COMPONENT>_INCLUDE_DIR``
|
||||
Directory containing ``<COMPONENT>.h``.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
list(
|
||||
APPEND
|
||||
_Xcb_DEFAULT_COMPONENTS
|
||||
xcb
|
||||
xcb-composite
|
||||
xcb-damage
|
||||
xcb-dri2,
|
||||
xcb-ewmh
|
||||
xcb-glx
|
||||
xcb-icccm
|
||||
xcb-image
|
||||
xcb-keysyms
|
||||
xcb-randr
|
||||
xcb-render
|
||||
xcb-renderutil
|
||||
xcb-shape
|
||||
xcb-shm
|
||||
xcb-sync
|
||||
xcb-util
|
||||
xcb-xfixes
|
||||
xcb-xtest
|
||||
xcb-xv
|
||||
xcb-xinput
|
||||
xcb-xinerama
|
||||
)
|
||||
list(
|
||||
APPEND
|
||||
_Xcb_HEADERS
|
||||
xcb.h
|
||||
composite.h
|
||||
damage.h
|
||||
dri2h.h
|
||||
xcb_ewmh.h
|
||||
glx.h
|
||||
xcb_icccm.h
|
||||
xcb_image.h
|
||||
xcb_keysyms.h
|
||||
randr.h
|
||||
render.h
|
||||
xcb_renderutil.h
|
||||
shape.h
|
||||
shm.h
|
||||
sync.h
|
||||
xcb_util.h
|
||||
xfixes.h
|
||||
xtest.h
|
||||
xv.h
|
||||
xinput.h
|
||||
xinerama.h
|
||||
)
|
||||
|
||||
if(NOT Xcb_FIND_COMPONENTS)
|
||||
set(Xcb_FIND_COMPONENTS ${_Xcb_DEFAULT_COMPONENTS})
|
||||
endif()
|
||||
|
||||
# Xcb_find_component: Find and create targets for specified xcb component
|
||||
macro(Xcb_find_component component)
|
||||
list(GET _Xcb_DEFAULT_COMPONENTS ${component} COMPONENT_NAME)
|
||||
list(GET _Xcb_HEADERS ${component} COMPONENT_HEADER)
|
||||
|
||||
if(NOT TARGET xcb::${COMPONENT_NAME})
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_search_module(PC_Xcb_${COMPONENT_NAME} QUIET ${COMPONENT_NAME})
|
||||
endif()
|
||||
|
||||
find_path(
|
||||
Xcb_${COMPONENT_NAME}_INCLUDE_DIR
|
||||
NAMES "xcb/${COMPONENT_HEADER}"
|
||||
HINTS ${PC_Xcb_${COMPONENT_NAME}_INCLUDE_DIRS}
|
||||
PATHS /usr/include /usr/local/include
|
||||
DOC "XCB component ${COMPONENT_NAME} include directory"
|
||||
)
|
||||
|
||||
find_library(
|
||||
Xcb_${COMPONENT_NAME}_LIBRARY
|
||||
NAMES "${COMPONENT_NAME}"
|
||||
HINTS ${PC_Xcb_${COMPONENT_NAME}_LIBRARY_DIRS}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
DOC "XCB component ${COMPONENT_NAME} location"
|
||||
)
|
||||
|
||||
if(PC_Xcb_${COMPONENT_NAME}_VERSION VERSION_GREATER 0)
|
||||
set(Xcb_${COMPONENT_NAME}_VERSION ${PC_Xcb_${COMPONENT_NAME}_VERSION})
|
||||
else()
|
||||
if(NOT Xcb_FIND_QUIETLY)
|
||||
message(AUTHOR_WARNING "Failed to find ${COMPONENT_NAME} version.")
|
||||
endif()
|
||||
set(Xcb_${COMPONENT_NAME}_VERSION 0.0.0)
|
||||
endif()
|
||||
|
||||
if(Xcb_${COMPONENT_NAME}_LIBRARY AND Xcb_${COMPONENT_NAME}_INCLUDE_DIR)
|
||||
set(Xcb_${COMPONENT_NAME}_FOUND TRUE)
|
||||
set(Xcb_${COMPONENT_NAME}_LIBRARIES ${Xcb_${COMPONENT_NAME}_LIBRARY})
|
||||
set(Xcb_${COMPONENT_NAME}_INCLUDE_DIRS ${Xcb_${COMPONENT_NAME}_INCLUDE_DIR})
|
||||
set(Xcb_${COMPONENT_NAME}_DEFINITIONS ${PC_Xcb_${COMPONENT_NAME}_CFLAGS_OTHER})
|
||||
mark_as_advanced(Xcb_${COMPONENT_NAME}_LIBRARY Xcb_${COMPONENT_NAME}_INCLUDE_DIR)
|
||||
|
||||
if(IS_ABSOLUTE "${Xcb_${COMPONENT_NAME}_LIBRARY}")
|
||||
add_library(xcb::${COMPONENT_NAME} UNKNOWN IMPORTED)
|
||||
set_property(TARGET xcb::${COMPONENT_NAME} PROPERTY IMPORTED_LOCATION "${Xcb_${COMPONENT_NAME}_LIBRARY}")
|
||||
else()
|
||||
add_library(xcb::${COMPONENT_NAME} INTERFACE IMPORTED)
|
||||
set_property(TARGET xcb::${COMPONENT_NAME} PROPERTY IMPORTED_LIBNAME "${Xcb_${COMPONENT_NAME}_LIBRARY}")
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
xcb::${COMPONENT_NAME}
|
||||
PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "${PC_Xcb_${COMPONENT_NAME}_CFLAGS_OTHER}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}"
|
||||
VERSION ${Xcb_${COMPONENT_NAME}_VERSION}
|
||||
)
|
||||
list(APPEND Xcb_COMPONENTS xcb::${COMPONENT_NAME})
|
||||
list(APPEND Xcb_LIBRARIES ${Xcb_${COMPONENT_NAME}_LIBRARY})
|
||||
list(APPEND Xcb_INCLUDE_DIRS ${Xcb_${COMPONENT_NAME}_INCLUDE_DIR})
|
||||
if(NOT Xcb_VERSION)
|
||||
set(Xcb_VERSION ${Xcb_${COMPONENT_NAME}_VERSION})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
list(APPEND Xcb_COMPONENTS xcb::${COMPONENT_NAME})
|
||||
set(Xcb_${COMPONENT_NAME}_FOUND TRUE)
|
||||
get_target_property(component_location xcb::${COMPONENT_NAME} IMPORTED_LOCATION)
|
||||
if(NOT component_location)
|
||||
get_target_property(component_location xcb::${COMPONENT_NAME} IMPORTED_LIBNAME)
|
||||
endif()
|
||||
get_target_property(component_include_dir xcb::${COMPONENT_NAME} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
list(APPEND Xcb_LIBRARIES ${component_location})
|
||||
list(APPEND Xcb_INCLUDE_DIRS ${component_include_dir})
|
||||
unset(component_location)
|
||||
unset(component_include_dir)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
foreach(component IN LISTS Xcb_FIND_COMPONENTS)
|
||||
list(FIND _Xcb_DEFAULT_COMPONENTS "${component}" valid_component)
|
||||
|
||||
if(valid_component GREATER_EQUAL 0)
|
||||
xcb_find_component(${valid_component})
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown XCB component required: ${component}.")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES Xcb_INCLUDE_DIRS)
|
||||
|
||||
find_package_handle_standard_args(
|
||||
Xcb
|
||||
REQUIRED_VARS Xcb_LIBRARIES Xcb_INCLUDE_DIRS
|
||||
VERSION_VAR Xcb_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
REASON_FAILURE_MESSAGE "Ensure xcb is installed on the system."
|
||||
)
|
||||
|
||||
unset(_Xcb_DEFAULT_COMPONENTS)
|
||||
unset(_Xcb_HEADERS)
|
||||
|
||||
include(FeatureSummary)
|
||||
set_package_properties(
|
||||
Xcb
|
||||
PROPERTIES
|
||||
URL "https://xcb.freedesktop.org"
|
||||
DESCRIPTION
|
||||
"A replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility."
|
||||
)
|
@ -10,8 +10,8 @@ endif()
|
||||
if(OS_LINUX OR OS_FREEBSD OR OS_OPENBSD)
|
||||
find_package(Libdrm REQUIRED)
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(Xcb REQUIRED xcb)
|
||||
find_package(X11-xcb REQUIRED)
|
||||
find_package(XCB REQUIRED XCB)
|
||||
find_package(X11_XCB REQUIRED)
|
||||
|
||||
if(ENABLE_WAYLAND)
|
||||
find_package(OpenGL REQUIRED EGL)
|
||||
@ -56,8 +56,8 @@ target_link_libraries(
|
||||
"$<$<PLATFORM_ID:Darwin>:$<LINK_LIBRARY:FRAMEWORK,Cocoa.framework>>"
|
||||
"$<$<PLATFORM_ID:Darwin>:$<LINK_LIBRARY:FRAMEWORK,IOSurface.framework>>"
|
||||
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:Libdrm::Libdrm>
|
||||
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:xcb::xcb>
|
||||
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:X11::x11-xcb>
|
||||
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:XCB::XCB>
|
||||
$<$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>:X11::XCB>
|
||||
$<$<AND:$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>,$<BOOL:${ENABLE_WAYLAND}>>:OpenGL::EGL>
|
||||
$<$<AND:$<PLATFORM_ID:Linux,FreeBSD,OpenBSD>,$<BOOL:${ENABLE_WAYLAND}>>:Wayland::Egl>
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
find_package(LibUUID REQUIRED)
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(X11-xcb REQUIRED)
|
||||
find_package(Xcb REQUIRED xcb OPTIONAL_COMPONENTS xcb-xinput)
|
||||
find_package(X11_XCB REQUIRED)
|
||||
find_package(XCB REQUIRED XCB OPTIONAL_COMPONENTS XINPUT)
|
||||
find_package(Gio)
|
||||
find_package(Sysinfo REQUIRED)
|
||||
|
||||
@ -42,13 +42,13 @@ target_compile_definitions(
|
||||
target_link_libraries(
|
||||
libobs
|
||||
PRIVATE
|
||||
X11::x11-xcb
|
||||
xcb::xcb
|
||||
X11::XCB
|
||||
XCB::XCB
|
||||
LibUUID::LibUUID
|
||||
Sysinfo::Sysinfo
|
||||
${CMAKE_DL_LIBS}
|
||||
$<$<NOT:$<BOOL:${HAVE_MATH_IN_STD_LIB}>>:m>
|
||||
$<$<TARGET_EXISTS:xcb::xcb-input>:xcb::xcb-input>
|
||||
$<$<TARGET_EXISTS:XCB::XINPUT>:XCB::XINPUT>
|
||||
)
|
||||
|
||||
if(ENABLE_PULSEAUDIO)
|
||||
|
@ -1,7 +1,7 @@
|
||||
find_package(LibUUID REQUIRED)
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(X11-xcb REQUIRED)
|
||||
find_package(Xcb REQUIRED xcb OPTIONAL_COMPONENTS xcb-xinput)
|
||||
find_package(X11_XCB REQUIRED)
|
||||
find_package(XCB REQUIRED XCB OPTIONAL_COMPONENTS XINPUT)
|
||||
find_package(Gio)
|
||||
|
||||
target_sources(
|
||||
@ -48,12 +48,12 @@ target_link_libraries(
|
||||
libobs
|
||||
PRIVATE
|
||||
X11::X11
|
||||
X11::x11-xcb
|
||||
xcb::xcb
|
||||
X11::XCB
|
||||
XCB::XCB
|
||||
LibUUID::LibUUID
|
||||
${CMAKE_DL_LIBS}
|
||||
$<$<NOT:$<BOOL:${HAVE_MATH_IN_STD_LIB}>>:m>
|
||||
$<$<TARGET_EXISTS:xcb::xcb-input>:xcb::xcb-input>
|
||||
$<$<TARGET_EXISTS:XCB::XINPUT>:XCB::XINPUT>
|
||||
)
|
||||
|
||||
if(ENABLE_PULSEAUDIO)
|
||||
|
@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.28...3.30)
|
||||
find_package(X11 REQUIRED)
|
||||
|
||||
find_package(
|
||||
Xcb
|
||||
REQUIRED xcb xcb-xfixes xcb-randr xcb-shm xcb-xinerama xcb-composite
|
||||
XCB
|
||||
REQUIRED XCB XFIXES RANDR SHM XINERAMA COMPOSITE
|
||||
)
|
||||
|
||||
add_library(linux-capture MODULE)
|
||||
@ -25,16 +25,7 @@ target_sources(
|
||||
|
||||
target_link_libraries(
|
||||
linux-capture
|
||||
PRIVATE
|
||||
OBS::libobs
|
||||
OBS::glad
|
||||
X11::X11
|
||||
xcb::xcb
|
||||
xcb::xcb-xfixes
|
||||
xcb::xcb-randr
|
||||
xcb::xcb-shm
|
||||
xcb::xcb-xinerama
|
||||
xcb::xcb-composite
|
||||
PRIVATE OBS::libobs OBS::glad X11::X11 XCB::XCB XCB::XFIXES XCB::RANDR XCB::SHM XCB::XINERAMA XCB::COMPOSITE
|
||||
)
|
||||
|
||||
set_target_properties_obs(linux-capture PROPERTIES FOLDER plugins PREFIX "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user