From 5e922be4d33071eb0a32cfcb30b77faff396d8ac Mon Sep 17 00:00:00 2001 From: Murat Seker Date: Mon, 14 Sep 2020 20:37:48 +0200 Subject: [PATCH] Fix OSX build (#952) --- CMakeLists.txt | 12 ++++++------ libsrc/grabber/xcb/CMakeLists.txt | 8 +++++++- libsrc/grabber/xcb/XcbGrabber.cpp | 7 +++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 878c47ac..dd5c7606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,11 @@ ELSE() ENDIF() if ( NOT DEFINED PLATFORM ) - if ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86" ) + if ( APPLE ) + SET( PLATFORM "osx") + elseif ( WIN32 ) + SET( PLATFORM "windows") + elseif ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86" ) SET( PLATFORM "x11") elseif ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64") SET( PLATFORM "rpi") @@ -79,10 +83,6 @@ if ( NOT DEFINED PLATFORM ) elseif ( ("${SYSTEM_CPUINFO}" MATCHES "amlogic" OR "${SYSTEM_CPUINFO}" MATCHES "odroid-c2" OR "${SYSTEM_CPUINFO}" MATCHES "vero4k") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 8 ) SET( PLATFORM "amlogic64" ) endif() - elseif ( APPLE ) - SET( PLATFORM "osx") - elseif ( WIN32 ) - SET( PLATFORM "windows") endif() if ( PLATFORM ) message( STATUS "PLATFORM is not defined, evaluated platform: ${PLATFORM}") @@ -108,7 +108,7 @@ ENDMACRO() if ( "${PLATFORM}" MATCHES "osx" ) # add specific prefix paths - FIRSTSUBDIR(SUBDIRQT "/usr/local/Cellar/qt5") + FIRSTSUBDIR(SUBDIRQT "/usr/local/Cellar/qt") FIRSTSUBDIR(SUBDIRPY "/usr/local/opt/python3/Frameworks/Python.framework/Versions") SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${SUBDIRQT} ${SUBDIRPY} "/usr/local/opt/qt5" ) include_directories("/opt/X11/include/") diff --git a/libsrc/grabber/xcb/CMakeLists.txt b/libsrc/grabber/xcb/CMakeLists.txt index ed81a112..792d41ff 100644 --- a/libsrc/grabber/xcb/CMakeLists.txt +++ b/libsrc/grabber/xcb/CMakeLists.txt @@ -4,7 +4,10 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb) find_package(XCB COMPONENTS SHM IMAGE RENDER RANDR REQUIRED) find_package(Qt5Widgets REQUIRED) -find_package(Qt5X11Extras REQUIRED) + +if (NOT APPLE) + find_package(Qt5X11Extras REQUIRED) +endif() include_directories(${XCB_INCLUDE_DIRS}) @@ -19,3 +22,6 @@ target_link_libraries(xcb-grabber ${XCB_LIBRARIES} ) +if (NOT APPLE) + target_link_libraries(xcb-grabber Qt5::X11Extras) +endif() diff --git a/libsrc/grabber/xcb/XcbGrabber.cpp b/libsrc/grabber/xcb/XcbGrabber.cpp index 1e788b30..ffffc0c7 100644 --- a/libsrc/grabber/xcb/XcbGrabber.cpp +++ b/libsrc/grabber/xcb/XcbGrabber.cpp @@ -7,7 +7,10 @@ #include #include + +#ifndef __APPLE__ #include +#endif #include @@ -427,7 +430,11 @@ xcb_render_pictformat_t XcbGrabber::findFormatForVisual(xcb_visualid_t visual) c if (formats == nullptr) return {}; +#ifdef __APPLE__ + int screen = 0; +#else int screen = QX11Info::appScreen(); +#endif xcb_render_pictscreen_iterator_t sit = xcb_render_query_pict_formats_screens_iterator(formats.get());