2014-09-18 14:30:42 +04:00
# (c) 2014 Copyright ownCloud, Inc.
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING* file.
2013-08-24 16:57:55 +04:00
include ( MacroOptionalFindPackage )
include ( MacroLogFeature )
2014-02-12 14:25:08 +04:00
option ( BUILD_WITH_QT4 "Build with Qt4 no matter if Qt5 was found" OFF )
2013-08-24 16:57:55 +04:00
2014-04-08 14:08:01 +04:00
if ( BUILD_WITH_QT4 )
2015-01-23 16:44:53 +03:00
message ( STATUS "Search for Qt5 was disabled by option BUILD_WITH_QT4" )
2014-04-08 14:08:01 +04:00
else ( BUILD_WITH_QT4 )
2014-04-07 20:08:28 +04:00
find_package ( Qt5Core QUIET )
2014-04-08 14:08:01 +04:00
endif ( BUILD_WITH_QT4 )
if ( Qt5Core_FOUND )
message ( STATUS "Found Qt5 core, checking for further dependencies..." )
find_package ( Qt5Network REQUIRED )
find_package ( Qt5Xml REQUIRED )
2014-04-06 21:34:56 +04:00
if ( NOT TOKEN_AUTH_ONLY )
find_package ( Qt5WebKitWidgets REQUIRED )
find_package ( Qt5WebKit REQUIRED )
find_package ( Qt5PrintSupport REQUIRED )
find_package ( Qt5Quick REQUIRED )
find_package ( Qt5Widgets REQUIRED )
2014-06-16 17:34:46 +04:00
if ( APPLE )
find_package ( Qt5MacExtras REQUIRED )
endif ( APPLE )
2014-04-06 21:34:56 +04:00
endif ( )
2014-06-16 17:34:46 +04:00
2014-04-08 14:08:01 +04:00
else ( Qt5Core_FOUND )
if ( WIN32 OR APPLE )
message ( FATAL_ERROR "Qt 5 not found, but application depends on Qt5 on Windows and Mac OS X" )
endif ( WIN32 OR APPLE )
endif ( Qt5Core_FOUND )
2014-04-07 19:38:30 +04:00
2014-04-08 14:08:01 +04:00
if ( Qt5Core_FOUND )
2014-04-07 19:38:30 +04:00
message ( STATUS "Using Qt 5!" )
2014-04-08 14:08:01 +04:00
# We need this to find the paths to qdbusxml2cpp and co
2014-04-07 19:38:30 +04:00
if ( WITH_DBUS )
2014-04-08 14:08:01 +04:00
find_package ( Qt5DBus REQUIRED )
include_directories ( ${ Qt5DBus_INCLUDES } )
add_definitions ( ${ Qt5DBus_DEFINITIONS } )
2014-04-07 19:38:30 +04:00
endif ( WITH_DBUS )
2014-04-06 21:34:56 +04:00
include_directories ( ${ Qt5Core_INCLUDES } )
add_definitions ( ${ Qt5Core_DEFINITIONS } )
2014-04-07 19:38:30 +04:00
if ( NOT WIN32 ) #implied on Win32
2014-04-08 14:08:01 +04:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
2014-04-07 19:38:30 +04:00
endif ( NOT WIN32 )
2013-09-05 19:08:05 +04:00
# set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
2013-08-28 22:58:22 +04:00
2014-04-06 21:34:56 +04:00
if ( APPLE AND NOT TOKEN_AUTH_ONLY )
2014-04-08 14:08:01 +04:00
include_directories ( ${ Qt5MacExtras_INCLUDE_DIRS } )
add_definitions ( ${ Qt5MacExtras_DEFINITIONS } )
set ( QT_LIBRARIES ${ QT_LIBRARIES } ${ Qt5MacExtras_LIBRARIES } )
2014-04-06 21:34:56 +04:00
endif ( )
2013-08-28 22:58:22 +04:00
2014-04-06 21:34:56 +04:00
if ( NOT BUILD_LIBRARIES_ONLY )
2014-04-07 19:38:30 +04:00
macro ( qt_wrap_ui )
2014-04-08 14:08:01 +04:00
qt5_wrap_ui ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2014-04-06 21:34:56 +04:00
else ( )
# hack
SET ( QT_UIC_EXECUTABLE "" )
endif ( )
2013-08-24 16:57:55 +04:00
2014-04-07 19:38:30 +04:00
macro ( qt_add_resources )
2014-04-08 14:08:01 +04:00
qt5_add_resources ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2013-08-24 16:57:55 +04:00
2014-08-08 13:59:14 +04:00
if ( NOT TOKEN_AUTH_ONLY )
2014-04-07 19:38:30 +04:00
find_package ( Qt5LinguistTools REQUIRED )
macro ( qt_add_translation )
2014-04-08 14:08:01 +04:00
qt5_add_translation ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2014-10-06 16:21:15 +04:00
else ( )
macro ( qt_add_translation )
endmacro ( )
2014-08-08 13:59:14 +04:00
endif ( )
2013-08-24 16:57:55 +04:00
2014-04-07 19:38:30 +04:00
macro ( qt_add_dbus_interface )
2014-04-08 14:08:01 +04:00
qt5_add_dbus_interface ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2013-08-24 16:57:55 +04:00
2014-04-07 19:38:30 +04:00
macro ( qt_add_dbus_adaptor )
2014-04-08 14:08:01 +04:00
qt5_add_dbus_adaptor ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2013-08-24 16:57:55 +04:00
2014-04-07 19:38:30 +04:00
macro ( qt_wrap_cpp )
2014-04-08 14:08:01 +04:00
qt5_wrap_cpp ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2013-08-28 22:14:40 +04:00
2014-04-07 19:38:30 +04:00
macro ( install_qt_executable )
2014-04-08 14:08:01 +04:00
install_qt5_executable ( ${ ARGN } )
2014-04-07 19:38:30 +04:00
endmacro ( )
2013-08-28 22:14:40 +04:00
2014-04-07 19:38:30 +04:00
macro ( setup_qt )
endmacro ( )
2013-08-24 16:57:55 +04:00
2014-04-07 19:38:30 +04:00
set ( QT_RCC_EXECUTABLE "${Qt5Core_RCC_EXECUTABLE}" )
2013-08-28 22:58:22 +04:00
2014-04-07 19:38:30 +04:00
#Enable deprecated symbols
add_definitions ( "-DQT_DISABLE_DEPRECATED_BEFORE=0" )
2015-02-04 15:43:02 +03:00
add_definitions ( "-DQT_USE_QSTRINGBUILDER" ) #optimize string concatenation
add_definitions ( "-DQT_MESSAGELOGCONTEXT" ) #enable function name and line number in debug output
2014-04-08 14:08:01 +04:00
endif ( Qt5Core_FOUND )
2014-04-07 19:38:30 +04:00
if ( NOT Qt5Core_FOUND )
2013-08-24 16:57:55 +04:00
message ( STATUS "Could not find Qt5, searching for Qt4 instead..." )
set ( NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork" "QtGui" "QtWebkit" )
if ( BUILD_TESTS )
list ( APPEND NEEDED_QT4_COMPONENTS "QtTest" )
endif ( )
2014-03-12 21:18:02 +04:00
find_package ( Qt4 4.7.0 COMPONENTS ${ NEEDED_QT4_COMPONENTS } )
2014-04-04 11:28:49 +04:00
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" )
2013-08-24 16:57:55 +04:00
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 ( )
2013-08-28 22:14:40 +04:00
macro ( qt_wrap_cpp )
qt4_wrap_cpp ( ${ ARGN } )
endmacro ( )
2013-11-19 17:41:32 +04:00
macro ( install_qt_executable )
install_qt4_executable ( ${ ARGN } )
endmacro ( )
2013-08-24 16:57:55 +04:00
macro ( setup_qt )
2013-08-28 22:14:40 +04:00
set ( QT_USE_QTGUI TRUE )
2013-08-24 16:57:55 +04:00
set ( QT_USE_QTSQL TRUE )
set ( QT_USE_QTNETWORK TRUE )
set ( QT_USE_QTXML TRUE )
set ( QT_USE_QTWEBKIT TRUE )
2013-08-28 22:14:40 +04:00
set ( QT_USE_QTDBUS TRUE )
2013-08-24 16:57:55 +04:00
include ( ${ QT_USE_FILE } )
endmacro ( )
2014-07-10 01:10:07 +04:00
2014-10-08 20:55:41 +04:00
if ( CMAKE_COMPILER_IS_GNUCC )
execute_process ( COMMAND ${ CMAKE_C_COMPILER } -dumpversion
O U T P U T _ V A R I A B L E G C C _ V E R S I O N )
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 ( )
2014-10-09 19:54:23 +04:00
else ( ) #clang or others
add_definitions ( "-DQ_DECL_OVERRIDE=override" )
2014-10-08 20:55:41 +04:00
endif ( )
2013-08-24 16:57:55 +04:00
endif ( )
if ( Qt5Core_DIR )
set ( HAVE_QT5 TRUE )
else ( Qt5Core_DIR )
set ( HAVE_QT5 FALSE )
endif ( Qt5Core_DIR )