diff --git a/CMakeLists.txt b/CMakeLists.txt index c22afab6e5690a099822d56effe7ec1fe8b11bbf..0fdebb2352f9502164144e50ee62bfe7cde39364 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ message(STATUS "|- log4cxx : -DLOG4CXX_INCLUDE_DIR, -DLOG4CXX_LIBRARY") message(STATUS "|- purple : -DPURPLE_INCLUDE_DIR, -DPURPLE_LIBRARY") message(STATUS " : -DPURPLE_NOT_RUNTIME - enables compilation with libpurple.lib") +option(ENABLE_QT4 "Build with Qt4 instead of Qt5" ON) + option(ENABLE_SQLITE3 "Build with SQLite3 support" ON) option(ENABLE_MYSQL "Build with MySQL support" ON) option(ENABLE_PQXX "Build with Postgres supoort" ON) @@ -182,8 +184,13 @@ endif() if(ENABLE_IRC) find_package(Communi) - INCLUDE(FindQt4) - FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork) + if(ENABLE_QT4) + INCLUDE(FindQt4) + FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork) + else() + FIND_PACKAGE(Qt5 COMPONENTS Core Network) + endif() + # ADD_DEFINITIONS(${SWIFTEN_CFLAGS}) ADD_DEFINITIONS(-DSUPPORT_LEGACY_CAPS) # ADD_DEFINITIONS(-DBOOST_FILESYSTEM_VERSION=2) @@ -321,7 +328,10 @@ if (PROTOBUF_FOUND) message("IRC plugin : yes") include_directories(${QT_QTNETWORK_INCLUDE_DIR}) include_directories(${IRC_INCLUDE_DIR}) - include(${QT_USE_FILE}) + + if (ENABLE_QT4) + include(${QT_USE_FILE}) + endif() else() if(ENABLE_IRC) message("IRC plugin : no (install libCommuni and libprotobuf-dev)") diff --git a/backends/libcommuni/CMakeLists.txt b/backends/libcommuni/CMakeLists.txt index 679981ed9e006004593c7b28e5474e7e5131b301..4a71b379ad1e54afb7af0059083eb5252045b28a 100644 --- a/backends/libcommuni/CMakeLists.txt +++ b/backends/libcommuni/CMakeLists.txt @@ -1,14 +1,29 @@ cmake_minimum_required(VERSION 2.6) FILE(GLOB SRC *.cpp) FILE(GLOB HEADERS *.h) -QT4_WRAP_CPP(SRC ${HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) + +if (ENABLE_QT4) + QT4_WRAP_CPP(SRC ${HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) +else() + QT5_WRAP_CPP(SRC ${HEADERS} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) + include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) +endif() + add_definitions(-DQT_NO_KEYWORDS) ADD_EXECUTABLE(spectrum2_libcommuni_backend ${SRC}) if (NOT WIN32) - target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport pthread) + if (ENABLE_QT4) + target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport pthread) + else() + target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport pthread) + endif() else () - target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport) + if (ENABLE_QT4) + target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport) + else() + target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport) + endif() endif() INSTALL(TARGETS spectrum2_libcommuni_backend RUNTIME DESTINATION bin) diff --git a/cmake_modules/FindCommuni.cmake b/cmake_modules/FindCommuni.cmake index 49d732cc87c6f04e86aebc4d02001d478f0f4eb3..c650897523aa225e86361d9fcd6f7c1c46a1e561 100644 --- a/cmake_modules/FindCommuni.cmake +++ b/cmake_modules/FindCommuni.cmake @@ -1,8 +1,16 @@ -find_package(Qt4) -include( ${QT_USE_FILE} ) +if( ENABLE_QT4 ) + find_package(Qt4) + include( ${QT_USE_FILE} ) +else() + find_package(Qt5Network) +endif() FIND_LIBRARY(IRC_LIBRARY NAMES IrcCore PATHS ${QT_LIBRARY_DIR}) -FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${QT_INCLUDE_DIR} PATH_SUFFIXES Communi) +if( ENABLE_QT4 ) + FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${QT_INCLUDE_DIR} PATH_SUFFIXES Communi) +else() + FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${Qt5Core_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS}"/.." PATH_SUFFIXES Communi) +endif() # message( STATUS ${IRC_LIBRARY}) if( IRC_LIBRARY AND IRC_INCLUDE_DIR )