Fix building without D-Bus (and make it optional)

Summary:
* centralize control in a single var MARBLE_NO_DBUS
  (following pattern of MARBLE_NO_WEBKITWIDGETS)
* move setting option BUILD_WITH_DBUS before finding of deps,
  so it can influence what is searched for
  (not sure if for Android this should be an option at all,
  but keeping for now as is)

Test Plan: Builds with BUILD_WITH_DBUS=ON and OFF for me.

Reviewers: #marble, nienhueser, rahn

Differential Revision: https://phabricator.kde.org/D2147
parent a3399c11
......@@ -49,6 +49,15 @@ include( MarbleMacros )
# if this option is set, srtm.jpg will not be installed but the generated tiles instead
option(MOBILE "Create a Marble version optimized for handheld devices")
####################################################
# Build a D-Bus interface for the Marble widget
# This is disabled by default for all win32, apple and Android
if(WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL Android)
option(BUILD_WITH_DBUS "Build the D-Bus interface for the Marble widget" OFF)
else()
option(BUILD_WITH_DBUS "Build the D-Bus interface for the Marble widget" ON)
endif()
#######################################################
# Specific options for building for different platforms
......@@ -67,7 +76,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL Android)
else()
find_package(Qt5WebKit)
find_package(Qt5WebKitWidgets)
find_package(Qt5DBus REQUIRED)
if ( NOT Qt5WebKitWidgets_FOUND )
set ( MARBLE_NO_WEBKITWIDGETS TRUE )
......@@ -86,6 +94,15 @@ find_package(Qt5Concurrent REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
if (BUILD_WITH_DBUS)
find_package(Qt5DBus)
if (NOT Qt5DBus_FOUND)
set(MARBLE_NO_DBUS TRUE)
endif()
else()
set(MARBLE_NO_DBUS TRUE)
endif()
if(QTONLY)
# Forward the old QTONLY=TRUE option to the new WITH_KDE=FALSE
# needs to be written to cache and forcefully, otherwise macro_optional_find_package's
......@@ -105,15 +122,6 @@ if( WIN32 )
add_definitions( -D_USE_MATH_DEFINES )
endif( WIN32 )
####################################################
# Build a D-Bus interface for marble
# This is disabled by default for all win32, apple and Qt-Only builds
if(WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL Android)
option(BUILD_WITH_DBUS "Build the D-Bus interface for the Marble widget" OFF)
else()
option(BUILD_WITH_DBUS "Build the D-Bus interface for the Marble widget" ON)
endif()
####################################################
# build unit tests
......
......@@ -3,9 +3,9 @@ if(MSVC)
add_definitions(-D_USE_MATH_DEFINES=1)
endif(MSVC)
if(BUILD_WITH_DBUS)
add_definitions(-DMARBLE_DBUS)
endif(BUILD_WITH_DBUS)
if(NOT MARBLE_NO_DBUS)
add_definitions(-DMARBLE_DBUS)
endif()
if( Qt5Quick_FOUND )
OPTION(IGNORE_CMAKE_INSTALL_PREFIX_FOR_DECLARATIVE_PLUGINS "Install Marble Qt Declarative plugins to QT_IMPORTS_DIR even if that is out of the CMAKE_INSTALL_PREFIX")
......
......@@ -22,8 +22,13 @@ target_link_libraries (
Qt5::PrintSupport
LINK_PRIVATE
Qt5::Network
Qt5::DBus
)
if (NOT MARBLE_NO_DBUS)
target_link_libraries( marbleui
LINK_PRIVATE
Qt5::DBus
)
endif ()
if(WIN32)
# TODO: PUBLIC or can be PRIVATE?
......
......@@ -295,7 +295,7 @@ else()
)
endif()
if (NOT QT_NO_DBUS AND NOT CMAKE_SYSTEM_NAME STREQUAL Android)
if (NOT MARBLE_NO_DBUS)
LIST(APPEND marblewidget_SRCS
MarbleDBusInterface.cpp
)
......@@ -389,7 +389,7 @@ if (NOT MARBLE_NO_WEBKITWIDGETS)
Qt5::WebKitWidgets
)
endif ()
if (NOT QT_NO_DBUS AND NOT CMAKE_SYSTEM_NAME STREQUAL Android)
if (NOT MARBLE_NO_DBUS)
TARGET_LINK_LIBRARIES (${MARBLEWIDGET}
LINK_PRIVATE
Qt5::DBus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment