Merge "enable Flag, (Not) Junk, and Archive shortcuts in message list"
[trojita.git] / CMakeLists.txt
blob3a882370dcb760e393197cf4e43868f038ed11a7
1 project(trojita)
2 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
4 # Qt5's qt5_use_modules need 2.8.9+
5 # On win32, we need QtMain linking, which means 2.8.11+
6 # EL7 ships 2.8.11, Debian 8 ships 3.0.2, and Ubuntu 14.04 LTS has 2.8.12
7 cmake_minimum_required(VERSION 2.8.11)
8 cmake_policy(SET CMP0020 NEW)
10 if(POLICY CMP0054)
11     # Silence warnings in TrojitaOption.cmake; we are fine with only doing the
12     # expansion by hand
13     cmake_policy(SET CMP0054 NEW)
14 endif()
16 if(POLICY CMP0043)
17     # We make use of CMAKE_CXXFLAGS_DEBUG...
18     cmake_policy(SET CMP0043 OLD)
19 endif()
21 if(CMAKE_VERSION VERSION_LESS "3.1")
22     # If you aren't using and old Linux with an old GCC and old CMake, please just upgrade.
23     set(CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")
24 else()
25     set(CMAKE_CXX_STANDARD 11)
26     set(CMAKE_CXX_STANDARD_REQUIRED ON)
27 endif()
29 # Set a default build type if none was specified. This was shamelessly stolen
30 # from VTK's cmake setup because these guys produce both CMake and a project that
31 # manipulates this variable, and the web is full of posts where people say that
32 # it is apparently evil to just set the build type in a way an earlier version of
33 # this patch did. Oh, and the location of this check/update matters, apparently.
35 # Yes, this is just plain crazy.
36 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
37     message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
38     set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
39     # Set the possible values of build type for cmake-gui
40     set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
41 endif()
43 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
45 include(TrojitaOption)
47 trojita_option(WITH_DESKTOP "Build desktop version" ON)
48 trojita_option(WITH_DBUS "Build with DBus library" AUTO)
49 trojita_option(WITH_RAGEL "Build with Ragel library" AUTO)
50 trojita_option(WITH_ZLIB "Build with zlib library" AUTO)
51 trojita_option(WITH_SHARED_PLUGINS "Enable shared dynamic plugins" ON)
52 trojita_option(BUILD_TESTING "Build tests" ON)
53 trojita_option(WITH_MIMETIC "Build with client-side MIME parsing" AUTO)
54 trojita_option(WITH_GPGMEPP "Use GpgME's native C++ bindings" AUTO)
55 trojita_option(WITH_KF5_GPGMEPP "Use legacy discontinued GpgME++ library from KDE frameworks" AUTO)
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 find_package(Qt5Core 5.2 REQUIRED)
68 find_package(Qt5Gui REQUIRED)
69 find_package(Qt5Network REQUIRED)
70 find_package(Qt5Sql REQUIRED)
71 find_package(Qt5WebKitWidgets REQUIRED)
72 find_package(Qt5Widgets REQUIRED)
73 find_package(Qt5LinguistTools)
74 find_package(Qt5Svg REQUIRED)
75 trojita_find_package(Qt5DBus "" "http://qt-project.org" "Qt5 D-Bus support" "Needed for IPC and for some plugins" WITH_DBUS)
76 trojita_find_package(Qt5Test "" "http://qt-project.org" "Qt5 QTest library" "Needed for automated tests" BUILD_TESTING)
77 if(Qt5LinguistTools_FOUND)
78     find_package(Qt5LinguistForTrojita)
79 endif()
81 trojita_find_package(KF5AkonadiContact "" "" "" "Required for building Akonadi address book plugin")
83 trojita_plugin_option(WITH_ABOOKADDRESSBOOK_PLUGIN "Build AbookAddressbook plugin" STATIC)
84 trojita_plugin_option(WITH_AKONADIADDRESSBOOK_PLUGIN "Build AkonadiAddressbook plugin" KF5AkonadiContact_FOUND)
85 trojita_plugin_option(WITH_CLEARTEXT_PLUGIN "Build Cleartext password plugin" STATIC)
86 trojita_plugin_option(WITH_QTKEYCHAIN_PLUGIN "Build Qtkeychain password plugin" "${QTKEYCHAIN_DEPENDS}")
87 trojita_plugin_option(WITH_SONNET_PLUGIN "Build a plugin for spellchecking via KDE's Sonnet" "WITH_DESKTOP")
89 trojita_find_package(Git "" "" "" "")
91 trojita_find_package(Mimetic "" "http://www.codesink.org/mimetic_mime_library.html" "C++ MIME Library" "Required for client-side MIME parsing" WITH_MIMETIC)
92 trojita_find_package(Gpgmepp "1.8.0" "https://gnupg.org/related_software/gpgme/index.html" "C++/Qt bindings for gpgme" "Needed for encrypted/signed e-mails" WITH_GPGMEPP)
93 if(NOT WITH_GPGMEPP)
94     trojita_find_package(KF5Gpgmepp "" "https://commits.kde.org/gpgmepp?path=/" "C++ bindings for gpgme" "Needed for encrypted/signed e-mails" WITH_KF5_GPGMEPP)
95     trojita_option(WITH_CRYPTO_MESSAGES "Enable support for encrypted messages" AUTO "WITH_MIMETIC;WITH_KF5_GPGMEPP")
96 else()
97     trojita_option(WITH_CRYPTO_MESSAGES "Enable support for encrypted messages" AUTO "WITH_MIMETIC;WITH_GPGMEPP")
98 endif()
100 if(WIN32)
101     trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
102 endif()
104 # Add support for Mingw RC compiler
105 if(WIN32)
106     enable_language(RC)
107     include(CMakeDetermineRCCompiler)
109     if(MINGW)
110         set(CMAKE_RC_COMPILER_INIT windres)
111         set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -I${CMAKE_CURRENT_BINARY_DIR} -i <SOURCE> -o <OBJECT>")
112     endif()
113 endif()
115 trojita_find_package(Qt5Keychain QUIET "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library (Qt5 version)" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
116 if(Qt5Keychain_FOUND OR QtKeychain_FOUND)
117     message(STATUS "Found QtKeychain library (includes at ${QTKEYCHAIN_INCLUDE_DIRS}, lib at ${QTKEYCHAIN_LIBRARIES})")
118 else()
119     message(STATUS "Could not find QtKeychain library")
120 endif()
122 trojita_find_package(KF5Sonnet "" "https://projects.kde.org/projects/frameworks/sonnet" "Qt5 Spell Checking Library from KDE" "Spell checking support" WITH_SONNET_PLUGIN)
124 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
125     set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
126 endif()
127 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
129 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
130     set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
131 endif()
132 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
134 if(NOT PLUGIN_DIR)
135     if(IS_ABSOLUTE ${CMAKE_INSTALL_PLUGIN_DIR})
136         set(PLUGIN_DIR "${CMAKE_INSTALL_PLUGIN_DIR}")
137     else()
138         set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
139     endif()
140 endif()
141 mark_as_advanced(PLUGIN_DIR)
143 include(GNUInstallDirs)
145 # When manipulating CXXFLAGS, we put the user's CXXFLAGS *after* that so that they take priority.
146 if(MSVC)
147     # See below for some reationale for these optimizations
148     set(CMAKE_CXX_FLAGS "/O2 ${CMAKE_CXX_FLAGS}")
150     # We have no information about the warnings and their usefullness. Reports are welcome.
151     # We might enable warnings on MSVC in future.
152 else()
153     # -Werror is not a default for sanity reasons (one cannot know what warnings a future compiler
154     # might bring along), but it's a default in debug mode. The idea is that developers should care
155     # about a warning-free build, and that this is easier than messing with yet another configure option.
156     set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
157     # Also see CMP0043...
159     # Optimizations are enabled unconditionally because they make a big difference in the speed of the
160     # resulting binaries, and that it is better to allow an opt-out from them by adjusting CXXFLAGS through
161     # an env var at cmake time if needed.
162     # The reason for not manipulating just CMAKE_CXX_FLAGS_DEBUG is that unrecognized build types ("DebugFull")
163     # should still benefit from these optimizations. Yup, it would be even better if CMake did a sane thing
164     # and warned when users set an unrecognized and unused build type, but that just isn't the case.
165     set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
167     # Build warnings are useful tools (and Trojita should be warning-free anyway), enable them on all
168     # configurations. They are warnings, not errors.
169     set(CMAKE_CXX_FLAGS "-Wall -Wsign-compare ${CMAKE_CXX_FLAGS}")
170 endif()
172 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
173 # The following is required so that the moc_*.cpp and ui_*.h are found
174 include_directories(${CMAKE_CURRENT_BINARY_DIR})
176 add_definitions(-DQT_STRICT_ITERATORS)
177 add_definitions(-DQT_USE_QSTRINGBUILDER)
178 add_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
179 add_definitions(-DQT_USE_FAST_CONCATENATION)
181 if(NOT MSVC)
182   # We're using C++11's threading features (std::async in particular), and that requires "some threading". With GCC and
183   # Clang, this is implemented through the -pthread build flag. Without using these bits, linking fails on Fedora 23,
184   # and this is apparently a slightly different failure than the Kf5::Gpgmepp-pthread one in commit
185   # 12e41101070f7073caec653185c0504763672ee7.
186   #
187   # Apparently, there's been various methods on how to enable this in the most-cmakeish-way throughout the years, with
188   # cmake-3.1+ supporting some magic linking via the Threads::Threads option on a per-library basis. However, I am not
189   # really looking into that wonderful fun of mixing -pthread and non-pthread translation units, so let's use a big
190   # hammer and set it unconditionally on platforms which use it anyway.
191   #
192   # And because we also support MinGW and its `windres` compiler, we have to avoid passing -pthread to *that* thing, so,
193   # well, let's cheat and put it into the CXXFLAGS.
194   set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}")
195 endif()
197 # Make sure that plugins not export all symbols, only that which are explicitly marked
198 include(GenerateExportHeader)
199 add_compiler_export_flags()
201 set(CMAKE_AUTOMOC True)
203 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
204 trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
206 if(WITH_MIMETIC)
207   set(TROJITA_HAVE_MIMETIC True)
208 else()
209   set(TROJITA_HAVE_MIMETIC False)
210 endif()
212 if(WITH_GPGMEPP OR WITH_KF5_GPGMEPP)
213   set(TROJITA_HAVE_GPGMEPP True)
214 else()
215   set(TROJITA_HAVE_GPGMEPP False)
216 endif()
218 if(WITH_CRYPTO_MESSAGES)
219   set(TROJITA_HAVE_CRYPTO_MESSAGES True)
220 else()
221   set(TROJITA_HAVE_CRYPTO_MESSAGES False)
222 endif()
224 if(WITH_ZLIB)
225     set(TROJITA_HAVE_ZLIB True)
226     message(STATUS "Support for COMPRESS=DEFLATE enabled")
227 else()
228     set(TROJITA_HAVE_ZLIB False)
229     message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
230 endif()
232 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
233     ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
234 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure-plugins.cmake.in
235     ${CMAKE_CURRENT_BINARY_DIR}/configure-plugins.cmake.h)
237 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES DESCRIPTION "\n" WHAT ALL)
239 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
240 set(libCommon_SOURCES
241     ${path_Common}/Application.cpp
242     ${path_Common}/ConnectionId.cpp
243     ${path_Common}/FileLogger.cpp
244     ${path_Common}/MetaTypes.cpp
245     ${path_Common}/Paths.cpp
246     ${path_Common}/SettingsNames.cpp
247     ${path_Common}/StashingReverseIterator.h
250 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
251 set(libPlugins_SOURCES
252     ${path_Plugins}/AddressbookPlugin.cpp
253     ${path_Plugins}/PasswordPlugin.cpp
254     ${path_Plugins}/PluginJob.cpp
255     ${path_Plugins}/PluginManager.cpp
256     ${path_Plugins}/SpellcheckerPlugin.cpp
259 set(path_UiUtils ${CMAKE_CURRENT_SOURCE_DIR}/src/UiUtils)
260 set(libUiUtils_SOURCES
261     ${path_UiUtils}/Color.cpp
262     ${path_UiUtils}/Formatting.cpp
263     ${path_UiUtils}/IconLoader.cpp
264     ${path_UiUtils}/PartLoadingOptions.h
265     ${path_UiUtils}/PartVisitor.h
266     ${path_UiUtils}/PartWalker.h
267     ${path_UiUtils}/PartWalker_impl.h
268     ${path_UiUtils}/PasswordWatcher.cpp
269     ${path_UiUtils}/PlainTextFormatter.cpp
270     ${path_UiUtils}/QaimDfsIterator.cpp
273 set(path_IPC ${CMAKE_CURRENT_SOURCE_DIR}/src/IPC)
275 if(WITH_DBUS)
276     set(libIPC_SOURCES
277         ${path_IPC}/DBusInterface.cpp
278         ${path_IPC}/MainWindowBridge.cpp
279     )
280 else()
281     set(libIPC_SOURCES
282         ${path_IPC}/None.cpp
283     )
284 endif()
286 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
287 set(libComposer_SOURCES
288     ${path_Composer}/AbstractComposer.cpp
289     ${path_Composer}/ComposerAttachments.cpp
290     ${path_Composer}/ExistingMessageComposer.cpp
291     ${path_Composer}/Mailto.cpp
292     ${path_Composer}/MessageComposer.cpp
293     ${path_Composer}/QuoteText.cpp
294     ${path_Composer}/Recipients.cpp
295     ${path_Composer}/ReplaceSignature.cpp
296     ${path_Composer}/SenderIdentitiesModel.cpp
297     ${path_Composer}/SubjectMangling.cpp
298     ${path_Composer}/Submission.cpp
301 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
302 set(libMSA_SOURCES
303     ${path_MSA}/AbstractMSA.cpp
304     ${path_MSA}/Account.cpp
305     ${path_MSA}/FakeMSA.cpp
306     ${path_MSA}/ImapSubmit.cpp
307     ${path_MSA}/SMTP.cpp
308     ${path_MSA}/Sendmail.cpp
311 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
312 set(libStreams_SOURCES
313     ${path_Streams}/DeletionWatcher.cpp
314     ${path_Streams}/FakeSocket.cpp
315     ${path_Streams}/IODeviceSocket.cpp
316     ${path_Streams}/Socket.cpp
317     ${path_Streams}/SocketFactory.cpp
320 set(path_Cryptography ${CMAKE_CURRENT_SOURCE_DIR}/src/Cryptography)
321 set(libCryptography_SOURCES
322     ${path_Cryptography}/MessageModel.cpp
323     ${path_Cryptography}/MessagePart.cpp
324     ${path_Cryptography}/PartReplacer.cpp
326 if(WITH_MIMETIC)
327     set(libCryptography_SOURCES
328         ${libCryptography_SOURCES}
329         ${path_Cryptography}/LocalMimeParser.cpp
330         ${path_Cryptography}/MimeticUtils.cpp
331     )
332 endif()
333 if(WITH_CRYPTO_MESSAGES)
334     set(libCryptography_SOURCES
335         ${libCryptography_SOURCES}
336         ${path_Cryptography}/GpgMe++.cpp
337     )
338 endif()
340 if(WITH_ZLIB)
341     set(libStreams_SOURCES ${libStreams_SOURCES}
342         ${path_Streams}/3rdparty/rfc1951.cpp)
343 endif()
345 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
346 set(libDesktopGui_SOURCES
347     ${path_DesktopGui}/AddressRowWidget.cpp
348     ${path_DesktopGui}/AttachmentView.cpp
349     ${path_DesktopGui}/ColoredItemDelegate.cpp
350     ${path_DesktopGui}/CompleteMessageWidget.cpp
351     ${path_DesktopGui}/ComposeWidget.cpp
352     ${path_DesktopGui}/ComposerAttachmentsList.cpp
353     ${path_DesktopGui}/ComposerTextEdit.cpp
354     ${path_DesktopGui}/EmbeddedWebView.cpp
355     ${path_DesktopGui}/EnvelopeView.cpp
356     ${path_DesktopGui}/ExternalElementsWidget.cpp
357     ${path_DesktopGui}/FindBar.cpp
358     ${path_DesktopGui}/FindBarMixin.cpp
359     ${path_DesktopGui}/FlowLayout.cpp
360     ${path_DesktopGui}/FromAddressProxyModel.cpp
361     ${path_DesktopGui}/LineEdit.cpp
362     ${path_DesktopGui}/LoadablePartWidget.cpp
363     ${path_DesktopGui}/MailBoxTreeView.cpp
364     ${path_DesktopGui}/MessageHeadersWidget.cpp
365     ${path_DesktopGui}/MessageListWidget.cpp
366     ${path_DesktopGui}/MessageSourceWidget.cpp
367     ${path_DesktopGui}/MessageView.cpp
368     ${path_DesktopGui}/MsgItemDelegate.cpp
369     ${path_DesktopGui}/MsgListView.cpp
370     ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
371     ${path_DesktopGui}/OneEnvelopeAddress.cpp
372     ${path_DesktopGui}/OverlayWidget.cpp
373     ${path_DesktopGui}/PartWalker.cpp
374     ${path_DesktopGui}/PartWidget.cpp
375     ${path_DesktopGui}/PartWidgetFactoryVisitor.cpp
376     ${path_DesktopGui}/PasswordDialog.cpp
377     ${path_DesktopGui}/ProgressPopUp.cpp
378     ${path_DesktopGui}/ProtocolLoggerWidget.cpp
379     ${path_DesktopGui}/ReplaceCharValidator.cpp
380     ${path_DesktopGui}/SettingsDialog.cpp
381     ${path_DesktopGui}/SimplePartWidget.cpp
382     ${path_DesktopGui}/Spinner.cpp
383     ${path_DesktopGui}/TagAddDialog.cpp
384     ${path_DesktopGui}/TagListWidget.cpp
385     ${path_DesktopGui}/TagWidget.cpp
386     ${path_DesktopGui}/TaskProgressIndicator.cpp
387     ${path_DesktopGui}/UserAgentWebPage.cpp
388     ${path_DesktopGui}/Util.cpp
389     ${path_DesktopGui}/Window.cpp
390     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
391     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
392     ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
394 set(libDesktopGui_UI
395     ${path_DesktopGui}/AboutDialog.ui
396     ${path_DesktopGui}/ComposeWidget.ui
397     ${path_DesktopGui}/CreateMailboxDialog.ui
398     ${path_DesktopGui}/EditIdentity.ui
399     ${path_DesktopGui}/EditFavoriteTag.ui
400     ${path_DesktopGui}/PasswordDialog.ui
401     ${path_DesktopGui}/ProgressPopUp.ui
402     ${path_DesktopGui}/SettingsCachePage.ui
403     ${path_DesktopGui}/SettingsGeneralPage.ui
404     ${path_DesktopGui}/SettingsImapPage.ui
405     ${path_DesktopGui}/SettingsOutgoingPage.ui
406     ${path_DesktopGui}/SettingsFavoriteTagsPage.ui
407     ${path_DesktopGui}/TagAddDialog.ui
408     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
410 set(libDesktopGui_RESOURCES
411     ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
412     ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
415 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
417 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
419 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
420 set(libImap_SOURCES
421     ${path_Imap}/ConnectionState.cpp
422     ${path_Imap}/Encoders.cpp
423     ${path_Imap}/Exceptions.cpp
424     ${path_Imap}/Parser/3rdparty/kcodecs.cpp
425     ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
427     ${path_Imap}/Parser/Command.cpp
428     ${path_Imap}/Parser/Data.cpp
429     ${path_Imap}/Parser/LowLevelParser.cpp
430     ${path_Imap}/Parser/MailAddress.cpp
431     ${path_Imap}/Parser/Message.cpp
432     ${path_Imap}/Parser/Parser.cpp
433     ${path_Imap}/Parser/Response.cpp
434     ${path_Imap}/Parser/Sequence.cpp
435     ${path_Imap}/Parser/ThreadingNode.cpp
437     ${path_Imap}/Network/FileDownloadManager.cpp
438     ${path_Imap}/Network/ForbiddenReply.cpp
439     ${path_Imap}/Network/MsgPartNetAccessManager.cpp
440     ${path_Imap}/Network/MsgPartNetworkReply.cpp
441     ${path_Imap}/Network/QQuickNetworkReplyWrapper.cpp
443     ${path_Imap}/Model/Cache.cpp
444     ${path_Imap}/Model/CombinedCache.cpp
445     ${path_Imap}/Model/DragAndDrop.cpp
446     ${path_Imap}/Model/DiskPartCache.cpp
447     ${path_Imap}/Model/DummyNetworkWatcher.cpp
448     ${path_Imap}/Model/FindInterestingPart.cpp
449     ${path_Imap}/Model/FlagsOperation.cpp
450     ${path_Imap}/Model/FullMessageCombiner.cpp
451     ${path_Imap}/Model/ImapAccess.cpp
452     ${path_Imap}/Model/MailboxFinder.cpp
453     ${path_Imap}/Model/MailboxMetadata.cpp
454     ${path_Imap}/Model/MailboxModel.cpp
455     ${path_Imap}/Model/MailboxTree.cpp
456     ${path_Imap}/Model/MemoryCache.cpp
457     ${path_Imap}/Model/Model.cpp
458     ${path_Imap}/Model/MsgListModel.cpp
459     ${path_Imap}/Model/NetworkWatcher.cpp
460     ${path_Imap}/Model/OneMessageModel.cpp
461     ${path_Imap}/Model/FavoriteTagsModel.cpp
462     ${path_Imap}/Model/ParserState.cpp
463     ${path_Imap}/Model/PrettyMailboxModel.cpp
464     ${path_Imap}/Model/PrettyMsgListModel.cpp
465     ${path_Imap}/Model/SpecialFlagNames.cpp
466     ${path_Imap}/Model/SQLCache.cpp
467     ${path_Imap}/Model/SubtreeModel.cpp
468     ${path_Imap}/Model/SystemNetworkWatcher.cpp
469     ${path_Imap}/Model/TaskFactory.cpp
470     ${path_Imap}/Model/TaskPresentationModel.cpp
471     ${path_Imap}/Model/ThreadingMsgListModel.cpp
472     ${path_Imap}/Model/Utils.cpp
473     ${path_Imap}/Model/VisibleTasksModel.cpp
475     # The ModelWatcher is another debugging aid
476     ${path_Imap}/Model/ModelWatcher.cpp
478     ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
480     ${path_Imap}/Tasks/AppendTask.cpp
481     ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
482     ${path_Imap}/Tasks/CreateMailboxTask.cpp
483     ${path_Imap}/Tasks/DeleteMailboxTask.cpp
484     ${path_Imap}/Tasks/EnableTask.cpp
485     ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
486     ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
487     ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
488     ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
489     ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
490     ${path_Imap}/Tasks/FetchMsgPartTask.cpp
491     ${path_Imap}/Tasks/GenUrlAuthTask.cpp
492     ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
493     ${path_Imap}/Tasks/IdTask.cpp
494     ${path_Imap}/Tasks/IdleLauncher.cpp
495     ${path_Imap}/Tasks/ImapTask.cpp
496     ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
497     ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
498     ${path_Imap}/Tasks/NoopTask.cpp
499     ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
500     ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
501     ${path_Imap}/Tasks/OfflineConnectionTask.cpp
502     ${path_Imap}/Tasks/OpenConnectionTask.cpp
503     ${path_Imap}/Tasks/SortTask.cpp
504     ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
505     ${path_Imap}/Tasks/ThreadTask.cpp
506     ${path_Imap}/Tasks/UidSubmitTask.cpp
507     ${path_Imap}/Tasks/UnSelectTask.cpp
508     ${path_Imap}/Tasks/UpdateFlagsTask.cpp
509     ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
512 # The ModelTest is only needed when debugging manually
513 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
514     list(APPEND libImap_SOURCES ${path_Imap}/Model/ModelTest/modeltest.cpp)
515 endif()
517 if(WITH_RAGEL)
518     message(STATUS "Using Ragel for the RFC 5322 parser")
519     ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
520     set(libImap_SOURCES ${libImap_SOURCES}
521         ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
522 else()
523     message(STATUS "Using pregenerated RFC 5322 parser")
524     set(libImap_SOURCES ${libImap_SOURCES}
525         ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
526 endif()
528 set(trojita_desktop_SOURCES
529     ${path_DesktopGui}/main.cpp
532 if(WIN32)
533     list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
534     set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc APPEND PROPERTY OBJECT_DEPENDS
535         ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.ico
536         ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h
537         ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h
538     )
539 endif()
541 if(Qt5LinguistForTrojita_FOUND)
542     file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
543     qt5_wrap_po(trojita_QM ${lang_PO})
544     set(language_summary "")
545     foreach(po ${lang_PO})
546         string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
547         list(APPEND language_summary ${lang})
548     endforeach()
549     list(SORT language_summary)
550     list(LENGTH language_summary num_languages)
551     if(num_languages)
552         message(STATUS "Available languages: ${language_summary}")
553         if(WITH_DESKTOP)
554             install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/trojita/locale" REGEX "(x_test)|(.*\\.ts)" EXCLUDE)
555         endif()
556     else()
557         message(STATUS "No .po files found, will not install any languages")
558     endif()
559 else()
560     message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
561 endif()
563 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
564 if(WITH_NSIS)
565     set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
566     set(NSIS TRUE)
567 endif()
569 add_custom_target(version DEPENDS version_fake_file)
570 add_custom_command(OUTPUT version_fake_file ${version_files}
571     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)
572 set_source_files_properties(${version_files}
573     PROPERTIES GENERATED TRUE
574     HEADER_FILE_ONLY TRUE)
576 add_library(Common STATIC ${libCommon_SOURCES})
577 set_property(TARGET Common APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
578 add_dependencies(Common version)
579 target_link_libraries(Common Qt5::Network)
581 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
582 set_property(TARGET AppVersion APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
583 add_dependencies(AppVersion version)
584 target_link_libraries(AppVersion Common)
585 target_link_libraries(AppVersion Qt5::Core)
587 if(WITH_SHARED_PLUGINS)
588     add_library(Plugins SHARED ${libPlugins_SOURCES})
589     set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS BUILDING_LIBTROJITA_PLUGINS)
590 else()
591     add_library(Plugins STATIC ${libPlugins_SOURCES})
592     set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
593 endif()
594 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
595 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
596 target_link_libraries(Plugins Qt5::Core)
598 add_library(UiUtils STATIC ${libUiUtils_SOURCES})
599 set_property(TARGET UiUtils APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
600 target_link_libraries(UiUtils Plugins Common Qt5::Gui)
602 add_library(Streams STATIC ${libStreams_SOURCES})
603 set_property(TARGET Streams APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
604 if(WITH_ZLIB)
605     set_property(TARGET Streams APPEND PROPERTY INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR})
606     target_link_libraries(Streams ${ZLIB_LIBRARIES})
607 endif()
608 target_link_libraries(Streams Qt5::Network)
610 add_library(IPC STATIC ${libIPC_SOURCES})
611 set_property(TARGET IPC APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
612 if(WITH_DBUS)
613     target_link_libraries(IPC Qt5::DBus Qt5::Widgets)
614 else()
615     target_link_libraries(IPC Qt5::Core)
616 endif()
618 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
619 target_link_libraries(qwwsmtpclient Qt5::Network)
621 add_library(MSA STATIC ${libMSA_SOURCES})
622 set_property(TARGET MSA APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
623 target_link_libraries(MSA Imap Streams qwwsmtpclient)
625 add_library(Composer STATIC ${libComposer_SOURCES})
626 set_property(TARGET Composer APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
627 target_link_libraries(Composer Common MSA Streams UiUtils qwwsmtpclient)
629 add_library(Imap STATIC ${libImap_SOURCES})
630 set_property(TARGET Imap APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
631 target_link_libraries(Imap Common Streams UiUtils Qt5::Sql)
633 add_library(Cryptography STATIC ${libCryptography_SOURCES})
634 set_property(TARGET Cryptography APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
635 target_link_libraries(Cryptography Common Imap)
636 if(WITH_MIMETIC)
637     target_link_libraries(Cryptography ${MIMETIC_LIBRARIES})
638     set_property(TARGET Cryptography APPEND PROPERTY INCLUDE_DIRECTORIES ${MIMETIC_INCLUDE_DIRS})
639 endif()
640 if(WITH_CRYPTO_MESSAGES)
641     if(WITH_GPGMEPP)
642         target_link_libraries(Cryptography Gpgmepp QGpgme)
643     elseif(WITH_KF5_GPGMEPP)
644         if(WIN32)
645             target_link_libraries(Cryptography KF5::Gpgmepp KF5::QGpgme)
646         else()
647             target_link_libraries(Cryptography KF5::Gpgmepp-pthread KF5::QGpgme)
648         endif()
649     endif()
650 endif()
652 ## ClearText password plugin
653 if(WITH_CLEARTEXT_PLUGIN)
654     trojita_add_plugin(trojita_plugin_ClearTextPasswordPlugin WITH_CLEARTEXT_PLUGIN src/Plugins/ClearTextPassword/ClearTextPassword.cpp)
655 endif()
657 ## QtKeyChain plugin
658 if(WITH_QTKEYCHAIN_PLUGIN)
659     trojita_add_plugin(trojita_plugin_QtKeychainPasswordPlugin WITH_QTKEYCHAIN_PLUGIN src/Plugins/QtKeyChain/QtKeyChainPassword.cpp)
660     target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QTKEYCHAIN_LIBRARIES} Qt5::DBus)
661     set_property(TARGET trojita_plugin_QtKeychainPasswordPlugin APPEND PROPERTY INCLUDE_DIRECTORIES ${QTKEYCHAIN_INCLUDE_DIRS})
662 endif()
664 ## AbookAddressbook plugin
665 if(WITH_ABOOKADDRESSBOOK_PLUGIN)
666     set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins/AbookAddressbook)
667     set(libAbookAddressbook_HEADERS
668         ${path_AbookAddressbook}/AbookAddressbook.h
669         ${path_AbookAddressbook}/be-contacts.h
670     )
671     set(libAbookAddressbook_SOURCES
672         ${path_AbookAddressbook}/AbookAddressbook.cpp
673         ${path_AbookAddressbook}/be-contacts.cpp
674     )
675     set(libAbookAddressbook_UI
676         ${path_AbookAddressbook}/be-contacts.ui
677         ${path_AbookAddressbook}/onecontact.ui
678     )
680     qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
682     trojita_add_plugin(trojita_plugin_AbookAddressbookPlugin WITH_ABOOKADDRESSBOOK_PLUGIN ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
683     set_property(TARGET trojita_plugin_AbookAddressbookPlugin APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
685     target_link_libraries(trojita_plugin_AbookAddressbookPlugin Qt5::Widgets)
687     set(be_contacts_SOURCES
688         ${path_AbookAddressbook}/main.cpp
689     )
691     add_executable(be.contacts WIN32 ${be_contacts_SOURCES})
692     set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
693     target_link_libraries(be.contacts Plugins)
694     if("${WITH_ABOOKADDRESSBOOK_PLUGIN}" STREQUAL "STATIC")
695         set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
696         target_link_libraries(be.contacts trojita_plugin_AbookAddressbookPlugin)
697     endif()
698     target_link_libraries(be.contacts Qt5::Widgets)
699 endif()
701 ## AkonadiAddressbook plugin
702 if(WITH_AKONADIADDRESSBOOK_PLUGIN)
703     set(path_AkonadiAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins/AkonadiAddressbook)
704     set(libAkonadiAddressbook_HEADERS
705         ${path_AkonadiAddressbook}/AkonadiAddressbook.h
706         ${path_AkonadiAddressbook}/AkonadiAddressbookCompletionJob.h
707         ${path_AkonadiAddressbook}/AkonadiAddressbookNamesJob.h
708     )
709     set(libAkonadiAddressbook_SOURCES
710         ${path_AkonadiAddressbook}/AkonadiAddressbook.cpp
711         ${path_AkonadiAddressbook}/AkonadiAddressbookCompletionJob.cpp
712         ${path_AkonadiAddressbook}/AkonadiAddressbookNamesJob.cpp
713     )
715     trojita_add_plugin(trojita_plugin_AkonadiAddressbookPlugin WITH_AKONADIADDRESSBOOK_PLUGIN ${libAkonadiAddressbook_SOURCES})
716     target_link_libraries(trojita_plugin_AkonadiAddressbookPlugin KF5::AkonadiContact)
717     set_property(TARGET trojita_plugin_AkonadiAddressbookPlugin APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
718 endif()
720 if(WITH_SONNET_PLUGIN)
721     trojita_add_plugin(trojita_plugin_Sonnet WITH_SONNET_PLUGIN src/Plugins/SonnetSpellchecker/SonnetSpellchecker.cpp)
722     set_property(TARGET trojita_plugin_Sonnet APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
723     target_link_libraries(trojita_plugin_Sonnet KF5::SonnetUi)
724 endif()
726 # Generate file static_plugins.h.in
727 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
728 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
729 foreach(PLUGIN ${STATIC_PLUGINS})
730     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
731 endforeach()
732 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
734 if(WITH_DESKTOP)
735     qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
736     qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
738     add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
739     set_property(TARGET DesktopGui APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
740     # The following is needed for the LineEdit widget within the .ui files.
741     # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
742     set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
743     target_link_libraries(DesktopGui Common UiUtils Composer Cryptography Imap IPC MSA Plugins Streams qwwsmtpclient Qt5::WebKitWidgets)
745     # On Windows build a real Win32 GUI application without console window
746     # On other platforms WIN32 flag is ignored
747     add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
748     set_property(TARGET trojita APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
749     target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS})
750 endif()
753 if(WITH_SHARED_PLUGINS)
754     install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
755 endif()
757 include(SanitizedDesktopFile)
759 if(WITH_ABOOKADDRESSBOOK_PLUGIN)
760     install(TARGETS be.contacts RUNTIME DESTINATION bin)
761 endif()
763 if(WITH_DESKTOP)
764     copy_desktop_file_without_cruft("${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/org.kde.trojita.desktop" "${CMAKE_CURRENT_BINARY_DIR}/org.kde.trojita-DesktopGui.desktop")
765     install(TARGETS trojita RUNTIME DESTINATION bin)
766     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.trojita-DesktopGui.desktop DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications/" RENAME org.kde.trojita.desktop)
767     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/org.kde.trojita.appdata.xml DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
768     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps/")
769     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps/")
770 endif()
772 if(WITH_NSIS)
773     include(TrojitaNSIS)
774 endif()
777 if(BUILD_TESTING)
778     set(test_LibMailboxSync_SOURCES
779         tests/Utils/ModelEvents.cpp
780         tests/Utils/LibMailboxSync.cpp
781     )
782     add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
783     set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
784         ${CMAKE_CURRENT_SOURCE_DIR}/tests
785         ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
786     target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer Qt5::Test)
788     macro(trojita_test dir fname)
789         set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
790         add_executable(test_${fname} ${test_${fname}_SOURCES})
791         target_link_libraries(test_${fname} Imap MSA Streams Common Composer Cryptography test_LibMailboxSync)
792         set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
793         if(NOT CMAKE_CROSSCOMPILING)
794             add_test(test_${fname} test_${fname})
795         endif()
796     endmacro()
798     set(UBSAN_ENV_SUPPRESSIONS "UBSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/tests/ubsan.supp")
800     enable_testing()
801     trojita_test(Composer Composer_Submission)
802     trojita_test(Composer Composer_Existing)
803     trojita_test(Composer Composer_responses)
804     target_link_libraries(test_Composer_responses Qt5::WebKitWidgets)
805     trojita_test(Composer Html_formatting)
806     target_link_libraries(test_Html_formatting Qt5::WebKitWidgets)
807     trojita_test(Imap Imap_DisappearingMailboxes)
808     trojita_test(Imap Imap_Idle)
809     trojita_test(Imap Imap_LowLevelParser)
810     trojita_test(Imap Imap_Message)
811     trojita_test(Imap Imap_Model)
812     trojita_test(Imap Imap_MsgPartNetAccessManager)
813     set_property(TEST test_Imap_MsgPartNetAccessManager PROPERTY ENVIRONMENT "${UBSAN_ENV_SUPPRESSIONS}")
814     trojita_test(Imap Imap_Parser_parse)
815     trojita_test(Imap Imap_Parser_write)
816     trojita_test(Imap Imap_Responses)
817     trojita_test(Imap Imap_SelectedMailboxUpdates)
818     trojita_test(Imap Imap_Tasks_CreateMailbox)
819     trojita_test(Imap Imap_Tasks_DeleteMailbox)
820     trojita_test(Imap Imap_Tasks_ListChildMailboxes)
821     trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
822     trojita_test(Imap Imap_Tasks_OpenConnection)
823     trojita_test(Imap Imap_Threading)
824     trojita_test(Imap Imap_BodyParts)
825     trojita_test(Imap Imap_Offline)
826     trojita_test(Imap Imap_CopyAndFlagOperations)
827     trojita_test(Cryptography Cryptography_MessageModel)
829     if(WITH_CRYPTO_MESSAGES)
830       find_program(GPGCONF_BINARY NAMES gpgconf)
831       if(GPGCONF_BINARY_NOTFOUND)
832         message(SEND_ERROR "The `gpgconf` binary from GnuPG not found, this is needed for crypto tests.")
833       endif()
835       if(NOT UNIX)
836         message(SEND_ERROR "The Cryptography unit tests really need Unix. Patches welcome.")
837       endif()
839       add_library(fake-dev-random SHARED ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils/fake-dev-random.c)
840       set_target_properties(fake-dev-random PROPERTIES AUTOMOC off)
841       target_link_libraries(fake-dev-random dl)
843       # FIXME: it would be nice to depend on the contents of keys/, but in my testing it produces Makefiles
844       # which suffer from races (the keygen.sh is run multiple times in parallel within the CI environment).
845       # I wasn't able to track down the root cause behind this; it affected all cmake versions within the CI
846       # as of Feb 2016, which is 3.1.something up to 3.3.something.
847       add_custom_command(OUTPUT crypto_test_data.h
848         COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/tests/Cryptography/keygen.sh ${CMAKE_CURRENT_SOURCE_DIR}
849         DEPENDS fake-dev-random tests/Cryptography/keygen.sh tests/Cryptography/batch-keygen)
850       add_custom_target(crypto_test_data DEPENDS crypto_test_data.h)
852       trojita_test(Cryptography Cryptography_PGP)
853       set_property(TEST test_Cryptography_PGP PROPERTY ENVIRONMENT "${UBSAN_ENV_SUPPRESSIONS}")
854       add_dependencies(test_Cryptography_PGP crypto_test_data)
855     endif()
857     trojita_test(Misc Rfc5322)
858     trojita_test(Misc RingBuffer)
859     trojita_test(Misc SenderIdentitiesModel)
860     trojita_test(Misc SqlCache)
861     trojita_test(Misc algorithms)
862     trojita_test(Misc rfccodecs)
863     trojita_test(Misc prettySize)
864     trojita_test(Misc Formatting)
865     trojita_test(Misc QaimDfsIterator)
866     trojita_test(Misc FavoriteTagsModel)
868 endif()
870 if(WIN32) # Check if we are on Windows
871     if(MSVC10) # Check if we are using the Visual Studio compiler 2010
872         # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
873         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
874     elseif(MINGW)
875     else()
876         message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
877         message(WARNING "Please let us know how well it works.")
878     endif()
879 endif()