Hi,
Trying to build pure Qt5 version of trojita led me to some very weird
crashes from within libQtCore.so.4. (maybe Qt4 and Qt5 cannot coexist
within one elf?)
Here's a patch for CMake that remove any linking to Qt4 libraries when
WITH_QT5 option is passed to CMake.
BR,
Bartekcommit cda12524621595d4c2a958471505c6f2166547d1
Author: Bartosz Taczala <[email protected]>
Date: Thu Oct 17 12:19:54 2013 +0200
Fixing build for Qt5
When building with WITH_QT5=On, some Qt4 libraries also were linked,
this caused runtime errors (libc)
So don't link agaist Qt4 when Qt5 build is set up.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 33bb61f..c9b4e89 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -515,11 +515,19 @@ set_source_files_properties(${version_files}
add_library(Common ${libCommon_SOURCES})
add_dependencies(Common version)
-target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(Common Core Gui)
+else()
+ target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+endif()
add_library(AppVersion ${libAppVersion_SOURCES})
add_dependencies(AppVersion version)
-target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(AppVersion Core)
+else()
+ target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
+endif()
if(WITH_SHARED_PLUGINS)
add_library(Plugins SHARED ${libPlugins_SOURCES})
@@ -535,25 +543,51 @@ else()
endif()
add_library(Streams ${libStreams_SOURCES})
-target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(Streams Core Network)
+else()
+ target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
+endif()
+
if(WITH_ZLIB)
target_link_libraries(Streams ${ZLIB_LIBRARIES})
endif()
add_library(qwwsmtpclient ${libqwwsmtpclient_SOURCES})
-target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY}
${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(qwwsmtpclient Network Core)
+else()
+ target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY}
${QT_QTCORE_LIBRARY})
+endif()
add_library(MSA ${libMSA_SOURCES})
-target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(MSA Core)
+else()
+ target_link_libraries(MSA ${QT_QTCORE_LIBRARY})
+endif()
+target_link_libraries(MSA Imap Streams qwwsmtpclient)
add_library(Composer ${libComposer_SOURCES})
-target_link_libraries(Composer Common MSA Streams qwwsmtpclient
${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(Composer Core Gui)
+else()
+ target_link_libraries(Composer ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+endif()
+target_link_libraries(Composer Common MSA Streams qwwsmtpclient)
+
if(NOT WITH_QT5)
target_link_libraries(Composer MimetypesQt4)
endif()
add_library(Imap ${libImap_SOURCES})
-target_link_libraries(Imap Common Streams ${QT_QTNETWORK_LIBRARY}
${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+if(WITH_QT5)
+ qt5_use_modules(MSA Core Network Sql Gui)
+else()
+ target_link_libraries(Imap Common Streams ${QT_QTNETWORK_LIBRARY}
${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+endif()
+target_link_libraries(Imap Common Streams)
+
if(WITH_ZLIB)
target_link_libraries(Imap ${ZLIB_LIBRARIES})
endif()
@@ -587,7 +621,11 @@ if(WITH_DESKTOP)
endif()
add_library(AbookAddressbook ${libAbookAddressbook_SOURCES}
${libAbookAddressbook_UI_OUT})
- target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY})
+ if(WITH_QT5)
+ qt5_use_modules(AbookAddressbook Core Gui)
+ else()
+ target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY})
+ endif()
add_library(DesktopGui ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT}
${libDesktopGui_RESOURCES_OUT})
# The following is needed for the LineEdit widget within the .ui files.
@@ -595,12 +633,22 @@ if(WITH_DESKTOP)
if(SUPPORTS_TARGET_INCLUDES)
set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES
${path_DesktopGui})
endif()
- target_link_libraries(DesktopGui Common Composer Imap MSA Plugins Streams
qwwsmtpclient AbookAddressbook ${QT_QTWEBKIT_LIBRARY} ${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY})
+ if(WITH_QT5)
+ qt5_use_modules(DesktopGui WebKit Core Gui)
+ else()
+ target_link_libraries(DesktopGui ${QT_QTWEBKIT_LIBRARY}
${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+ endif()
+ target_link_libraries(DesktopGui Common Composer Imap MSA Plugins Streams
qwwsmtpclient AbookAddressbook)
# On Windows build a real Win32 GUI application without console window
# On other platforms WIN32 flag is ignored
add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
- target_link_libraries(trojita AppVersion Common DesktopGui
${STATIC_PLUGINS} ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
+ if(WITH_QT5)
+ qt5_use_modules(trojita Gui Core)
+ else()
+ target_link_libraries(trojita ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY}
${QT_QTCORE_LIBRARY})
+ endif()
+ target_link_libraries(trojita AppVersion Common DesktopGui
${STATIC_PLUGINS})
if(NOT WITH_QT5)
target_link_libraries(trojita MimetypesQt4)
endif()
@@ -692,13 +740,14 @@ if(WITH_TESTS)
add_library(test_LibMailboxSync ${test_LibMailboxSync_SOURCES})
if(WITH_QT5)
qt5_use_modules(test_LibMailboxSync Test Network)
+ else()
+ target_link_libraries(test_LibMailboxSync Imap MSA Streams Common
Composer ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
endif()
if(SUPPORTS_TARGET_INCLUDES)
set_property(TARGET test_LibMailboxSync APPEND PROPERTY
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
endif()
- target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer
${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
macro(trojita_test dir fname)
set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)