1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 22:38:33 +01:00

qt5: cmake: allow building Tomahawk against Qt4 and Qt5

This commit is contained in:
Dominik Schmidt 2013-01-06 03:52:20 +01:00
parent 033e6a3059
commit 110fb0100d
10 changed files with 146 additions and 116 deletions

View File

@ -81,26 +81,76 @@ INCLUDE( GNUInstallDirs )
# installer creation
INCLUDE( TomahawkCPack.cmake )
#deps
# deps
INCLUDE( MacroOptionalFindPackage )
INCLUDE( MacroLogFeature )
# Check if we need qtgui:
SET(NEEDED_QT4_COMPONENTS QtCore QtXml QtNetwork )
IF( NOT BUILD_GUI )
ADD_DEFINITIONS( -DENABLE_HEADLESS )
MESSAGE( STATUS "Building Tomahawk ${TOMAHAWK_VERSION} in HEADLESS mode ***" )
ELSE()
MESSAGE( STATUS "Building Tomahawk ${TOMAHAWK_VERSION} full GUI version ***" )
LIST(APPEND NEEDED_QT4_COMPONENTS "QtGui" "QtWebkit" "QtUiTools" )
ENDIF()
# headless mode
if( NOT BUILD_GUI )
add_definitions( -DENABLE_HEADLESS )
message( STATUS "Building Tomahawk ${TOMAHAWK_VERSION} in HEADLESS mode ***" )
else()
message( STATUS "Building Tomahawk ${TOMAHAWK_VERSION} full GUI version ***" )
endif()
IF( BUILD_GUI AND UNIX AND NOT APPLE )
FIND_PACKAGE( X11 )
ENDIF()
macro_optional_find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} )
macro_log_feature(QT4_FOUND "Qt" "A cross-platform application and UI framework" "http://qt.nokia.com" TRUE "" "If you see this, although libqt4-devel is installed, check whether the \n qtwebkit-devel package and whatever contains QtUiTools is installed too")
find_package(Qt5Core QUIET)
if(Qt5Core_DIR)
find_package(Qt5Widgets QUIET)
message(STATUS "Found Qt5! Please keep in mind, this is highly experimental and not our main development..")
macro(qt_wrap_ui)
qt5_wrap_ui(${ARGN})
endmacro()
macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()
find_package(Qt5LinguistTools REQUIRED)
macro(qt_add_translation)
qt5_add_translation(${ARGN})
endmacro()
macro(setup_qt)
endmacro()
#FIXME: CrashReporter depends on deprecated QHttp
set(WITH_CRASHREPORTER OFF)
set(WITH_BREAKPAD OFF)
else()
message(STATUS "Could not find Qt5, now searching for Qt4... you're better off this way!")
set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
if(BUILD_GUI)
list(APPEND NEEDED_QT4_COMPONENTS "QtGui" "QtWebkit" "QtUiTools" )
endif()
macro_optional_find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} )
macro_logfeature(QT4_FOUND "Qt" "A cross-platform application and UI framework" "http://qt.nokia.com" 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(setup_qt)
if(NOT BUILD_GUI)
set(QT_DONT_USE_QTGUI TRUE)
endif()
if(UNIX AND NOT APPLE)
set(QT_USE_QTDBUS TRUE)
endif()
set(QT_USE_QTSQL TRUE)
set(QT_USE_QTNETWORK TRUE)
set(QT_USE_QTXML TRUE)
set(QT_USE_QTWEBKIT TRUE)
include( ${QT_USE_FILE} )
endmacro()
endif()
if(BUILD_GUI AND UNIX AND NOT APPLE)
find_package( X11 )
endif()
macro_optional_find_package(Phonon 4.5.0)
macro_log_feature(PHONON_FOUND "Phonon" "The Phonon multimedia library" "http://phonon.kde.org" TRUE "" "")
@ -143,6 +193,10 @@ macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://gith
macro_optional_find_package(LibLastFm 1.0.0)
macro_log_feature(LIBLASTFM_FOUND "liblastfm" "Qt library for the Last.fm webservices" "https://github.com/eartle/liblastfm" TRUE "" "liblastfm is needed for scrobbling tracks to Last.fm and fetching cover artwork")
# we need pthreads too
macro_optional_find_package(Threads)
macro_log_feature(THREADS_FOUND "Threads" "Threading Library" "" TRUE "" "Platform specific library for threading")
IF( WIN32 )
macro_optional_find_package(QtSparkle)
macro_log_feature(QTSPARKLE_FOUND "qtsparkle" "Library for creating auto updaters written in Qt" "https://github.com/davidsansome/qtsparkle" FALSE "" "")
@ -153,6 +207,12 @@ set(QXTWEB_FOUND TRUE)
set(QXTWEB_LIBRARIES qxtweb-standalone)
set(QXTWEB_INCLUDE_DIRS ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb ${CMAKE_CURRENT_BINARY_DIR})
### libportfwd
set(LIBPORTFWD_INCLUDE_DIR ${THIRDPARTY_DIR}/libportfwd/include)
set(LIBPORTFWD_LIBRARY tomahawk_portfwd)
set(LIBPORTFWD_LIBRARIES ${LIBPORTFWD_LIBRARY})
add_subdirectory(${THIRDPARTY_DIR}/libportfwd)
#### submodules start
# automatically init submodules here, don't delete this code we may add submodules again
@ -167,15 +227,7 @@ set(QXTWEB_INCLUDE_DIRS ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb ${CMAKE_C
#### submodules end
### libportfwd
SET( LIBPORTFWD_INCLUDE_DIR ${THIRDPARTY_DIR}/libportfwd/include )
SET( LIBPORTFWD_LIBRARY tomahawk_portfwd )
SET( LIBPORTFWD_LIBRARIES ${LIBPORTFWD_LIBRARY} )
ADD_SUBDIRECTORY( ${THIRDPARTY_DIR}/libportfwd )
# we need pthreads too
macro_optional_find_package(Threads)
macro_log_feature(THREADS_FOUND "Threads" "Threading Library" "" TRUE "" "Platform specific library for threading")
macro_optional_find_package(KDE4)
macro_optional_find_package(KDE4Installed)

View File

@ -59,12 +59,12 @@ macro(add_tomahawk_plugin)
# qt stuff
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(PLUGIN_UI)
qt4_wrap_ui(PLUGIN_UI_SOURCES ${PLUGIN_UI})
qt_wrap_ui(PLUGIN_UI_SOURCES ${PLUGIN_UI})
list(APPEND PLUGIN_SOURCES ${PLUGIN_UI_SOURCES})
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/resources.qrc")
qt4_add_resources(PLUGIN_RC_SOURCES "resources.qrc")
qt_add_resources(PLUGIN_RC_SOURCES "resources.qrc")
list(APPEND PLUGIN_SOURCES ${PLUGIN_RC_SOURCES})
unset(PLUGIN_RC_SOURCES)
endif()
@ -72,6 +72,9 @@ macro(add_tomahawk_plugin)
# add target
add_library(${target} MODULE ${PLUGIN_SOURCES})
# add qt modules
qt5_use_modules(${target} Core Network Widgets Sql Xml DBus)
# definitions - can this be moved into set_target_properties below?
add_definitions(${QT_DEFINITIONS})
set_target_properties(${target} PROPERTIES AUTOMOC TRUE COMPILE_DEFINITIONS ${PLUGIN_EXPORT_MACRO})

View File

@ -21,25 +21,25 @@ macro(add_tomahawk_translations language)
file( WRITE ${CMAKE_BINARY_DIR}/lang/tomahawk_i18n.qrc "${tomahawk_i18n_qrc_content}" )
QT4_ADD_TRANSLATION( QM_FILES ${TS_FILES} )
qt_add_translation(QM_FILES ${TS_FILES})
## HACK HACK HACK - around rcc limitations to allow out of source-tree building
SET( trans_file tomahawk_i18n )
SET( trans_srcfile ${CMAKE_BINARY_DIR}/lang/${trans_file}.qrc )
SET( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
SET( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
set( trans_file tomahawk_i18n )
set( trans_srcfile ${CMAKE_BINARY_DIR}/lang/${trans_file}.qrc )
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
# Copy the QRC file to the output directory
ADD_CUSTOM_COMMAND(
add_custom_command(
OUTPUT ${trans_infile}
COMMAND ${CMAKE_COMMAND} -E copy ${trans_srcfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_srcfile}
)
# Run the resource compiler (rcc_options should already be set)
ADD_CUSTOM_COMMAND(
add_custom_command(
OUTPUT ${trans_outfile}
COMMAND ${QT_RCC_EXECUTABLE}
COMMAND ${Qt5Core_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${trans_file} -o ${trans_outfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_infile}
DEPENDS ${QM_FILES}

View File

@ -1,26 +1,14 @@
PROJECT( tomahawk )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
IF( "${gui}" STREQUAL "no" )
SET( QT_DONT_USE_QTGUI TRUE )
ENDIF()
IF( UNIX AND NOT APPLE )
SET( QT_USE_QTDBUS TRUE )
ENDIF( UNIX AND NOT APPLE )
SET( QT_USE_QTSQL TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTWEBKIT TRUE )
setup_qt()
INCLUDE( ${QT_USE_FILE} )
INCLUDE( AddAppIconMacro )
include( AddAppIconMacro )
#SET( CMAKE_BUILD_TYPE "Release" )
SET( CMAKE_VERBOSE_MAKEFILE ON )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
# SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
# SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
# SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
IF( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
MESSAGE( "Building in debug mode, enabling all debug updates" )
SET( DEBUG_BUILD ON )
@ -164,7 +152,7 @@ SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${trans_outfile})
IF( BUILD_GUI )
LIST(APPEND tomahawkSources ${tomahawkSourcesGui})
qt4_wrap_ui( tomahawkUI_H ${tomahawkUI} )
qt_wrap_ui( tomahawkUI_H ${tomahawkUI} )
IF( WITH_CRASHREPORTER )
ADD_SUBDIRECTORY( breakpad/CrashReporter )
@ -172,7 +160,7 @@ IF( BUILD_GUI )
ENDIF()
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
qt4_add_resources( RC_SRCS "../resources.qrc" )
qt_add_resources( RC_SRCS "../resources.qrc" )
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMoc} ${tomahawkSources} ${RC_SRCS} )
@ -188,6 +176,7 @@ IF( WIN32 )
ENDIF( WIN32 )
SET_TARGET_PROPERTIES(tomahawk PROPERTIES AUTOMOC TRUE)
qt5_use_modules(tomahawk Core Widgets Network Sql WebKitWidgets)
MESSAGE( STATUS "OS_SPECIFIC_LINK_LIBRARIES: ${OS_SPECIFIC_LINK_LIBRARIES}" )

View File

@ -22,8 +22,6 @@
#include "Zeroconf.h"
#include "Source.h"
#include <QtPlugin>
using namespace Tomahawk;
using namespace Accounts;

View File

@ -1,26 +1,31 @@
PROJECT( CrashReporter )
cmake_policy(SET CMP0017 NEW)
FIND_PACKAGE( Qt4 REQUIRED )
SET( QT_USE_QTNETWORK TRUE )
setup_qt()
set(crashreporter_SOURCES main.cpp CrashReporter.cpp)
set(crashreporter_UI CrashReporter.ui)
set(crashreporter_RC ../../../resources.qrc)
qt_wrap_ui( crashreporter_UI_HEADERS ${crashreporter_UI} )
qt_add_resources( crashreporter_RC_RCC ${crashreporter_RC} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} ../../libtomahawk )
add_executable( tomahawk_crash_reporter WIN32
${crashreporter_SOURCES}
${crashreporter_HEADERS_MOC}
${crashreporter_UI_HEADERS}
${crashreporter_RC_RCC}
)
SET( crashreporter_SOURCES main.cpp CrashReporter.cpp )
SET( crashreporter_UI CrashReporter.ui )
SET( crashreporter_RC ../../../resources.qrc )
target_link_libraries(tomahawk_crash_reporter
tomahawklib
${QT_LIBRARIES}
)
QT4_WRAP_UI( crashreporter_UI_HEADERS ${crashreporter_UI} )
QT4_ADD_RESOURCES( crashreporter_RC_RCC ${crashreporter_RC} )
INCLUDE( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ../../libtomahawk )
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
# translations
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
add_tomahawk_translations( ${TOMAHAWK_TRANSLATION_LANGUAGES} )
ADD_EXECUTABLE( tomahawk_crash_reporter WIN32 ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} ${trans_outfile} )
TARGET_LINK_LIBRARIES( tomahawk_crash_reporter ${QT_LIBRARIES} tomahawklib )
set_target_properties( tomahawk_crash_reporter PROPERTIES AUTOMOC ON)
set_target_properties(tomahawk_crash_reporter PROPERTIES AUTOMOC ON)
install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
qt5_use_modules(tomahawk_crash_reporter Widgets Network)

View File

@ -1,4 +1,7 @@
IF(BUILD_GUI AND X11_FOUND)
# don't build with Qt5 because QX11Info is missing there
if(NOT Qt5Core_DIR)
IF(BUILD_GUI AND X11_FOUND)
INCLUDE_DIRECTORIES( ${THIRDPARTY_DIR}/libqnetwm )
SET(fdo_srcs
fdonotify/FdoNotifyPlugin.cpp
@ -11,7 +14,9 @@ IF(BUILD_GUI AND X11_FOUND)
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
SOURCES "${fdo_srcs}" LINK_LIBRARIES "${FDO_LINK_LIBRARIES}"
)
ENDIF()
ENDIF()
endif()
SET(mpris_srcs
mpris/MprisPluginRootAdaptor.cpp

View File

@ -48,7 +48,6 @@
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtGui/QImage>
#include <QtPlugin>
namespace Tomahawk
{

View File

@ -1,17 +1,6 @@
project( tomahawklib )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTSQL TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTSVG TRUE )
SET( QT_USE_QTUITOOLS TRUE )
IF( UNIX AND NOT APPLE )
SET( QT_USE_QTDBUS TRUE )
ENDIF( UNIX AND NOT APPLE )
include( ${QT_USE_FILE} )
setup_qt()
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_SHARED )
@ -358,7 +347,6 @@ include_directories(
${PHONON_INCLUDES}
${LIBPORTFWD_INCLUDE_DIR}
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
${QuaZip_INCLUDE_DIR}
)
@ -373,14 +361,6 @@ IF(LIBATTICA_FOUND)
LIST(APPEND LINK_LIBRARIES ${LIBATTICA_LIBRARIES} ${QuaZip_LIBRARIES} )
ENDIF(LIBATTICA_FOUND)
IF( UNIX AND NOT APPLE )
IF( BUILD_GUI AND X11_FOUND )
INCLUDE_DIRECTORIES( ${THIRDPARTY_DIR}/libqnetwm )
SET( libSources ${libSources} ${THIRDPARTY_DIR}/libqnetwm/libqnetwm/netwm.cpp )
LIST(APPEND LINK_LIBRARIES ${X11_LIBRARIES} )
ENDIF()
ENDIF( UNIX AND NOT APPLE )
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
@ -437,12 +417,13 @@ IF(BUILD_GUI)
LIST(APPEND libSources ${libGuiSources} )
ENDIF()
qt4_wrap_ui( libUI_H ${libUI} )
qt_wrap_ui(libUI_H ${libUI})
SET( libSources ${libSources} ${libUI_H} )
ADD_LIBRARY( tomahawklib SHARED ${libSources})
add_library( tomahawklib SHARED ${libSources})
set_target_properties(tomahawklib PROPERTIES AUTOMOC TRUE)
qt5_use_modules(tomahawklib Widgets Network Sql WebKitWidgets Concurrent Xml UiTools Svg)
IF(QCA2_FOUND)
LIST(APPEND LINK_LIBRARIES ${QCA2_LIBRARIES} )

View File

@ -1,15 +1,11 @@
PROJECT(libqxtweb-standalone)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_INSTALL_PREFIX ".")
IF( ${CMAKE_VERSION} VERSION_GREATER 2.8.3 )
CMAKE_POLICY(SET CMP0017 NEW)
ENDIF( ${CMAKE_VERSION} VERSION_GREATER 2.8.3 )
FIND_PACKAGE( Qt4 4.6.0 COMPONENTS QtCore QtNetwork REQUIRED )
set(QT_USE_QTNETWORK TRUE)
include( ${QT_USE_FILE} )
setup_qt()
SET(qxtweb "qxtweb")
@ -87,4 +83,6 @@ target_link_libraries( qxtweb-standalone
${QT_LIBRARIES}
)
qt5_use_modules(qxtweb-standalone Network)
set_target_properties(qxtweb-standalone PROPERTIES AUTOMOC TRUE)