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)
11 # Silence warnings in TrojitaOption.cmake; we are fine with only doing the
13 cmake_policy(SET CMP0054 NEW)
17 # We make use of CMAKE_CXXFLAGS_DEBUG...
18 cmake_policy(SET CMP0043 OLD)
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}")
25 set(CMAKE_CXX_STANDARD 11)
26 set(CMAKE_CXX_STANDARD_REQUIRED ON)
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")
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)
58 trojita_option(WITH_NSIS "Build Windows NSIS installer" AUTO "WITH_DESKTOP")
61 if(UNIX AND NOT APPLE)
62 set(QTKEYCHAIN_DEPENDS ";WITH_DBUS")
64 set(QTKEYCHAIN_DEPENDS "")
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)
81 trojita_plugin_option(WITH_ABOOKADDRESSBOOK_PLUGIN "Build AbookAddressbook plugin" STATIC)
82 trojita_plugin_option(WITH_CLEARTEXT_PLUGIN "Build Cleartext password plugin" STATIC)
83 trojita_plugin_option(WITH_QTKEYCHAIN_PLUGIN "Build Qtkeychain password plugin" "${QTKEYCHAIN_DEPENDS}")
85 trojita_find_package(Git "" "" "" "")
87 trojita_find_package(Mimetic "" "http://www.codesink.org/mimetic_mime_library.html" "C++ MIME Library" "Required for client-side MIME parsing" WITH_MIMETIC)
88 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)
90 trojita_find_package(KF5Gpgmepp "" "https://commits.kde.org/gpgmepp?path=/" "C++ bindings for gpgme" "Needed for encrypted/signed e-mails" WITH_KF5_GPGMEPP)
91 trojita_option(WITH_CRYPTO_MESSAGES "Enable support for encrypted messages" AUTO "WITH_MIMETIC;WITH_KF5_GPGMEPP")
93 trojita_option(WITH_CRYPTO_MESSAGES "Enable support for encrypted messages" AUTO "WITH_MIMETIC;WITH_GPGMEPP")
97 trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
100 # Add support for Mingw RC compiler
103 include(CMakeDetermineRCCompiler)
106 set(CMAKE_RC_COMPILER_INIT windres)
107 set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -I${CMAKE_CURRENT_BINARY_DIR} -i <SOURCE> -o <OBJECT>")
111 trojita_find_package(Qt5Keychain QUIET "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library (Qt5 version)" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
112 if(Qt5Keychain_FOUND OR QtKeychain_FOUND)
113 message(STATUS "Found QtKeychain library (includes at ${QTKEYCHAIN_INCLUDE_DIRS}, lib at ${QTKEYCHAIN_LIBRARIES})")
115 message(STATUS "Could not find QtKeychain library")
118 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
119 set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
121 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
123 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
124 set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
126 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
129 if(IS_ABSOLUTE ${CMAKE_INSTALL_PLUGIN_DIR})
130 set(PLUGIN_DIR "${CMAKE_INSTALL_PLUGIN_DIR}")
132 set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
135 mark_as_advanced(PLUGIN_DIR)
137 include(GNUInstallDirs)
139 # When manipulating CXXFLAGS, we put the user's CXXFLAGS *after* that so that they take priority.
141 # See below for some reationale for these optimizations
142 set(CMAKE_CXX_FLAGS "/O2 ${CMAKE_CXX_FLAGS}")
144 # We have no information about the warnings and their usefullness. Reports are welcome.
145 # We might enable warnings on MSVC in future.
147 # -Werror is not a default for sanity reasons (one cannot know what warnings a future compiler
148 # might bring along), but it's a default in debug mode. The idea is that developers should care
149 # about a warning-free build, and that this is easier than messing with yet another configure option.
150 set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
151 # Also see CMP0043...
153 # Optimizations are enabled unconditionally because they make a big difference in the speed of the
154 # resulting binaries, and that it is better to allow an opt-out from them by adjusting CXXFLAGS through
155 # an env var at cmake time if needed.
156 # The reason for not manipulating just CMAKE_CXX_FLAGS_DEBUG is that unrecognized build types ("DebugFull")
157 # should still benefit from these optimizations. Yup, it would be even better if CMake did a sane thing
158 # and warned when users set an unrecognized and unused build type, but that just isn't the case.
159 set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
161 # Build warnings are useful tools (and Trojita should be warning-free anyway), enable them on all
162 # configurations. They are warnings, not errors.
163 set(CMAKE_CXX_FLAGS "-Wall -Wsign-compare ${CMAKE_CXX_FLAGS}")
166 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
167 # The following is required so that the moc_*.cpp and ui_*.h are found
168 include_directories(${CMAKE_CURRENT_BINARY_DIR})
170 add_definitions(-DQT_STRICT_ITERATORS)
171 add_definitions(-DQT_USE_QSTRINGBUILDER)
172 add_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
173 add_definitions(-DQT_USE_FAST_CONCATENATION)
176 # We're using C++11's threading features (std::async in particular), and that requires "some threading". With GCC and
177 # Clang, this is implemented through the -pthread build flag. Without using these bits, linking fails on Fedora 23,
178 # and this is apparently a slightly different failure than the Kf5::Gpgmepp-pthread one in commit
179 # 12e41101070f7073caec653185c0504763672ee7.
181 # Apparently, there's been various methods on how to enable this in the most-cmakeish-way throughout the years, with
182 # cmake-3.1+ supporting some magic linking via the Threads::Threads option on a per-library basis. However, I am not
183 # really looking into that wonderful fun of mixing -pthread and non-pthread translation units, so let's use a big
184 # hammer and set it unconditionally on platforms which use it anyway.
186 # And because we also support MinGW and its `windres` compiler, we have to avoid passing -pthread to *that* thing, so,
187 # well, let's cheat and put it into the CXXFLAGS.
188 set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}")
191 # Make sure that plugins not export all symbols, only that which are explicitly marked
192 include(GenerateExportHeader)
193 add_compiler_export_flags()
195 set(CMAKE_AUTOMOC True)
197 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
198 trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
201 set(TROJITA_HAVE_MIMETIC True)
203 set(TROJITA_HAVE_MIMETIC False)
206 if(WITH_GPGMEPP OR WITH_KF5_GPGMEPP)
207 set(TROJITA_HAVE_GPGMEPP True)
209 set(TROJITA_HAVE_GPGMEPP False)
212 if(WITH_CRYPTO_MESSAGES)
213 set(TROJITA_HAVE_CRYPTO_MESSAGES True)
215 set(TROJITA_HAVE_CRYPTO_MESSAGES False)
219 set(TROJITA_HAVE_ZLIB True)
220 message(STATUS "Support for COMPRESS=DEFLATE enabled")
222 set(TROJITA_HAVE_ZLIB False)
223 message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
226 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
227 ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
228 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure-plugins.cmake.in
229 ${CMAKE_CURRENT_BINARY_DIR}/configure-plugins.cmake.h)
231 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES DESCRIPTION "\n" WHAT ALL)
233 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
234 set(libCommon_SOURCES
235 ${path_Common}/Application.cpp
236 ${path_Common}/ConnectionId.cpp
237 ${path_Common}/DeleteAfter.cpp
238 ${path_Common}/FileLogger.cpp
239 ${path_Common}/MetaTypes.cpp
240 ${path_Common}/Paths.cpp
241 ${path_Common}/SettingsNames.cpp
242 ${path_Common}/StashingReverseIterator.h
245 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
246 set(libPlugins_SOURCES
247 ${path_Plugins}/AddressbookPlugin.cpp
248 ${path_Plugins}/PasswordPlugin.cpp
249 ${path_Plugins}/PluginJob.cpp
250 ${path_Plugins}/PluginManager.cpp
253 set(path_UiUtils ${CMAKE_CURRENT_SOURCE_DIR}/src/UiUtils)
254 set(libUiUtils_SOURCES
255 ${path_UiUtils}/Color.cpp
256 ${path_UiUtils}/Formatting.cpp
257 ${path_UiUtils}/IconLoader.cpp
258 ${path_UiUtils}/PartLoadingOptions.h
259 ${path_UiUtils}/PartVisitor.h
260 ${path_UiUtils}/PartWalker.h
261 ${path_UiUtils}/PartWalker_impl.h
262 ${path_UiUtils}/PasswordWatcher.cpp
263 ${path_UiUtils}/PlainTextFormatter.cpp
264 ${path_UiUtils}/QaimDfsIterator.cpp
267 set(path_IPC ${CMAKE_CURRENT_SOURCE_DIR}/src/IPC)
271 ${path_IPC}/DBusInterface.cpp
272 ${path_IPC}/MainWindowBridge.cpp
280 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
281 set(libComposer_SOURCES
282 ${path_Composer}/AbstractComposer.cpp
283 ${path_Composer}/ComposerAttachments.cpp
284 ${path_Composer}/ExistingMessageComposer.cpp
285 ${path_Composer}/Mailto.cpp
286 ${path_Composer}/MessageComposer.cpp
287 ${path_Composer}/QuoteText.cpp
288 ${path_Composer}/Recipients.cpp
289 ${path_Composer}/ReplaceSignature.cpp
290 ${path_Composer}/SenderIdentitiesModel.cpp
291 ${path_Composer}/SubjectMangling.cpp
292 ${path_Composer}/Submission.cpp
295 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
297 ${path_MSA}/AbstractMSA.cpp
298 ${path_MSA}/Account.cpp
299 ${path_MSA}/FakeMSA.cpp
300 ${path_MSA}/ImapSubmit.cpp
302 ${path_MSA}/Sendmail.cpp
305 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
306 set(libStreams_SOURCES
307 ${path_Streams}/DeletionWatcher.cpp
308 ${path_Streams}/FakeSocket.cpp
309 ${path_Streams}/IODeviceSocket.cpp
310 ${path_Streams}/Socket.cpp
311 ${path_Streams}/SocketFactory.cpp
314 set(path_Cryptography ${CMAKE_CURRENT_SOURCE_DIR}/src/Cryptography)
315 set(libCryptography_SOURCES
316 ${path_Cryptography}/MessageModel.cpp
317 ${path_Cryptography}/MessagePart.cpp
318 ${path_Cryptography}/PartReplacer.cpp
321 set(libCryptography_SOURCES
322 ${libCryptography_SOURCES}
323 ${path_Cryptography}/LocalMimeParser.cpp
324 ${path_Cryptography}/MimeticUtils.cpp
327 if(WITH_CRYPTO_MESSAGES)
328 set(libCryptography_SOURCES
329 ${libCryptography_SOURCES}
330 ${path_Cryptography}/GpgMe++.cpp
335 set(libStreams_SOURCES ${libStreams_SOURCES}
336 ${path_Streams}/3rdparty/rfc1951.cpp)
339 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
340 set(libDesktopGui_SOURCES
341 ${path_DesktopGui}/AddressRowWidget.cpp
342 ${path_DesktopGui}/AttachmentView.cpp
343 ${path_DesktopGui}/ColoredItemDelegate.cpp
344 ${path_DesktopGui}/CompleteMessageWidget.cpp
345 ${path_DesktopGui}/ComposeWidget.cpp
346 ${path_DesktopGui}/ComposerAttachmentsList.cpp
347 ${path_DesktopGui}/ComposerTextEdit.cpp
348 ${path_DesktopGui}/EmbeddedWebView.cpp
349 ${path_DesktopGui}/EnvelopeView.cpp
350 ${path_DesktopGui}/ExternalElementsWidget.cpp
351 ${path_DesktopGui}/FindBar.cpp
352 ${path_DesktopGui}/FindBarMixin.cpp
353 ${path_DesktopGui}/FlowLayout.cpp
354 ${path_DesktopGui}/FromAddressProxyModel.cpp
355 ${path_DesktopGui}/LineEdit.cpp
356 ${path_DesktopGui}/LoadablePartWidget.cpp
357 ${path_DesktopGui}/MailBoxTreeView.cpp
358 ${path_DesktopGui}/MessageHeadersWidget.cpp
359 ${path_DesktopGui}/MessageListWidget.cpp
360 ${path_DesktopGui}/MessageSourceWidget.cpp
361 ${path_DesktopGui}/MessageView.cpp
362 ${path_DesktopGui}/MsgListView.cpp
363 ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
364 ${path_DesktopGui}/OneEnvelopeAddress.cpp
365 ${path_DesktopGui}/OverlayWidget.cpp
366 ${path_DesktopGui}/PartWalker.cpp
367 ${path_DesktopGui}/PartWidget.cpp
368 ${path_DesktopGui}/PartWidgetFactoryVisitor.cpp
369 ${path_DesktopGui}/PasswordDialog.cpp
370 ${path_DesktopGui}/ProgressPopUp.cpp
371 ${path_DesktopGui}/ProtocolLoggerWidget.cpp
372 ${path_DesktopGui}/ReplaceCharValidator.cpp
373 ${path_DesktopGui}/SettingsDialog.cpp
374 ${path_DesktopGui}/SimplePartWidget.cpp
375 ${path_DesktopGui}/Spinner.cpp
376 ${path_DesktopGui}/TagAddDialog.cpp
377 ${path_DesktopGui}/TagListWidget.cpp
378 ${path_DesktopGui}/TagWidget.cpp
379 ${path_DesktopGui}/TaskProgressIndicator.cpp
380 ${path_DesktopGui}/UserAgentWebPage.cpp
381 ${path_DesktopGui}/Util.cpp
382 ${path_DesktopGui}/Window.cpp
383 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
384 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
385 ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
388 ${path_DesktopGui}/AboutDialog.ui
389 ${path_DesktopGui}/ComposeWidget.ui
390 ${path_DesktopGui}/CreateMailboxDialog.ui
391 ${path_DesktopGui}/EditIdentity.ui
392 ${path_DesktopGui}/EditFavoriteTag.ui
393 ${path_DesktopGui}/PasswordDialog.ui
394 ${path_DesktopGui}/ProgressPopUp.ui
395 ${path_DesktopGui}/SettingsCachePage.ui
396 ${path_DesktopGui}/SettingsGeneralPage.ui
397 ${path_DesktopGui}/SettingsImapPage.ui
398 ${path_DesktopGui}/SettingsOutgoingPage.ui
399 ${path_DesktopGui}/SettingsFavoriteTagsPage.ui
400 ${path_DesktopGui}/TagAddDialog.ui
401 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
403 set(libDesktopGui_RESOURCES
404 ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
405 ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
408 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
410 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
412 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
414 ${path_Imap}/ConnectionState.cpp
415 ${path_Imap}/Encoders.cpp
416 ${path_Imap}/Exceptions.cpp
417 ${path_Imap}/Parser/3rdparty/kcodecs.cpp
418 ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
420 ${path_Imap}/Parser/Command.cpp
421 ${path_Imap}/Parser/Data.cpp
422 ${path_Imap}/Parser/LowLevelParser.cpp
423 ${path_Imap}/Parser/MailAddress.cpp
424 ${path_Imap}/Parser/Message.cpp
425 ${path_Imap}/Parser/Parser.cpp
426 ${path_Imap}/Parser/Response.cpp
427 ${path_Imap}/Parser/Sequence.cpp
428 ${path_Imap}/Parser/ThreadingNode.cpp
430 ${path_Imap}/Network/FileDownloadManager.cpp
431 ${path_Imap}/Network/ForbiddenReply.cpp
432 ${path_Imap}/Network/MsgPartNetAccessManager.cpp
433 ${path_Imap}/Network/MsgPartNetworkReply.cpp
434 ${path_Imap}/Network/QQuickNetworkReplyWrapper.cpp
436 ${path_Imap}/Model/Cache.cpp
437 ${path_Imap}/Model/CombinedCache.cpp
438 ${path_Imap}/Model/DragAndDrop.cpp
439 ${path_Imap}/Model/DiskPartCache.cpp
440 ${path_Imap}/Model/DummyNetworkWatcher.cpp
441 ${path_Imap}/Model/FindInterestingPart.cpp
442 ${path_Imap}/Model/FlagsOperation.cpp
443 ${path_Imap}/Model/FullMessageCombiner.cpp
444 ${path_Imap}/Model/ImapAccess.cpp
445 ${path_Imap}/Model/MailboxFinder.cpp
446 ${path_Imap}/Model/MailboxMetadata.cpp
447 ${path_Imap}/Model/MailboxModel.cpp
448 ${path_Imap}/Model/MailboxTree.cpp
449 ${path_Imap}/Model/MemoryCache.cpp
450 ${path_Imap}/Model/Model.cpp
451 ${path_Imap}/Model/MsgListModel.cpp
452 ${path_Imap}/Model/NetworkWatcher.cpp
453 ${path_Imap}/Model/OneMessageModel.cpp
454 ${path_Imap}/Model/FavoriteTagsModel.cpp
455 ${path_Imap}/Model/ParserState.cpp
456 ${path_Imap}/Model/PrettyMailboxModel.cpp
457 ${path_Imap}/Model/PrettyMsgListModel.cpp
458 ${path_Imap}/Model/SpecialFlagNames.cpp
459 ${path_Imap}/Model/SQLCache.cpp
460 ${path_Imap}/Model/SubtreeModel.cpp
461 ${path_Imap}/Model/SystemNetworkWatcher.cpp
462 ${path_Imap}/Model/TaskFactory.cpp
463 ${path_Imap}/Model/TaskPresentationModel.cpp
464 ${path_Imap}/Model/ThreadingMsgListModel.cpp
465 ${path_Imap}/Model/Utils.cpp
466 ${path_Imap}/Model/VisibleTasksModel.cpp
468 # The ModelWatcher is another debugging aid
469 ${path_Imap}/Model/ModelWatcher.cpp
471 ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
473 ${path_Imap}/Tasks/AppendTask.cpp
474 ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
475 ${path_Imap}/Tasks/CreateMailboxTask.cpp
476 ${path_Imap}/Tasks/DeleteMailboxTask.cpp
477 ${path_Imap}/Tasks/EnableTask.cpp
478 ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
479 ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
480 ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
481 ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
482 ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
483 ${path_Imap}/Tasks/FetchMsgPartTask.cpp
484 ${path_Imap}/Tasks/GenUrlAuthTask.cpp
485 ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
486 ${path_Imap}/Tasks/IdTask.cpp
487 ${path_Imap}/Tasks/IdleLauncher.cpp
488 ${path_Imap}/Tasks/ImapTask.cpp
489 ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
490 ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
491 ${path_Imap}/Tasks/NoopTask.cpp
492 ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
493 ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
494 ${path_Imap}/Tasks/OfflineConnectionTask.cpp
495 ${path_Imap}/Tasks/OpenConnectionTask.cpp
496 ${path_Imap}/Tasks/SortTask.cpp
497 ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
498 ${path_Imap}/Tasks/ThreadTask.cpp
499 ${path_Imap}/Tasks/UidSubmitTask.cpp
500 ${path_Imap}/Tasks/UnSelectTask.cpp
501 ${path_Imap}/Tasks/UpdateFlagsTask.cpp
502 ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
505 # The ModelTest is only needed when debugging manually
506 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
507 list(APPEND libImap_SOURCES ${path_Imap}/Model/ModelTest/modeltest.cpp)
511 message(STATUS "Using Ragel for the RFC 5322 parser")
512 ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
513 set(libImap_SOURCES ${libImap_SOURCES}
514 ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
516 message(STATUS "Using pregenerated RFC 5322 parser")
517 set(libImap_SOURCES ${libImap_SOURCES}
518 ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
521 set(trojita_desktop_SOURCES
522 ${path_DesktopGui}/main.cpp
526 list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
527 set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc APPEND PROPERTY OBJECT_DEPENDS
528 ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.ico
529 ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h
530 ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h
534 if(Qt5LinguistForTrojita_FOUND)
535 file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
536 qt5_wrap_po(trojita_QM ${lang_PO})
537 set(language_summary "")
538 foreach(po ${lang_PO})
539 string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
540 list(APPEND language_summary ${lang})
542 list(SORT language_summary)
543 list(LENGTH language_summary num_languages)
545 message(STATUS "Available languages: ${language_summary}")
547 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/trojita/locale" REGEX "(x_test)|(.*\\.ts)" EXCLUDE)
550 message(STATUS "No .po files found, will not install any languages")
553 message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
556 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
558 set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
562 add_custom_target(version DEPENDS version_fake_file)
563 add_custom_command(OUTPUT version_fake_file ${version_files}
564 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)
565 set_source_files_properties(${version_files}
566 PROPERTIES GENERATED TRUE
567 HEADER_FILE_ONLY TRUE)
569 add_library(Common STATIC ${libCommon_SOURCES})
570 set_property(TARGET Common APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
571 add_dependencies(Common version)
572 target_link_libraries(Common Qt5::Network)
574 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
575 set_property(TARGET AppVersion APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
576 add_dependencies(AppVersion version)
577 target_link_libraries(AppVersion Common)
578 target_link_libraries(AppVersion Qt5::Core)
580 if(WITH_SHARED_PLUGINS)
581 add_library(Plugins SHARED ${libPlugins_SOURCES})
582 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS BUILDING_LIBTROJITA_PLUGINS)
584 add_library(Plugins STATIC ${libPlugins_SOURCES})
585 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
587 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
588 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
589 target_link_libraries(Plugins Qt5::Core)
591 add_library(UiUtils STATIC ${libUiUtils_SOURCES})
592 set_property(TARGET UiUtils APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
593 target_link_libraries(UiUtils Plugins Common Qt5::Gui)
595 add_library(Streams STATIC ${libStreams_SOURCES})
596 set_property(TARGET Streams APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
598 set_property(TARGET Streams APPEND PROPERTY INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR})
599 target_link_libraries(Streams ${ZLIB_LIBRARIES})
601 target_link_libraries(Streams Qt5::Network)
603 add_library(IPC STATIC ${libIPC_SOURCES})
604 set_property(TARGET IPC APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
606 target_link_libraries(IPC Qt5::DBus Qt5::Widgets)
608 target_link_libraries(IPC Qt5::Core)
611 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
612 target_link_libraries(qwwsmtpclient Qt5::Network)
614 add_library(MSA STATIC ${libMSA_SOURCES})
615 set_property(TARGET MSA APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
616 target_link_libraries(MSA Imap Streams qwwsmtpclient)
618 add_library(Composer STATIC ${libComposer_SOURCES})
619 set_property(TARGET Composer APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
620 target_link_libraries(Composer Common MSA Streams UiUtils qwwsmtpclient)
622 add_library(Imap STATIC ${libImap_SOURCES})
623 set_property(TARGET Imap APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
624 target_link_libraries(Imap Common Streams UiUtils Qt5::Sql)
626 add_library(Cryptography STATIC ${libCryptography_SOURCES})
627 set_property(TARGET Cryptography APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
628 target_link_libraries(Cryptography Common Imap)
630 target_link_libraries(Cryptography ${MIMETIC_LIBRARIES})
631 set_property(TARGET Cryptography APPEND PROPERTY INCLUDE_DIRECTORIES ${MIMETIC_INCLUDE_DIRS})
633 if(WITH_CRYPTO_MESSAGES)
635 target_link_libraries(Cryptography Gpgmepp QGpgme)
636 elseif(WITH_KF5_GPGMEPP)
638 target_link_libraries(Cryptography KF5::Gpgmepp KF5::QGpgme)
640 target_link_libraries(Cryptography KF5::Gpgmepp-pthread KF5::QGpgme)
645 ## ClearText password plugin
646 if(WITH_CLEARTEXT_PLUGIN)
647 trojita_add_plugin(trojita_plugin_ClearTextPasswordPlugin WITH_CLEARTEXT_PLUGIN src/Plugins/ClearTextPassword/ClearTextPassword.cpp)
651 if(WITH_QTKEYCHAIN_PLUGIN)
652 trojita_add_plugin(trojita_plugin_QtKeychainPasswordPlugin WITH_QTKEYCHAIN_PLUGIN src/Plugins/QtKeyChain/QtKeyChainPassword.cpp)
653 target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QTKEYCHAIN_LIBRARIES} Qt5::DBus)
654 set_property(TARGET trojita_plugin_QtKeychainPasswordPlugin APPEND PROPERTY INCLUDE_DIRECTORIES ${QTKEYCHAIN_INCLUDE_DIRS})
657 ## AbookAddressbook plugin
658 if(WITH_ABOOKADDRESSBOOK_PLUGIN)
659 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins/AbookAddressbook)
660 set(libAbookAddressbook_HEADERS
661 ${path_AbookAddressbook}/AbookAddressbook.h
662 ${path_AbookAddressbook}/be-contacts.h
664 set(libAbookAddressbook_SOURCES
665 ${path_AbookAddressbook}/AbookAddressbook.cpp
666 ${path_AbookAddressbook}/be-contacts.cpp
668 set(libAbookAddressbook_UI
669 ${path_AbookAddressbook}/be-contacts.ui
670 ${path_AbookAddressbook}/onecontact.ui
673 qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
675 trojita_add_plugin(trojita_plugin_AbookAddressbookPlugin WITH_ABOOKADDRESSBOOK_PLUGIN ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
676 set_property(TARGET trojita_plugin_AbookAddressbookPlugin APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
678 target_link_libraries(trojita_plugin_AbookAddressbookPlugin Qt5::Widgets)
680 set(be_contacts_SOURCES
681 ${path_AbookAddressbook}/main.cpp
684 add_executable(be.contacts WIN32 ${be_contacts_SOURCES})
685 set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
686 target_link_libraries(be.contacts Plugins)
687 if("${WITH_ABOOKADDRESSBOOK_PLUGIN}" STREQUAL "STATIC")
688 set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
689 target_link_libraries(be.contacts trojita_plugin_AbookAddressbookPlugin)
691 target_link_libraries(be.contacts Qt5::Widgets)
694 # Generate file static_plugins.h.in
695 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
696 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
697 foreach(PLUGIN ${STATIC_PLUGINS})
698 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
700 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
703 qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
704 qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
706 add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
707 set_property(TARGET DesktopGui APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
708 # The following is needed for the LineEdit widget within the .ui files.
709 # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
710 set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
711 target_link_libraries(DesktopGui Common UiUtils Composer Cryptography Imap IPC MSA Plugins Streams qwwsmtpclient Qt5::WebKitWidgets)
713 # On Windows build a real Win32 GUI application without console window
714 # On other platforms WIN32 flag is ignored
715 add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
716 set_property(TARGET trojita APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
717 target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS})
721 if(WITH_SHARED_PLUGINS)
722 install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
725 include(SanitizedDesktopFile)
727 if(WITH_ABOOKADDRESSBOOK_PLUGIN)
728 install(TARGETS be.contacts RUNTIME DESTINATION bin)
732 copy_desktop_file_without_cruft("${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/org.kde.trojita.desktop" "${CMAKE_CURRENT_BINARY_DIR}/org.kde.trojita-DesktopGui.desktop")
733 install(TARGETS trojita RUNTIME DESTINATION bin)
734 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.trojita-DesktopGui.desktop DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications/" RENAME org.kde.trojita.desktop)
735 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/org.kde.trojita.appdata.xml DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
736 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps/")
737 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps/")
746 set(test_LibMailboxSync_SOURCES
747 tests/Utils/ModelEvents.cpp
748 tests/Utils/LibMailboxSync.cpp
750 add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
751 set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
752 ${CMAKE_CURRENT_SOURCE_DIR}/tests
753 ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
754 target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer Qt5::Test)
756 macro(trojita_test dir fname)
757 set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
758 add_executable(test_${fname} ${test_${fname}_SOURCES})
759 target_link_libraries(test_${fname} Imap MSA Streams Common Composer Cryptography test_LibMailboxSync)
760 set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
761 if(NOT CMAKE_CROSSCOMPILING)
762 add_test(test_${fname} test_${fname})
766 set(UBSAN_ENV_SUPPRESSIONS "UBSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/tests/ubsan.supp")
769 trojita_test(Composer Composer_Submission)
770 trojita_test(Composer Composer_Existing)
771 trojita_test(Composer Composer_responses)
772 target_link_libraries(test_Composer_responses Qt5::WebKitWidgets)
773 trojita_test(Composer Html_formatting)
774 target_link_libraries(test_Html_formatting Qt5::WebKitWidgets)
775 trojita_test(Imap Imap_DisappearingMailboxes)
776 trojita_test(Imap Imap_Idle)
777 trojita_test(Imap Imap_LowLevelParser)
778 trojita_test(Imap Imap_Message)
779 trojita_test(Imap Imap_Model)
780 trojita_test(Imap Imap_MsgPartNetAccessManager)
781 set_property(TEST test_Imap_MsgPartNetAccessManager PROPERTY ENVIRONMENT "${UBSAN_ENV_SUPPRESSIONS}")
782 trojita_test(Imap Imap_Parser_parse)
783 trojita_test(Imap Imap_Parser_write)
784 trojita_test(Imap Imap_Responses)
785 trojita_test(Imap Imap_SelectedMailboxUpdates)
786 trojita_test(Imap Imap_Tasks_CreateMailbox)
787 trojita_test(Imap Imap_Tasks_DeleteMailbox)
788 trojita_test(Imap Imap_Tasks_ListChildMailboxes)
789 trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
790 trojita_test(Imap Imap_Tasks_OpenConnection)
791 trojita_test(Imap Imap_Threading)
792 trojita_test(Imap Imap_BodyParts)
793 trojita_test(Imap Imap_Offline)
794 trojita_test(Imap Imap_CopyAndFlagOperations)
795 trojita_test(Cryptography Cryptography_MessageModel)
797 if(WITH_CRYPTO_MESSAGES)
798 find_program(GPGCONF_BINARY NAMES gpgconf)
799 if(GPGCONF_BINARY_NOTFOUND)
800 message(SEND_ERROR "The `gpgconf` binary from GnuPG not found, this is needed for crypto tests.")
804 message(SEND_ERROR "The Cryptography unit tests really need Unix. Patches welcome.")
807 add_library(fake-dev-random SHARED ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils/fake-dev-random.c)
808 set_target_properties(fake-dev-random PROPERTIES AUTOMOC off)
809 target_link_libraries(fake-dev-random dl)
811 # FIXME: it would be nice to depend on the contents of keys/, but in my testing it produces Makefiles
812 # which suffer from races (the keygen.sh is run multiple times in parallel within the CI environment).
813 # I wasn't able to track down the root cause behind this; it affected all cmake versions within the CI
814 # as of Feb 2016, which is 3.1.something up to 3.3.something.
815 add_custom_command(OUTPUT crypto_test_data.h
816 COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/tests/Cryptography/keygen.sh ${CMAKE_CURRENT_SOURCE_DIR}
817 DEPENDS fake-dev-random tests/Cryptography/keygen.sh tests/Cryptography/batch-keygen)
818 add_custom_target(crypto_test_data DEPENDS crypto_test_data.h)
820 trojita_test(Cryptography Cryptography_PGP)
821 set_property(TEST test_Cryptography_PGP PROPERTY ENVIRONMENT "${UBSAN_ENV_SUPPRESSIONS}")
822 add_dependencies(test_Cryptography_PGP crypto_test_data)
825 trojita_test(Misc Rfc5322)
826 trojita_test(Misc RingBuffer)
827 trojita_test(Misc SenderIdentitiesModel)
828 trojita_test(Misc SqlCache)
829 trojita_test(Misc algorithms)
830 trojita_test(Misc rfccodecs)
831 trojita_test(Misc prettySize)
832 trojita_test(Misc Formatting)
833 trojita_test(Misc QaimDfsIterator)
834 trojita_test(Misc FavoriteTagsModel)
838 if(WIN32) # Check if we are on Windows
839 if(MSVC10) # Check if we are using the Visual Studio compiler 2010
840 # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
841 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
844 message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
845 message(WARNING "Please let us know how well it works.")