Fix CMake build on macOS (don't try to link against Qt's X11Extras) (#267)

macOS is identified as UNIX by CMake, but Qt doesn't actually use X11
there (and X11 support is not available by default anyway). Change the
condition that includes X11Extras to if (UNIX AND NOT APPLE) instead of
just if (UNIX) to mitigate that. This makes the build on macOS work
with CMake.

Co-authored-by: Christian Seiler <c.seiler@luxflux.de>
This commit is contained in:
Christian Seiler 2020-10-21 22:05:36 +02:00 committed by GitHub
parent 46fa22dc6a
commit 0c88457037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -2,5 +2,7 @@ include(CMakeFindDependencyMacro)
find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
if(UNIX AND NOT APPLE)
find_dependency(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake")

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT}) project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
find_package(Qt5 5.5 COMPONENTS Core Gui Widgets REQUIRED) find_package(Qt5 5.5 COMPONENTS Core Gui Widgets REQUIRED)
if (UNIX) if (UNIX AND NOT APPLE)
find_package(Qt5 5.5 COMPONENTS X11Extras REQUIRED) find_package(Qt5 5.5 COMPONENTS X11Extras REQUIRED)
endif() endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -48,7 +48,7 @@ set(ads_HEADERS
IconProvider.h IconProvider.h
DockComponentsFactory.h DockComponentsFactory.h
) )
if (UNIX) if (UNIX AND NOT APPLE)
set(ads_SRCS linux/FloatingWidgetTitleBar.cpp ${ads_SRCS}) set(ads_SRCS linux/FloatingWidgetTitleBar.cpp ${ads_SRCS})
set(ads_HEADERS linux/FloatingWidgetTitleBar.h ${ads_HEADERS}) set(ads_HEADERS linux/FloatingWidgetTitleBar.h ${ads_HEADERS})
endif() endif()
@ -60,7 +60,7 @@ else()
target_compile_definitions(qtadvanceddocking PRIVATE ADS_SHARED_EXPORT) target_compile_definitions(qtadvanceddocking PRIVATE ADS_SHARED_EXPORT)
endif() endif()
target_link_libraries(qtadvanceddocking PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets) target_link_libraries(qtadvanceddocking PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets)
if (UNIX) if (UNIX AND NOT APPLE)
target_link_libraries(qtadvanceddocking PUBLIC Qt5::X11Extras) target_link_libraries(qtadvanceddocking PUBLIC Qt5::X11Extras)
endif() endif()
set_target_properties(qtadvanceddocking PROPERTIES set_target_properties(qtadvanceddocking PROPERTIES