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