Skip to content

Commit

Permalink
Require Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart authored and guruz committed Apr 20, 2017
1 parent 51041d0 commit 9aeb587
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 179 deletions.
209 changes: 58 additions & 151 deletions cmake/modules/QtVersionAbstraction.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,47 @@
include (MacroOptionalFindPackage)
include (MacroLogFeature)

option(BUILD_WITH_QT4 "Build with Qt4 no matter if Qt5 was found" OFF)

if( BUILD_WITH_QT4 )
message(STATUS "Search for Qt5 was disabled by option BUILD_WITH_QT4")
else( BUILD_WITH_QT4 )
find_package(Qt5Core QUIET)
endif( BUILD_WITH_QT4 )

if( Qt5Core_FOUND )
message(STATUS "Found Qt5 core, checking for further dependencies...")
find_package(Qt5Network REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Concurrent REQUIRED)
if(UNIT_TESTING)
find_package(Qt5Test REQUIRED)
endif()
if(NOT TOKEN_AUTH_ONLY)
find_package(Qt5Widgets REQUIRED)
if(APPLE)
find_package(Qt5MacExtras REQUIRED)
endif(APPLE)

if(NOT NO_SHIBBOLETH)
find_package(Qt5WebKitWidgets)
find_package(Qt5WebKit)
if(NOT Qt5WebKitWidgets_FOUND)
message(FATAL_ERROR "Qt5WebKit required for Shibboleth. Use -DNO_SHIBBOLETH=1 to disable it.")
endif()
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Concurrent REQUIRED)
if(UNIT_TESTING)
find_package(Qt5Test REQUIRED)
endif()

if(NOT TOKEN_AUTH_ONLY)
find_package(Qt5Widgets REQUIRED)
if(APPLE)
find_package(Qt5MacExtras REQUIRED)
endif(APPLE)

if(NOT NO_SHIBBOLETH)
find_package(Qt5WebKitWidgets)
find_package(Qt5WebKit)
if(NOT Qt5WebKitWidgets_FOUND)
message(FATAL_ERROR "Qt5WebKit required for Shibboleth. Use -DNO_SHIBBOLETH=1 to disable it.")
endif()
endif()
endif()

else( Qt5Core_FOUND )
if(WIN32 OR APPLE)
if (NOT BUILD_WITH_QT4)
message(FATAL_ERROR "Qt 5 not found, but application depends on Qt5 on Windows and Mac OS X")
endif ()
endif(WIN32 OR APPLE)
endif( Qt5Core_FOUND )


if( Qt5Core_FOUND )
message(STATUS "Using Qt 5!")

# We need this to find the paths to qdbusxml2cpp and co
if (WITH_DBUS)
find_package(Qt5DBus REQUIRED)
include_directories(${Qt5DBus_INCLUDES})
add_definitions(${Qt5DBus_DEFINITIONS})
endif (WITH_DBUS)
include_directories(${Qt5Core_INCLUDES})
add_definitions(${Qt5Core_DEFINITIONS})
if (NOT WIN32) #implied on Win32
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif(NOT WIN32)
# We need this to find the paths to qdbusxml2cpp and co
if (WITH_DBUS)
find_package(Qt5DBus REQUIRED)
include_directories(${Qt5DBus_INCLUDES})
add_definitions(${Qt5DBus_DEFINITIONS})
endif (WITH_DBUS)
include_directories(${Qt5Core_INCLUDES})
add_definitions(${Qt5Core_DEFINITIONS})
if (NOT WIN32) #implied on Win32
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif(NOT WIN32)
# set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

if(APPLE AND NOT TOKEN_AUTH_ONLY)
include_directories(${Qt5MacExtras_INCLUDE_DIRS})
add_definitions(${Qt5MacExtras_DEFINITIONS})
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5MacExtras_LIBRARIES})
endif()
if(APPLE AND NOT TOKEN_AUTH_ONLY)
include_directories(${Qt5MacExtras_INCLUDE_DIRS})
add_definitions(${Qt5MacExtras_DEFINITIONS})
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5MacExtras_LIBRARIES})
endif()

