Merge changes I23ff29b8,Icbc02dab
[trojita.git] / CMakeLists.txt
blob9369c5efc14425fd8db96b13d1269474bdfe93ee
1 if(WITH_QT5)
2     # The Qt5's qt5_use_modules is only available on 2.8.9 or later -- sweet, isn't it?
3     cmake_minimum_required(VERSION 2.8.9)
4 else()
5     cmake_minimum_required(VERSION 2.8.7)
6 endif()
7 project(trojita)
8 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
10 # POSITION_INDEPENDENT_CODE is only available on cmake 2.8.9 or later
11 # Add needed flags for supported compilers which simulate POSITION_INDEPENDENT_CODE property
12 if(CMAKE_VERSION VERSION_LESS "2.8.9")
13     if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
14         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
15     else()
16         message(FATAL_ERROR "Needs GNU or Clang C++ compiler or CMake 2.8.9 (or later)")
17     endif()
18 else()
19     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
20 endif()
22 include(FindCXXFeatures)
23 if(NOT CXXFeatures_auto_FOUND)
24     message(SEND_ERROR "Your compiler doesn't support C++11's auto")
25 endif()
26 if(NOT CXXFeatures_static_assert_FOUND)
27     message(SEND_ERROR "Your compiler doesn't support C++11's static_assert")
28 endif()
29 if(NOT CXXFeatures_alignof_FOUND)
30     if(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT MSVC)
31         message(SEND_ERROR "Your compiler doesn't support C++11's alignof and it also isn't gcc or MSVC. Either would work.")
32     endif()
33 endif()
34 if(NOT CXXFeatures_nullptr_FOUND)
35     # Yes, this is extremely fragile; it will break on any code which wants to
36     # distinguish between an int and nullptr_t. So far, we don't have anything
37     # like that in Trojita. Let's just pretend that it won't ever happen, and
38     # if it happens, then let's hope that an "ambiguous overload" would come up.
39     add_definitions(-Dnullptr=0)
40     message(WARNING "Your C++ compiler doesn't support C++11's nullptr. Activating a very hackish workaround "
41             "which can break existing code because nullptr is not plain 0.")
42 endif()
43 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
45 include(TrojitaOption)
47 trojita_option(WITH_DESKTOP "Build desktop version" ON)
48 trojita_option(WITH_HARMATTAN "Build MeeGo Harmattan version" OFF "NOT WITH_DESKTOP")
49 trojita_option(WITH_QT5 "Build with Qt5 library" OFF)
50 trojita_option(WITH_DBUS "Build with DBus library" AUTO)
51 trojita_option(WITH_RAGEL "Build with Ragel library" AUTO)
52 trojita_option(WITH_ZLIB "Build with zlib library" AUTO)
53 trojita_option(WITH_SHARED_PLUGINS "Enable shared dynamic plugins" ON)
54 trojita_option(WITH_TESTS "Build tests" ON "NOT WITH_HARMATTAN")
55 trojita_option(DEV_FATAL_WARNINGS "Turn build warnings into errors (developers only)" OFF)
57 if(WIN32)
58     trojita_option(WITH_NSIS "Build Windows NSIS installer" AUTO "WITH_DESKTOP")
59 endif()
61 if(UNIX AND NOT APPLE)
62     set(QTKEYCHAIN_DEPENDS ";WITH_DBUS")
63 else()
64     set(QTKEYCHAIN_DEPENDS "")
65 endif()
67 if(WITH_QT5)
68     message(STATUS "Building the Qt5 version")
69     find_package(Qt5Core 5.2 REQUIRED)
70     find_package(Qt5Gui REQUIRED)
71     find_package(Qt5Network REQUIRED)
72     find_package(Qt5Sql REQUIRED)
73     find_package(Qt5WebKitWidgets REQUIRED)
74     find_package(Qt5Widgets REQUIRED)
75     find_package(Qt5LinguistTools)
76     trojita_find_package(Qt5DBus "" "http://qt-project.org" "Qt5 D-Bus support" "Needed for IPC anf for some plugins" WITH_DBUS)
77     trojita_find_package(Qt5Test "" "http://qt-project.org" "Qt5 QTest library" "Needed for automated tests" WITH_TESTS)
78     if(Qt5LinguistTools_FOUND)
79         find_package(Qt5LinguistForTrojita)
80     endif()
81 else()
82     message(STATUS "Building the Qt4 version")
83     set(QT_USE_QTNETWORK 1)
84     set(QT_USE_QTSQL 1)
85     set(QT_USE_QTWEBKIT 1)
86     if(WITH_DBUS)
87         set(QT_USE_QTDBUS 1)
88     endif()
89     if(WITH_TESTS)
90         set(QT_USE_QTTEST 1)
91     endif()
92     if(WITH_HARMATTAN)
93         set(QT_USE_QTDECLARATIVE 1)
94     endif()
95     trojita_find_package(Qt4 4.6 "http://qt-project.org" "Qt4" "Needed for building" REQUIRED)
96     include(${QT_USE_FILE})
97     trojita_check_qt4_module(QTCORE REQUIRED)
98     trojita_check_qt4_module(QTGUI REQUIRED)
99     trojita_check_qt4_module(QTNETWORK REQUIRED)
100     trojita_check_qt4_module(QTSQL REQUIRED)
101     trojita_check_qt4_module(QTWEBKIT REQUIRED)
102     trojita_check_qt4_module(QTDBUS WITH_DBUS)
103     trojita_check_qt4_module(QTTEST WITH_TESTS)
104     trojita_check_qt4_module(QTDECLARATIVE WITH_HARMATTAN)
105     trojita_find_package(LinguistForTrojita "" "" "" "")
106     if(NOT QT_QCONFIG MATCHES "openssl" OR QT_QCONFIG MATCHES "no-openssl")
107         message(FATAL_ERROR "Your copy of Qt was build without SSL support. Please get openssl and rebuild Qt or a Qt binary with SSL support compiled in")
108     endif()
109 endif()
111 trojita_plugin_option(WITH_CLEARTEXT_PLUGIN "Build Cleartext password plugin" STATIC)
112 trojita_plugin_option(WITH_QTKEYCHAIN_PLUGIN "Build Qtkeychain password plugin" "NOT WITH_HARMATTAN${QTKEYCHAIN_DEPENDS}")
114 trojita_find_package(Git "" "" "" "")
116 if(WIN32)
117     trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
118 endif()
120 # Add support for Mingw RC compiler
121 if(WIN32)
122     enable_language(RC)
123     include(CMakeDetermineRCCompiler)
125     if(MINGW)
126         set(CMAKE_RC_COMPILER_INIT windres)
127         set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
128     endif()
129 endif()
131 if (WITH_QT5)
132     trojita_find_package(Qt5Keychain "" "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library (Qt5 version)" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
133 else()
134     trojita_find_package(QtKeychain "" "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
135 endif()
136 if(Qt5Keychain_FOUND OR QtKeychain_FOUND)
137     message(STATUS "Found QtKeychain library (includes at ${QTKEYCHAIN_INCLUDE_DIRS}, lib at ${QTKEYCHAIN_LIBRARIES})")
138 endif()
140 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
141     set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
142 endif()
143 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
145 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
146     set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
147 endif()
148 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
150 if(NOT PLUGIN_DIR)
151     if(IS_ABSOLUTE ${CMAKE_INSTALL_PLUGIN_DIR})
152         set(PLUGIN_DIR "${CMAKE_INSTALL_PLUGIN_DIR}")
153     else()
154         set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
155     endif()
156 endif()
157 mark_as_advanced(PLUGIN_DIR)
159 if(NOT WIN32 AND NOT MSVC)
160     # Check if we are NOT on Windows and don't use MSVC since -g is not supported by VC
161     # and Wall makes the build very noisy.
162     # At first, enable optimizations. In my testing, these do *not* make debugging any harder than no optimization and
163     # they (of course) optimize away stuff like QByteArray::operator[] etc.
164     # We put the user's CXXFLAGS *after* that so that they take priority.
165     set(CMAKE_CXX_FLAGS "-O2 -g ${CMAKE_CXX_FLAGS}")
166     # Now enable build warnings; these are useful tools (and Trojita should be warning-free anyway). We do not set
167     # -Werror for sanity reasons, though (one cannot know what warnings a future compiler might bring along).
168     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wsign-compare")
169 endif(NOT WIN32 AND NOT MSVC)
170 if(DEV_FATAL_WARNINGS)
171     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
172 endif()
174 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
175 # The following is required so that the moc_*.cpp and ui_*.h are found
176 include_directories(${CMAKE_CURRENT_BINARY_DIR})
177 add_definitions(-DQT_STRICT_ITERATORS)
179 # Make sure that plugins not export all symbols, only that which are explicitly marked
180 include(GenerateExportHeader)
181 add_compiler_export_flags()
183 if(NOT WITH_QT5 AND CMAKE_VERSION VERSION_LESS 2.8.10)
184     set(SUPPORTS_TARGET_INCLUDES 0)
185     include_directories(
186         ${QT_MKSPECS_DIR}/default
187         ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/
188         ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4/io/
189         ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer
190         ${CMAKE_CURRENT_SOURCE_DIR}/tests
191         ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_LibMailboxSync)
192 else()
193     set(SUPPORTS_TARGET_INCLUDES 1)
194 endif()
196 set(CMAKE_AUTOMOC True)
198 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
200 if(WIN32) # Check if we are on Windows
201     # On win32, qt can statically link to zlib and export their symbols.
202     # We check if we can find the string " zlib " in the QT_CONFIG list in
203     # ${QT_MKSPECS_DIR}/qconfig.pri and include on success ${QT_QTCORE_LIBRARY}
204     # and ${QTDIR}/src/3rdparty/zlib as lib and include folder
205     if(QT_QTCORE_FOUND)
206         message(STATUS "We are on Windows with Qt. Checking if zlib is built into Qt")
208         if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
209             file(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents_ZLIB_CHECK)
210             string(REGEX MATCH "QT_CONFIG[^\n]+" QT_CONFIG_ZLIB_CHECK ${_qconfig_FILE_contents_ZLIB_CHECK})
212             set(ENV_QTDIR $ENV{QTDIR})
213             if(NOT DEFINED ENV_QTDIR)
214                 message(STATUS "QTDIR not specified in environment, will not use zlib")
215             elseif(QT_CONFIG_ZLIB_CHECK)
216                 if(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
217                     message(STATUS "Found zlib in QT_QCONFIG. zlib seems to be built into Qt")
218                     set(ZLIB_LIBRARY_RELEASE ${QT_QTCORE_LIBRARY_RELEASE})
219                     set(ZLIB_LIBRARY_DEBUG ${QT_QTCORE_LIBRARY_DEBUG})
220                     set(ZLIB_LIBRARY ${QT_QTCORE_LIBRARY})
222                     string(REGEX REPLACE "\\\\" "/" QTDIR ${ENV_QTDIR})
223                     set(ZLIB_INCLUDE_DIR "${QTDIR}/src/3rdparty/zlib")
225                     set(ZLIB_FOUND TRUE)
226                     set(ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
227                     mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR ZLIB_FOUND)
228                 else(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
229                     message(STATUS "Could not determine if Qt was built with zlib support.")
230                 endif(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
232             endif()
233         endif(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
234     endif(QT_QTCORE_FOUND)
235 endif()
237 if(NOT ZLIB_FOUND)
238     trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
239 endif()
241 if(WITH_ZLIB)
242     set(TROJITA_HAVE_ZLIB True)
243     message(STATUS "Support for COMPRESS=DEFLATE enabled")
244 else()
245     set(TROJITA_HAVE_ZLIB False)
246     message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
247 endif()
249 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
250     ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
252 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES DESCRIPTION "\n" WHAT ALL)
254 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
255 set(libCommon_SOURCES
256     ${path_Common}/Application.cpp
257     ${path_Common}/ConnectionId.cpp
258     ${path_Common}/DeleteAfter.cpp
259     ${path_Common}/FileLogger.cpp
260     ${path_Common}/MetaTypes.cpp
261     ${path_Common}/Paths.cpp
262     ${path_Common}/SettingsNames.cpp
265 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
266 set(libPlugins_SOURCES
267     ${path_Plugins}/AddressbookPlugin.cpp
268     ${path_Plugins}/PasswordPlugin.cpp
269     ${path_Plugins}/PluginJob.cpp
270     ${path_Plugins}/PluginManager.cpp
273 set(path_UiUtils ${CMAKE_CURRENT_SOURCE_DIR}/src/UiUtils)
274 set(libUiUtils_SOURCES
275     ${path_UiUtils}/Color.cpp
276     ${path_UiUtils}/Formatting.cpp
277     ${path_UiUtils}/PasswordWatcher.cpp
278     ${path_UiUtils}/PlainTextFormatter.cpp
281 set(path_IPC ${CMAKE_CURRENT_SOURCE_DIR}/src/IPC)
283 if(WITH_DBUS)
284     set(libIPC_SOURCES
285         ${path_IPC}/DBusInterface.cpp
286         ${path_IPC}/MainWindowBridge.cpp
287     )
288 else()
289     set(libIPC_SOURCES
290         ${path_IPC}/None.cpp
291     )
292 endif()
294 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
295 set(libComposer_SOURCES
296     ${path_Composer}/ComposerAttachments.cpp
297     ${path_Composer}/Mailto.cpp
298     ${path_Composer}/MessageComposer.cpp
299     ${path_Composer}/QuoteText.cpp
300     ${path_Composer}/Recipients.cpp
301     ${path_Composer}/ReplaceSignature.cpp
302     ${path_Composer}/SenderIdentitiesModel.cpp
303     ${path_Composer}/SubjectMangling.cpp
304     ${path_Composer}/Submission.cpp
307 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
308 set(libMSA_SOURCES
309     ${path_MSA}/AbstractMSA.cpp
310     ${path_MSA}/Account.cpp
311     ${path_MSA}/FakeMSA.cpp
312     ${path_MSA}/ImapSubmit.cpp
313     ${path_MSA}/SMTP.cpp
314     ${path_MSA}/Sendmail.cpp
317 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
318 set(libStreams_SOURCES
319     ${path_Streams}/DeletionWatcher.cpp
320     ${path_Streams}/FakeSocket.cpp
321     ${path_Streams}/IODeviceSocket.cpp
322     ${path_Streams}/Socket.cpp
323     ${path_Streams}/SocketFactory.cpp
326 if(WITH_ZLIB)
327     set(libStreams_SOURCES ${libStreams_SOURCES}
328         ${path_Streams}/3rdparty/rfc1951.cpp)
329     include_directories(${ZLIB_INCLUDE_DIR})
330 endif()
332 if(NOT WITH_QT5)
333     set(path_mimetypesqt4 ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4)
334     set(libMimetypesQt4_SOURCES
335         ${path_mimetypesqt4}/io/qstandardpaths.cpp
336         ${path_mimetypesqt4}/mimetypes/qmimedatabase.cpp
337         ${path_mimetypesqt4}/mimetypes/qmimeglobpattern.cpp
338         ${path_mimetypesqt4}/mimetypes/qmimemagicrule.cpp
339         ${path_mimetypesqt4}/mimetypes/qmimemagicrulematcher.cpp
340         ${path_mimetypesqt4}/mimetypes/qmimetype.cpp
341         ${path_mimetypesqt4}/mimetypes/qmimetypeparser.cpp
342         ${path_mimetypesqt4}/mimetypes/qmimeprovider.cpp
343     )
344     if(WIN32)
345         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
346             ${path_mimetypesqt4}/io/qstandardpaths_win.cpp)
347     elseif(APPLE)
348         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
349             ${path_mimetypesqt4}/io/qstandardpaths_mac.cpp)
350     elseif (OS2)
351         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
352             ${path_mimetypesqt4}/io/qstandardpaths_os2.cpp)
353     elseif (UNIX)
354         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
355             ${path_mimetypesqt4}/io/qstandardpaths_unix.cpp)
356     else()
357         message(FATAL_ERROR "Unsupported platform -- mimetypes-Qt4 support only Unix, MacOSX, Windows and OS/2")
358     endif()
359 endif()
361 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
362 set(libDesktopGui_SOURCES
363     ${path_DesktopGui}/AttachmentView.cpp
364     ${path_DesktopGui}/AutoCompletion.cpp
365     ${path_DesktopGui}/CompleteMessageWidget.cpp
366     ${path_DesktopGui}/ComposeWidget.cpp
367     ${path_DesktopGui}/ComposerAttachmentsList.cpp
368     ${path_DesktopGui}/ComposerTextEdit.cpp
369     ${path_DesktopGui}/EmbeddedWebView.cpp
370     ${path_DesktopGui}/EnvelopeView.cpp
371     ${path_DesktopGui}/ExternalElementsWidget.cpp
372     ${path_DesktopGui}/FindBar.cpp
373     ${path_DesktopGui}/FlowLayout.cpp
374     ${path_DesktopGui}/FromAddressProxyModel.cpp
375     ${path_DesktopGui}/LineEdit.cpp
376     ${path_DesktopGui}/LoadablePartWidget.cpp
377     ${path_DesktopGui}/MailBoxTreeView.cpp
378     ${path_DesktopGui}/MessageListWidget.cpp
379     ${path_DesktopGui}/MessageSourceWidget.cpp
380     ${path_DesktopGui}/MessageView.cpp
381     ${path_DesktopGui}/MsgListView.cpp
382     ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
383     ${path_DesktopGui}/OverlayWidget.cpp
384     ${path_DesktopGui}/PartWalker.cpp
385     ${path_DesktopGui}/PartWidget.cpp
386     ${path_DesktopGui}/PartWidgetFactoryVisitor.cpp
387     ${path_DesktopGui}/PasswordDialog.cpp
388     ${path_DesktopGui}/ProgressPopUp.cpp
389     ${path_DesktopGui}/ProtocolLoggerWidget.cpp
390     ${path_DesktopGui}/ReplaceCharValidator.cpp
391     ${path_DesktopGui}/SettingsDialog.cpp
392     ${path_DesktopGui}/SimplePartWidget.cpp
393     ${path_DesktopGui}/Spinner.cpp
394     ${path_DesktopGui}/TagListWidget.cpp
395     ${path_DesktopGui}/TagWidget.cpp
396     ${path_DesktopGui}/TaskProgressIndicator.cpp
397     ${path_DesktopGui}/UserAgentWebPage.cpp
398     ${path_DesktopGui}/Util.cpp
399     ${path_DesktopGui}/Window.cpp
400     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
401     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
402     ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
404 set(libDesktopGui_UI
405     ${path_DesktopGui}/AboutDialog.ui
406     ${path_DesktopGui}/ComposeWidget.ui
407     ${path_DesktopGui}/CreateMailboxDialog.ui
408     ${path_DesktopGui}/EditIdentity.ui
409     ${path_DesktopGui}/PasswordDialog.ui
410     ${path_DesktopGui}/ProgressPopUp.ui
411     ${path_DesktopGui}/SettingsCachePage.ui
412     ${path_DesktopGui}/SettingsGeneralPage.ui
413     ${path_DesktopGui}/SettingsImapPage.ui
414     ${path_DesktopGui}/SettingsOutgoingPage.ui
415     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
417 set(libDesktopGui_RESOURCES
418     ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
419     ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
422 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
424 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
426 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
427 set(libImap_SOURCES
428     ${path_Imap}/ConnectionState.cpp
429     ${path_Imap}/Encoders.cpp
430     ${path_Imap}/Exceptions.cpp
431     ${path_Imap}/Parser/3rdparty/kcodecs.cpp
432     ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
434     ${path_Imap}/Parser/Command.cpp
435     ${path_Imap}/Parser/Data.cpp
436     ${path_Imap}/Parser/LowLevelParser.cpp
437     ${path_Imap}/Parser/MailAddress.cpp
438     ${path_Imap}/Parser/Message.cpp
439     ${path_Imap}/Parser/Parser.cpp
440     ${path_Imap}/Parser/Response.cpp
441     ${path_Imap}/Parser/Sequence.cpp
442     ${path_Imap}/Parser/ThreadingNode.cpp
444     ${path_Imap}/Network/FileDownloadManager.cpp
445     ${path_Imap}/Network/ForbiddenReply.cpp
446     ${path_Imap}/Network/MsgPartNetAccessManager.cpp
447     ${path_Imap}/Network/MsgPartNetworkReply.cpp
448     ${path_Imap}/Network/QQuickNetworkReplyWrapper.cpp
450     ${path_Imap}/Model/Cache.cpp
451     ${path_Imap}/Model/CombinedCache.cpp
452     ${path_Imap}/Model/DragAndDrop.cpp
453     ${path_Imap}/Model/DiskPartCache.cpp
454     ${path_Imap}/Model/DummyNetworkWatcher.cpp
455     ${path_Imap}/Model/FindInterestingPart.cpp
456     ${path_Imap}/Model/FlagsOperation.cpp
457     ${path_Imap}/Model/FullMessageCombiner.cpp
458     ${path_Imap}/Model/ImapAccess.cpp
459     ${path_Imap}/Model/MailboxFinder.cpp
460     ${path_Imap}/Model/MailboxMetadata.cpp
461     ${path_Imap}/Model/MailboxModel.cpp
462     ${path_Imap}/Model/MailboxTree.cpp
463     ${path_Imap}/Model/MemoryCache.cpp
464     ${path_Imap}/Model/Model.cpp
465     ${path_Imap}/Model/MsgListModel.cpp
466     ${path_Imap}/Model/NetworkWatcher.cpp
467     ${path_Imap}/Model/OneMessageModel.cpp
468     ${path_Imap}/Model/ParserState.cpp
469     ${path_Imap}/Model/PrettyMailboxModel.cpp
470     ${path_Imap}/Model/PrettyMsgListModel.cpp
471     ${path_Imap}/Model/SpecialFlagNames.cpp
472     ${path_Imap}/Model/SQLCache.cpp
473     ${path_Imap}/Model/SubtreeModel.cpp
474     ${path_Imap}/Model/SystemNetworkWatcher.cpp
475     ${path_Imap}/Model/TaskFactory.cpp
476     ${path_Imap}/Model/TaskPresentationModel.cpp
477     ${path_Imap}/Model/ThreadingMsgListModel.cpp
478     ${path_Imap}/Model/Utils.cpp
479     ${path_Imap}/Model/VisibleTasksModel.cpp
481     # The ModelTest is only needed when debugging manually
482     #${path_Imap}/Model/ModelTest/modeltest.cpp
483     # The ModelWatcher is another debugging aid
484     ${path_Imap}/Model/ModelWatcher.cpp
486     ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
488     ${path_Imap}/Tasks/AppendTask.cpp
489     ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
490     ${path_Imap}/Tasks/CreateMailboxTask.cpp
491     ${path_Imap}/Tasks/DeleteMailboxTask.cpp
492     ${path_Imap}/Tasks/EnableTask.cpp
493     ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
494     ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
495     ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
496     ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
497     ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
498     ${path_Imap}/Tasks/FetchMsgPartTask.cpp
499     ${path_Imap}/Tasks/GenUrlAuthTask.cpp
500     ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
501     ${path_Imap}/Tasks/IdTask.cpp
502     ${path_Imap}/Tasks/IdleLauncher.cpp
503     ${path_Imap}/Tasks/ImapTask.cpp
504     ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
505     ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
506     ${path_Imap}/Tasks/NoopTask.cpp
507     ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
508     ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
509     ${path_Imap}/Tasks/OfflineConnectionTask.cpp
510     ${path_Imap}/Tasks/OpenConnectionTask.cpp
511     ${path_Imap}/Tasks/SortTask.cpp
512     ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
513     ${path_Imap}/Tasks/ThreadTask.cpp
514     ${path_Imap}/Tasks/UidSubmitTask.cpp
515     ${path_Imap}/Tasks/UnSelectTask.cpp
516     ${path_Imap}/Tasks/UpdateFlagsTask.cpp
517     ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
520 if(WITH_RAGEL)
521     message(STATUS "Using Ragel for the RFC 5322 parser")
522     ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
523     set(libImap_SOURCES ${libImap_SOURCES}
524         ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
525 else()
526     message(STATUS "Using pregenerated RFC 5322 parser")
527     set(libImap_SOURCES ${libImap_SOURCES}
528         ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
529 endif()
531 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/AbookAddressbook)
532 set(libAbookAddressbook_SOURCES
533     ${path_AbookAddressbook}/AbookAddressbook.cpp
534     ${path_AbookAddressbook}/be-contacts.cpp
536 set(libAbookAddressbook_UI
537     ${path_AbookAddressbook}/be-contacts.ui
538     ${path_AbookAddressbook}/onecontact.ui
541 set(trojita_desktop_SOURCES
542     ${path_DesktopGui}/main.cpp
545 if(WIN32)
546     list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
547 endif()
549 set(be_contacts_SOURCES
550     ${CMAKE_CURRENT_SOURCE_DIR}/src/be.contacts/main.cpp
553 set(libQNAMWebView_SOURCES
554     ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/plugin.cpp
555     ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qdeclarativewebview.cpp
558 set(trojitaHarmattan_SOURCES
559     ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/main.cpp
560     ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer/qmlapplicationviewer.cpp
563 if(LinguistForTrojita_FOUND OR Qt5LinguistForTrojita_FOUND)
564     file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
565     if(WITH_QT5)
566         qt5_wrap_po(trojita_QM ${lang_PO})
567     else()
568         qt4_wrap_po(trojita_QM ${lang_PO})
569     endif()
570     set(language_summary "")
571     foreach(po ${lang_PO})
572         string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
573         list(APPEND language_summary ${lang})
574     endforeach()
575     list(SORT language_summary)
576     list(LENGTH language_summary num_languages)
577     if(num_languages)
578         message(STATUS "Available languages: ${language_summary}")
579         if(WITH_DESKTOP)
580             install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION share/trojita/locale REGEX "(x_test)|(.*\\.ts)" EXCLUDE)
581         endif()
582     else()
583         message(STATUS "No .po files found, will not install any languages")
584     endif()
585 else()
586     message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
587 endif()
589 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
590 if(WITH_NSIS)
591     set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
592     set(NSIS TRUE)
593 endif()
595 add_custom_target(version DEPENDS version_fake_file)
596 add_custom_command(OUTPUT version_fake_file ${version_files}
597     COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DNSIS=${NSIS} -DHOST_ARCH=${HOST_ARCH} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TrojitaVersion.cmake)
598 set_source_files_properties(${version_files}
599     PROPERTIES GENERATED TRUE
600     HEADER_FILE_ONLY TRUE)
602 add_library(Common STATIC ${libCommon_SOURCES})
603 set_property(TARGET Common APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
604 add_dependencies(Common version)
605 target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
607 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
608 set_property(TARGET AppVersion APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
609 add_dependencies(AppVersion version)
610 target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
612 if(WITH_SHARED_PLUGINS)
613     add_library(Plugins SHARED ${libPlugins_SOURCES})
614 else()
615     add_library(Plugins STATIC ${libPlugins_SOURCES})
616     set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
617 endif()
618 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
619 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
620 if(WITH_QT5)
621     qt5_use_modules(Plugins Core)
622 else()
623     target_link_libraries(Plugins ${QT_QTCORE_LIBRARY})
624 endif()
626 add_library(UiUtils STATIC ${libUiUtils_SOURCES})
627 set_property(TARGET UiUtils APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
628 target_link_libraries(UiUtils Plugins Common ${QT_QTCORE_LIBRARY})
630 add_library(Streams STATIC ${libStreams_SOURCES})
631 set_property(TARGET Streams APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
632 target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
633 if(WITH_ZLIB)
634     target_link_libraries(Streams ${ZLIB_LIBRARIES})
635 endif()
637 add_library(IPC STATIC ${libIPC_SOURCES})
638 set_property(TARGET IPC APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
639 if(WITH_DBUS)
640     target_link_libraries(IPC ${QT_QTDBUS_LIBRARY})
641     if(WITH_QT5)
642         qt5_use_modules(IPC DBus Widgets)
643     endif()
644 else()
645     if(WITH_QT5)
646         qt5_use_modules(IPC Core)
647     endif()
648 endif()
650 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
651 target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
653 add_library(MSA STATIC ${libMSA_SOURCES})
654 set_property(TARGET MSA APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
655 target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
657 add_library(Composer STATIC ${libComposer_SOURCES})
658 set_property(TARGET Composer APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
659 target_link_libraries(Composer Common MSA Streams UiUtils qwwsmtpclient ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
660 if(NOT WITH_QT5)
661     target_link_libraries(Composer MimetypesQt4)
662 endif()
664 add_library(Imap STATIC ${libImap_SOURCES})
665 set_property(TARGET Imap APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
666 target_link_libraries(Imap Common Streams UiUtils ${QT_QTNETWORK_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
667 if(WITH_ZLIB)
668     target_link_libraries(Imap ${ZLIB_LIBRARIES})
669 endif()
671 if(NOT WITH_QT5)
672     add_library(MimetypesQt4 STATIC ${libMimetypesQt4_SOURCES})
673     if(SUPPORTS_TARGET_INCLUDES)
674         set_property(TARGET MimetypesQt4 APPEND PROPERTY INCLUDE_DIRECTORIES
675             ${QT_MKSPECS_DIR}/default ${path_mimetypesqt4}/io/)
676     endif()
677     target_link_libraries(MimetypesQt4 ${QT_QTCORE_LIBRARY})
678     if(APPLE)
679         find_library(CARBON_LIBRARY Carbon REQUIRED)
680         target_link_libraries(MimetypesQt4 ${CARBON_LIBRARY})
681     endif()
682 endif()
684 ## ClearText password plugin
685 if(WITH_CLEARTEXT_PLUGIN)
686     trojita_add_plugin(trojita_plugin_ClearTextPasswordPlugin WITH_CLEARTEXT_PLUGIN src/Plugins/ClearTextPassword/ClearTextPassword.cpp)
687 endif()
689 ## QtKeyChain plugin
690 if(WITH_QTKEYCHAIN_PLUGIN)
691     trojita_add_plugin(trojita_plugin_QtKeychainPasswordPlugin WITH_QTKEYCHAIN_PLUGIN src/Plugins/QtKeyChain/QtKeyChainPassword.cpp)
692     if(WITH_QT5)
693         qt5_use_modules(trojita_plugin_QtKeychainPasswordPlugin Core DBus)
694     else()
695         target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
696     endif()
697     target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QTKEYCHAIN_LIBRARIES})
698     if(SUPPORTS_TARGET_INCLUDES)
699         set_property(TARGET trojita_plugin_QtKeychainPasswordPlugin APPEND PROPERTY INCLUDE_DIRECTORIES ${QTKEYCHAIN_INCLUDE_DIRS})
700     else()
701         include_directories(${QTKEYCHAIN_INCLUDE_DIRS})
702     endif()
703 endif()
705 # Generate file static_plugins.h.in
706 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
707 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
708 foreach(PLUGIN ${STATIC_PLUGINS})
709     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
710 endforeach()
711 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
713 if(WITH_DESKTOP)
714     if(WITH_QT5)
715         qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
716         qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
717         qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
718     else()
719         qt4_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
720         qt4_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
721         qt4_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
722     endif()
724     add_library(AbookAddressbook STATIC ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
725     set_property(TARGET AbookAddressbook APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
726     target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
728     add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
729     set_property(TARGET DesktopGui APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
730     # The following is needed for the LineEdit widget within the .ui files.
731     # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
732     if(SUPPORTS_TARGET_INCLUDES)
733         set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
734     endif()
735     target_link_libraries(DesktopGui Common UiUtils Composer Imap IPC MSA Plugins Streams qwwsmtpclient AbookAddressbook ${QT_QTWEBKIT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
737     # On Windows build a real Win32 GUI application without console window
738     # On other platforms WIN32 flag is ignored
739     add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
740     set_property(TARGET trojita APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
741     target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS} ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
742     if(NOT WITH_QT5)
743         target_link_libraries(trojita MimetypesQt4)
744     endif()
745     if(WITH_ZLIB)
746         target_link_libraries(trojita ${ZLIB_LIBRARIES})
747     endif()
749     add_executable(be.contacts ${be_contacts_SOURCES})
750     set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
751     target_link_libraries(be.contacts AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
752 elseif(WITH_HARMATTAN)
753     add_library(trojitaqnamwebviewplugin SHARED ${libQNAMWebView_SOURCES})
754     add_executable(trojita-tp ${trojitaHarmattan_SOURCES})
755     set_property(TARGET trojita-tp APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
756     if(SUPPORTS_TARGET_INCLUDES)
757         set_property(TARGET trojita-tp APPEND PROPERTY INCLUDE_DIRECTORIES
758             ${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer)
759     endif()
760     target_link_libraries(trojita-tp AppVersion Imap MSA Streams qwwsmtpclient Common Composer MimetypesQt4
761         ${QT_QTSQL_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
762 endif()
764 if(WITH_QT5)
765     qt5_use_modules(AppVersion Core)
766     qt5_use_modules(Common Core Network)
767     qt5_use_modules(UiUtils Core Gui Network)
768     qt5_use_modules(Streams Network)
769     qt5_use_modules(qwwsmtpclient Network)
770     qt5_use_modules(MSA Network)
771     qt5_use_modules(Composer Gui Network)
772     qt5_use_modules(Imap Gui Network Sql)
773     if (WITH_DESKTOP)
774         qt5_use_modules(DesktopGui Network WebKitWidgets)
775         qt5_use_modules(AbookAddressbook Widgets)
776         qt5_use_modules(be.contacts Widgets)
777         qt5_use_modules(trojita Widgets Network)
778     endif()
779 endif()
782 if(WITH_SHARED_PLUGINS)
783     install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
784 endif()
786 include(SanitizedDesktopFile)
788 if(WITH_DESKTOP)
789     copy_desktop_file_without_cruft("${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.desktop" "${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop")
790     install(TARGETS trojita be.contacts RUNTIME DESTINATION bin)
791     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop DESTINATION share/applications/ RENAME trojita.desktop)
792     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.appdata.xml DESTINATION share/appdata/)
793     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION share/icons/hicolor/32x32/apps/)
794     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION share/icons/hicolor/scalable/apps/)
795 endif()
797 if(WITH_HARMATTAN)
798     set(trojita_harmattan_path ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan)
799     install(TARGETS trojita-tp RUNTIME DESTINATION bin)
800     install(TARGETS trojitaqnamwebviewplugin LIBRARY DESTINATION bin/net/flaska/QNAMWebView)
801     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qmldir DESTINATION bin/net/flaska/QNAMWebView)
802     install(DIRECTORY ${trojita_harmattan_path}/qml DESTINATION ${CMAKE_INSTALL_PREFIX})
803     install(FILES ${trojita_harmattan_path}/trojita-tp.desktop DESTINATION share/applications)
804     install(FILES ${trojita_harmattan_path}/trojita-tp80.png DESTINATION share/icons/hicolor/80x80/apps)
805 endif()
807 if(WITH_NSIS)
808     if(CMAKE_SIZEOF_VOID_P STREQUAL 4)
809         set(MAKENSIS_OUTPUT Trojita-installer.exe)
810     else()
811         set(MAKENSIS_FLAGS -DX86_64 ${MAKENSIS_FLAGS})
812         set(MAKENSIS_OUTPUT Trojita-installer-x86_64.exe)
813     endif()
815     if(NOT CMAKE_VERBOSE_MAKEFILE)
816         set(MAKENSIS_FLAGS -V2 -DQUIET ${MAKENSIS_FLAGS})
817     endif()
819     set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -NOCD)
821     add_custom_command(OUTPUT ${MAKENSIS_OUTPUT}
822         COMMAND ${MAKENSIS}
823         ARGS ${MAKENSIS_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi
824         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi ${CMAKE_CURRENT_BINARY_DIR}/trojita.exe version)
825     add_custom_target(installer ALL DEPENDS ${MAKENSIS_OUTPUT})
826 endif()
829 if(WITH_TESTS)
830     set(test_LibMailboxSync_SOURCES
831         tests/Utils/ModelEvents.cpp
832         tests/Utils/LibMailboxSync.cpp
833     )
834     add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
835     if(WITH_QT5)
836         qt5_use_modules(test_LibMailboxSync Test Network)
837     endif()
838     if(SUPPORTS_TARGET_INCLUDES)
839         set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
840             ${CMAKE_CURRENT_SOURCE_DIR}/tests
841             ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
842     endif()
843     target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
845     macro(trojita_test dir fname)
846         set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
847         add_executable(test_${fname} ${test_${fname}_SOURCES})
848         target_link_libraries(test_${fname} Imap MSA Streams Common Composer test_LibMailboxSync)
849         if(WITH_QT5)
850             qt5_use_modules(test_${fname} Network Sql Test Widgets)
851         else()
852             target_link_libraries(test_${fname} ${QT_QTSQL_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
853         endif()
854         if(WITH_ZLIB)
855             target_link_libraries(test_${fname} ${ZLIB_LIBRARIES})
856         endif()
857         if(SUPPORTS_TARGET_INCLUDES)
858             set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
859         endif()
860         if(NOT CMAKE_CROSSCOMPILING)
861             add_test(test_${fname} test_${fname})
862         endif()
863     endmacro()
865     enable_testing()
866     trojita_test(Composer Composer_Submission)
867     trojita_test(Composer Composer_responses)
868     trojita_test(Composer Html_formatting)
869     if(WITH_QT5)
870         qt5_use_modules(test_Composer_responses WebKitWidgets)
871         qt5_use_modules(test_Html_formatting WebKitWidgets)
872     else()
873         target_link_libraries(test_Html_formatting ${QT_QTWEBKIT_LIBRARY})
874     endif()
875     trojita_test(Imap Imap_DisappearingMailboxes)
876     trojita_test(Imap Imap_Idle)
877     trojita_test(Imap Imap_LowLevelParser)
878     trojita_test(Imap Imap_Message)
879     trojita_test(Imap Imap_Model)
880     trojita_test(Imap Imap_MsgPartNetAccessManager)
881     trojita_test(Imap Imap_Parser_parse)
882     trojita_test(Imap Imap_Responses)
883     trojita_test(Imap Imap_SelectedMailboxUpdates)
884     trojita_test(Imap Imap_Tasks_CreateMailbox)
885     trojita_test(Imap Imap_Tasks_DeleteMailbox)
886     trojita_test(Imap Imap_Tasks_ListChildMailboxes)
887     trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
888     trojita_test(Imap Imap_Tasks_OpenConnection)
889     trojita_test(Imap Imap_Threading)
890     trojita_test(Imap Imap_BodyParts)
891     trojita_test(Imap Imap_Offline)
892     trojita_test(Imap Imap_CopyAndFlagOperations)
893     trojita_test(Misc Rfc5322)
894     trojita_test(Misc RingBuffer)
895     trojita_test(Misc SenderIdentitiesModel)
896     trojita_test(Misc SqlCache)
897     trojita_test(Misc algorithms)
898     trojita_test(Misc rfccodecs)
900 endif()
902 if(WIN32) # Check if we are on Windows
903     if(MSVC10) # Check if we are using the Visual Studio compiler 2010
904         # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
905         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
906     elseif(MINGW)
907     else()
908         message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
909         message(WARNING "Please let us know how well it works.")
910     endif()
911 endif()