Changeset - daeb6dfc9a9f
[Not reviewed]
master
0 3 0
Conrad Kostecki - 7 years ago 2018-12-02 22:27:13
conrad@kostecki.com
Enable support for Qt5

Since Qt4 is EOL, we should also support libcommuni build with Qt5.
In order not to break Fedora docker builds, -DENABLE_QT4 is introduced.

When set to 'ON', support for Qt4 is being enabled,
otherwise support for Qt5 is enabled.

Signed-off-by: Conrad Kostecki <conrad@kostecki.com>
3 files changed with 42 insertions and 9 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -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)")
backends/libcommuni/CMakeLists.txt
Show inline comments
 
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)
 

	
cmake_modules/FindCommuni.cmake
Show inline comments
 
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 )
0 comments (0 inline, 0 general)