if(NOT BUILD_LIBRARIES_ONLY)
macro(qt_wrap_ui)
Expand All @@ -76,9 +56,9 @@ else()
SET(QT_UIC_EXECUTABLE "")
endif()

macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()
macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()

if(NOT TOKEN_AUTH_ONLY)
find_package(Qt5LinguistTools)
Expand All @@ -95,103 +75,30 @@ else()
endmacro()
endif()

macro(qt_add_dbus_interface)
qt5_add_dbus_interface(${ARGN})
endmacro()

macro(qt_add_dbus_adaptor)
qt5_add_dbus_adaptor(${ARGN})
endmacro()

macro(qt_wrap_cpp)
qt5_wrap_cpp(${ARGN})
endmacro()

macro(install_qt_executable)
install_qt5_executable(${ARGN})
endmacro()
macro(qt_add_dbus_interface)
qt5_add_dbus_interface(${ARGN})
endmacro()

macro(setup_qt)
endmacro()
macro(qt_add_dbus_adaptor)
qt5_add_dbus_adaptor(${ARGN})
endmacro()

set(QT_RCC_EXECUTABLE "${Qt5Core_RCC_EXECUTABLE}")
macro(qt_wrap_cpp)
qt5_wrap_cpp(${ARGN})
endmacro()

#Enable deprecated symbols
add_definitions("-DQT_DISABLE_DEPRECATED_BEFORE=0")
macro(install_qt_executable)
install_qt5_executable(${ARGN})
endmacro()

add_definitions("-DQT_USE_QSTRINGBUILDER") #optimize string concatenation
add_definitions("-DQT_MESSAGELOGCONTEXT") #enable function name and line number in debug output
endif( Qt5Core_FOUND )
macro(setup_qt)
endmacro()

if(NOT Qt5Core_FOUND)
message(STATUS "Could not find Qt5, searching for Qt4 instead...")
set(QT_RCC_EXECUTABLE "${Qt5Core_RCC_EXECUTABLE}")

set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork" "QtGui" "QtWebkit")
if( BUILD_TESTS )
list(APPEND NEEDED_QT4_COMPONENTS "QtTest")
endif()
#Enable deprecated symbols
add_definitions("-DQT_DISABLE_DEPRECATED_BEFORE=0")

find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} )
macro_log_feature(QT4_FOUND "Qt" "A cross-platform application and UI framework" "http://www.qt-project.org" TRUE "" "If you see this, although libqt4-devel is installed, check whether the \n qtwebkit-devel package and whatever contains QtUiTools is installed too")

macro(qt5_use_modules)
endmacro()

macro(qt_wrap_ui)
qt4_wrap_ui(${ARGN})
endmacro()

macro(qt_add_resources)
qt4_add_resources(${ARGN})
endmacro()

macro(qt_add_translation)
qt4_add_translation(${ARGN})
endmacro()

macro(qt_add_dbus_interface)
qt4_add_dbus_interface(${ARGN})
endmacro()

macro(qt_add_dbus_adaptor)
qt4_add_dbus_adaptor(${ARGN})
endmacro()

macro(qt_wrap_cpp)
qt4_wrap_cpp(${ARGN})
endmacro()

macro(install_qt_executable)
install_qt4_executable(${ARGN})
endmacro()

macro(setup_qt)
set(QT_USE_QTGUI TRUE)
set(QT_USE_QTSQL TRUE)
set(QT_USE_QTNETWORK TRUE)
set(QT_USE_QTXML TRUE)
set(QT_USE_QTWEBKIT TRUE)
set(QT_USE_QTDBUS TRUE)

include( ${QT_USE_FILE} )
endmacro()

if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
add_definitions("-DQ_DECL_OVERRIDE=override")
else()
add_definitions("-DQ_DECL_OVERRIDE=")
endif()
else() #clang or others
add_definitions("-DQ_DECL_OVERRIDE=override")
endif()

endif()
add_definitions("-DQT_USE_QSTRINGBUILDER") #optimize string concatenation
add_definitions("-DQT_MESSAGELOGCONTEXT") #enable function name and line number in debug output

if( Qt5Core_DIR )
set( HAVE_QT5 TRUE )
else( Qt5Core_DIR )
set( HAVE_QT5 FALSE )
endif( Qt5Core_DIR )
15 changes: 3 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,19 @@ set(synclib_NAME ${APPLICATION_EXECUTABLE}sync)

include(QtVersionAbstraction)
setup_qt()
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
if (${Qt5Core_VERSION_MAJOR} EQUAL "5")
if (${Qt5Core_VERSION_MINOR} EQUAL "4" OR ${Qt5Core_VERSION_MINOR} GREATER 4)
if (${Qt5Core_VERSION_MAJOR} EQUAL "5")
if (${Qt5Core_VERSION_MINOR} EQUAL "6" OR ${Qt5Core_VERSION_MINOR} GREATER 6)
else()
message(STATUS "If possible compile me with Qt 5.4 or higher.")
message(STATUS "If possible compile me with Qt 5.6 or higher.")
endif()
endif()
else()
message(STATUS "If possible compile me with Qt 5.4 or higher.")
endif()


if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()

if(NOT TOKEN_AUTH_ONLY)
if (Qt5Core_DIR)
find_package(Qt5Keychain REQUIRED)
else()
find_package(QtKeychain REQUIRED)
endif()
endif()

add_subdirectory(libsync)
Expand Down
31 changes: 15 additions & 16 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@ owncloud_add_test(XmlParse "")
owncloud_add_test(ChecksumValidator "")

owncloud_add_test(ExcludedFiles "")
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
owncloud_add_test(FileSystem "")
owncloud_add_test(Utility "")
owncloud_add_test(SyncEngine "syncenginetestutils.h")
owncloud_add_test(SyncFileStatusTracker "syncenginetestutils.h")
owncloud_add_test(ChunkingNg "syncenginetestutils.h")
owncloud_add_test(UploadReset "syncenginetestutils.h")
owncloud_add_test(AllFilesDeleted "syncenginetestutils.h")
owncloud_add_test(FolderWatcher "${FolderWatcher_SRC}")

if( UNIX AND NOT APPLE )
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
endif(UNIX AND NOT APPLE)

owncloud_add_benchmark(LargeSync "syncenginetestutils.h")
endif(HAVE_QT5 AND NOT BUILD_WITH_QT4)

owncloud_add_test(FileSystem "")
owncloud_add_test(Utility "")
owncloud_add_test(SyncEngine "syncenginetestutils.h")
owncloud_add_test(SyncFileStatusTracker "syncenginetestutils.h")
owncloud_add_test(ChunkingNg "syncenginetestutils.h")
owncloud_add_test(UploadReset "syncenginetestutils.h")
owncloud_add_test(AllFilesDeleted "syncenginetestutils.h")
owncloud_add_test(FolderWatcher "${FolderWatcher_SRC}")

if( UNIX AND NOT APPLE )
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
endif(UNIX AND NOT APPLE)

owncloud_add_benchmark(LargeSync "syncenginetestutils.h")

SET(FolderMan_SRC ../src/gui/folderman.cpp)
list(APPEND FolderMan_SRC ../src/gui/folder.cpp )
Expand Down

5 comments on commit 9aeb587

@jnweiger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kills all overlays. :-(

@ogoffart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how?

@jnweiger
Copy link
Contributor

@jnweiger jnweiger commented on 9aeb587 Aug 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qt5 is now a hard requirement. If there is no qt5 installed, cmake will fail here, before it had any chance to build the overlays.

@guruz
Copy link
Contributor

@guruz guruz commented on 9aeb587 Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the overlays need Qt4?

Or is this about having the overlays built with system Qt instead of our packaged Qt?

@ogoffart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overlays for windows/mac/nautilus don't require Qt at all. The overlay for dolphin require KF5 and should only work with system installed Qt/KF5

Please sign in to comment.