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 # Set a default build type if none was specified. This was shamelessly stolen
22 # from VTK's cmake setup because these guys produce both CMake and a project that
23 # manipulates this variable, and the web is full of posts where people say that
24 # it is apparently evil to just set the build type in a way an earlier version of
25 # this patch did. Oh, and the location of this check/update matters, apparently.
27 # Yes, this is just plain crazy.
28 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
29 message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
30 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
31 # Set the possible values of build type for cmake-gui
32 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
35 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
37 include(FindCXXFeatures)
38 if(NOT CXXFeatures_auto_FOUND)
39 message(SEND_ERROR "Your compiler doesn't support C++11's auto")
41 if(NOT CXXFeatures_static_assert_FOUND)
42 message(SEND_ERROR "Your compiler doesn't support C++11's static_assert")
44 if(NOT CXXFeatures_alignof_FOUND)
45 message(SEND_ERROR "Your compiler doesn't support C++11's alignof")
47 if(NOT CXXFeatures_nullptr_FOUND)
48 message(SEND_ERROR "Your compiler doesn't support C++11's nullptr")
50 if(NOT CXXFeatures_lambda_FOUND)
51 message(SEND_ERROR "Your compiler doesn't support C++11's lambda functions")
53 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
55 include(TrojitaOption)
57 trojita_option(WITH_DESKTOP "Build desktop version" ON)
58 trojita_option(WITH_DBUS "Build with DBus library" AUTO)
59 trojita_option(WITH_RAGEL "Build with Ragel library" AUTO)
60 trojita_option(WITH_ZLIB "Build with zlib library" AUTO)
61 trojita_option(WITH_SHARED_PLUGINS "Enable shared dynamic plugins" ON)
62 trojita_option(WITH_TESTS "Build tests" ON)
65 trojita_option(WITH_NSIS "Build Windows NSIS installer" AUTO "WITH_DESKTOP")
68 if(UNIX AND NOT APPLE)
69 set(QTKEYCHAIN_DEPENDS ";WITH_DBUS")
71 set(QTKEYCHAIN_DEPENDS "")
74 find_package(Qt5Core 5.2 REQUIRED)
75 find_package(Qt5Gui REQUIRED)
76 find_package(Qt5Network REQUIRED)
77 find_package(Qt5Sql REQUIRED)
78 find_package(Qt5WebKitWidgets REQUIRED)
79 find_package(Qt5Widgets REQUIRED)
80 find_package(Qt5LinguistTools)
81 trojita_find_package(Qt5DBus "" "http://qt-project.org" "Qt5 D-Bus support" "Needed for IPC and for some plugins" WITH_DBUS)
82 trojita_find_package(Qt5Test "" "http://qt-project.org" "Qt5 QTest library" "Needed for automated tests" WITH_TESTS)
83 if(Qt5LinguistTools_FOUND)
84 find_package(Qt5LinguistForTrojita)
87 trojita_plugin_option(WITH_ABOOKADDRESSBOOK_PLUGIN "Build AbookAddressbook plugin" STATIC)
88 trojita_plugin_option(WITH_CLEARTEXT_PLUGIN "Build Cleartext password plugin" STATIC)
89 trojita_plugin_option(WITH_QTKEYCHAIN_PLUGIN "Build Qtkeychain password plugin" "${QTKEYCHAIN_DEPENDS}")
91 trojita_find_package(Git "" "" "" "")
94 trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
97 # Add support for Mingw RC compiler
100 include(CMakeDetermineRCCompiler)
103 set(CMAKE_RC_COMPILER_INIT windres)
104 set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -I${CMAKE_CURRENT_BINARY_DIR} -i <SOURCE> -o <OBJECT>")
108 trojita_find_package(Qt5Keychain QUIET "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library (Qt5 version)" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
109 if(Qt5Keychain_FOUND OR QtKeychain_FOUND)
110 message(STATUS "Found QtKeychain library (includes at ${QTKEYCHAIN_INCLUDE_DIRS}, lib at ${QTKEYCHAIN_LIBRARIES})")
112 message(STATUS "Could not find QtKeychain library")
115 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
116 set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
118 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
120 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
121 set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
123 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
126 if(IS_ABSOLUTE ${CMAKE_INSTALL_PLUGIN_DIR})
127 set(PLUGIN_DIR "${CMAKE_INSTALL_PLUGIN_DIR}")
129 set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
132 mark_as_advanced(PLUGIN_DIR)
134 include(GNUInstallDirs)
136 # When manipulating CXXFLAGS, we put the user's CXXFLAGS *after* that so that they take priority.
138 # See below for some reationale for these optimizations
139 set(CMAKE_CXX_FLAGS "/O2 ${CMAKE_CXX_FLAGS}")
141 # We have no information about the warnings and their usefullness. Reports are welcome.
142 # We might enable warnings on MSVC in future.
144 # -Werror is not a default for sanity reasons (one cannot know what warnings a future compiler
145 # might bring along), but it's a default in debug mode. The idea is that developers should care
146 # about a warning-free build, and that this is easier than messing with yet another configure option.
147 set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
148 # Also see CMP0043...
150 # Optimizations are enabled unconditionally because they make a big difference in the speed of the
151 # resulting binaries, and that it is better to allow an opt-out from them by adjusting CXXFLAGS through
152 # an env var at cmake time if needed.
153 # The reason for not manipulating just CMAKE_CXX_FLAGS_DEBUG is that unrecognized build types ("DebugFull")
154 # should still benefit from these optimizations. Yup, it would be even better if CMake did a sane thing
155 # and warned when users set an unrecognized and unused build type, but that just isn't the case.
156 set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
158 # Build warnings are useful tools (and Trojita should be warning-free anyway), enable them on all
159 # configurations. They are warnings, not errors.
160 set(CMAKE_CXX_FLAGS "-Wall -Wsign-compare ${CMAKE_CXX_FLAGS}")
163 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
164 # The following is required so that the moc_*.cpp and ui_*.h are found
165 include_directories(${CMAKE_CURRENT_BINARY_DIR})
167 add_definitions(-DQT_STRICT_ITERATORS)
168 add_definitions(-DQT_USE_QSTRINGBUILDER)
169 add_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
170 add_definitions(-DQT_USE_FAST_CONCATENATION)
172 # Make sure that plugins not export all symbols, only that which are explicitly marked
173 include(GenerateExportHeader)
174 add_compiler_export_flags()
176 set(CMAKE_AUTOMOC True)
178 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
179 trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
182 set(TROJITA_HAVE_ZLIB True)
183 message(STATUS "Support for COMPRESS=DEFLATE enabled")
185 set(TROJITA_HAVE_ZLIB False)
186 message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
189 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
190 ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
192 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES DESCRIPTION "\n" WHAT ALL)
194 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
195 set(libCommon_SOURCES
196 ${path_Common}/Application.cpp
197 ${path_Common}/ConnectionId.cpp
198 ${path_Common}/DeleteAfter.cpp
199 ${path_Common}/FileLogger.cpp
200 ${path_Common}/MetaTypes.cpp
201 ${path_Common}/Paths.cpp
202 ${path_Common}/SettingsNames.cpp
205 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
206 set(libPlugins_SOURCES
207 ${path_Plugins}/AddressbookPlugin.cpp
208 ${path_Plugins}/PasswordPlugin.cpp
209 ${path_Plugins}/PluginJob.cpp
210 ${path_Plugins}/PluginManager.cpp
213 set(path_UiUtils ${CMAKE_CURRENT_SOURCE_DIR}/src/UiUtils)
214 set(libUiUtils_SOURCES
215 ${path_UiUtils}/Color.cpp
216 ${path_UiUtils}/Formatting.cpp
217 ${path_UiUtils}/IconLoader.cpp
218 ${path_UiUtils}/PasswordWatcher.cpp
219 ${path_UiUtils}/PlainTextFormatter.cpp
222 set(path_IPC ${CMAKE_CURRENT_SOURCE_DIR}/src/IPC)
226 ${path_IPC}/DBusInterface.cpp
227 ${path_IPC}/MainWindowBridge.cpp
235 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
236 set(libComposer_SOURCES
237 ${path_Composer}/ComposerAttachments.cpp
238 ${path_Composer}/Mailto.cpp
239 ${path_Composer}/MessageComposer.cpp
240 ${path_Composer}/QuoteText.cpp
241 ${path_Composer}/Recipients.cpp
242 ${path_Composer}/ReplaceSignature.cpp
243 ${path_Composer}/SenderIdentitiesModel.cpp
244 ${path_Composer}/SubjectMangling.cpp
245 ${path_Composer}/Submission.cpp
248 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
250 ${path_MSA}/AbstractMSA.cpp
251 ${path_MSA}/Account.cpp
252 ${path_MSA}/FakeMSA.cpp
253 ${path_MSA}/ImapSubmit.cpp
255 ${path_MSA}/Sendmail.cpp
258 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
259 set(libStreams_SOURCES
260 ${path_Streams}/DeletionWatcher.cpp
261 ${path_Streams}/FakeSocket.cpp
262 ${path_Streams}/IODeviceSocket.cpp
263 ${path_Streams}/Socket.cpp
264 ${path_Streams}/SocketFactory.cpp
268 set(libStreams_SOURCES ${libStreams_SOURCES}
269 ${path_Streams}/3rdparty/rfc1951.cpp)
272 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
273 set(libDesktopGui_SOURCES
274 ${path_DesktopGui}/AddressRowWidget.cpp
275 ${path_DesktopGui}/AttachmentView.cpp
276 ${path_DesktopGui}/CompleteMessageWidget.cpp
277 ${path_DesktopGui}/ComposeWidget.cpp
278 ${path_DesktopGui}/ComposerAttachmentsList.cpp
279 ${path_DesktopGui}/ComposerTextEdit.cpp
280 ${path_DesktopGui}/EmbeddedWebView.cpp
281 ${path_DesktopGui}/EnvelopeView.cpp
282 ${path_DesktopGui}/ExternalElementsWidget.cpp
283 ${path_DesktopGui}/FindBar.cpp
284 ${path_DesktopGui}/FlowLayout.cpp
285 ${path_DesktopGui}/FromAddressProxyModel.cpp
286 ${path_DesktopGui}/LineEdit.cpp
287 ${path_DesktopGui}/LoadablePartWidget.cpp
288 ${path_DesktopGui}/MailBoxTreeView.cpp
289 ${path_DesktopGui}/MessageListWidget.cpp
290 ${path_DesktopGui}/MessageSourceWidget.cpp
291 ${path_DesktopGui}/MessageView.cpp
292 ${path_DesktopGui}/MsgListView.cpp
293 ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
294 ${path_DesktopGui}/OneEnvelopeAddress.cpp
295 ${path_DesktopGui}/OverlayWidget.cpp
296 ${path_DesktopGui}/PartWalker.cpp
297 ${path_DesktopGui}/PartWidget.cpp
298 ${path_DesktopGui}/PartWidgetFactoryVisitor.cpp
299 ${path_DesktopGui}/PasswordDialog.cpp
300 ${path_DesktopGui}/ProgressPopUp.cpp
301 ${path_DesktopGui}/ProtocolLoggerWidget.cpp
302 ${path_DesktopGui}/ReplaceCharValidator.cpp
303 ${path_DesktopGui}/SettingsDialog.cpp
304 ${path_DesktopGui}/SimplePartWidget.cpp
305 ${path_DesktopGui}/Spinner.cpp
306 ${path_DesktopGui}/TagListWidget.cpp
307 ${path_DesktopGui}/TagWidget.cpp
308 ${path_DesktopGui}/TaskProgressIndicator.cpp
309 ${path_DesktopGui}/UserAgentWebPage.cpp
310 ${path_DesktopGui}/Util.cpp
311 ${path_DesktopGui}/Window.cpp
312 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
313 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
314 ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
317 ${path_DesktopGui}/AboutDialog.ui
318 ${path_DesktopGui}/ComposeWidget.ui
319 ${path_DesktopGui}/CreateMailboxDialog.ui
320 ${path_DesktopGui}/EditIdentity.ui
321 ${path_DesktopGui}/PasswordDialog.ui
322 ${path_DesktopGui}/ProgressPopUp.ui
323 ${path_DesktopGui}/SettingsCachePage.ui
324 ${path_DesktopGui}/SettingsGeneralPage.ui
325 ${path_DesktopGui}/SettingsImapPage.ui
326 ${path_DesktopGui}/SettingsOutgoingPage.ui
327 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
329 set(libDesktopGui_RESOURCES
330 ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
331 ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
334 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
336 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
338 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
340 ${path_Imap}/ConnectionState.cpp
341 ${path_Imap}/Encoders.cpp
342 ${path_Imap}/Exceptions.cpp
343 ${path_Imap}/Parser/3rdparty/kcodecs.cpp
344 ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
346 ${path_Imap}/Parser/Command.cpp
347 ${path_Imap}/Parser/Data.cpp
348 ${path_Imap}/Parser/LowLevelParser.cpp
349 ${path_Imap}/Parser/MailAddress.cpp
350 ${path_Imap}/Parser/Message.cpp
351 ${path_Imap}/Parser/Parser.cpp
352 ${path_Imap}/Parser/Response.cpp
353 ${path_Imap}/Parser/Sequence.cpp
354 ${path_Imap}/Parser/ThreadingNode.cpp
356 ${path_Imap}/Network/FileDownloadManager.cpp
357 ${path_Imap}/Network/ForbiddenReply.cpp
358 ${path_Imap}/Network/MsgPartNetAccessManager.cpp
359 ${path_Imap}/Network/MsgPartNetworkReply.cpp
360 ${path_Imap}/Network/QQuickNetworkReplyWrapper.cpp
362 ${path_Imap}/Model/Cache.cpp
363 ${path_Imap}/Model/CombinedCache.cpp
364 ${path_Imap}/Model/DragAndDrop.cpp
365 ${path_Imap}/Model/DiskPartCache.cpp
366 ${path_Imap}/Model/DummyNetworkWatcher.cpp
367 ${path_Imap}/Model/FindInterestingPart.cpp
368 ${path_Imap}/Model/FlagsOperation.cpp
369 ${path_Imap}/Model/FullMessageCombiner.cpp
370 ${path_Imap}/Model/ImapAccess.cpp
371 ${path_Imap}/Model/MailboxFinder.cpp
372 ${path_Imap}/Model/MailboxMetadata.cpp
373 ${path_Imap}/Model/MailboxModel.cpp
374 ${path_Imap}/Model/MailboxTree.cpp
375 ${path_Imap}/Model/MemoryCache.cpp
376 ${path_Imap}/Model/Model.cpp
377 ${path_Imap}/Model/MsgListModel.cpp
378 ${path_Imap}/Model/NetworkWatcher.cpp
379 ${path_Imap}/Model/OneMessageModel.cpp
380 ${path_Imap}/Model/ParserState.cpp
381 ${path_Imap}/Model/PrettyMailboxModel.cpp
382 ${path_Imap}/Model/PrettyMsgListModel.cpp
383 ${path_Imap}/Model/SpecialFlagNames.cpp
384 ${path_Imap}/Model/SQLCache.cpp
385 ${path_Imap}/Model/SubtreeModel.cpp
386 ${path_Imap}/Model/SystemNetworkWatcher.cpp
387 ${path_Imap}/Model/TaskFactory.cpp
388 ${path_Imap}/Model/TaskPresentationModel.cpp
389 ${path_Imap}/Model/ThreadingMsgListModel.cpp
390 ${path_Imap}/Model/Utils.cpp
391 ${path_Imap}/Model/VisibleTasksModel.cpp
393 # The ModelTest is only needed when debugging manually
394 #${path_Imap}/Model/ModelTest/modeltest.cpp
395 # The ModelWatcher is another debugging aid
396 ${path_Imap}/Model/ModelWatcher.cpp
398 ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
400 ${path_Imap}/Tasks/AppendTask.cpp
401 ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
402 ${path_Imap}/Tasks/CreateMailboxTask.cpp
403 ${path_Imap}/Tasks/DeleteMailboxTask.cpp
404 ${path_Imap}/Tasks/EnableTask.cpp
405 ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
406 ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
407 ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
408 ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
409 ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
410 ${path_Imap}/Tasks/FetchMsgPartTask.cpp
411 ${path_Imap}/Tasks/GenUrlAuthTask.cpp
412 ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
413 ${path_Imap}/Tasks/IdTask.cpp
414 ${path_Imap}/Tasks/IdleLauncher.cpp
415 ${path_Imap}/Tasks/ImapTask.cpp
416 ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
417 ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
418 ${path_Imap}/Tasks/NoopTask.cpp
419 ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
420 ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
421 ${path_Imap}/Tasks/OfflineConnectionTask.cpp
422 ${path_Imap}/Tasks/OpenConnectionTask.cpp
423 ${path_Imap}/Tasks/SortTask.cpp
424 ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
425 ${path_Imap}/Tasks/ThreadTask.cpp
426 ${path_Imap}/Tasks/UidSubmitTask.cpp
427 ${path_Imap}/Tasks/UnSelectTask.cpp
428 ${path_Imap}/Tasks/UpdateFlagsTask.cpp
429 ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
433 message(STATUS "Using Ragel for the RFC 5322 parser")
434 ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
435 set(libImap_SOURCES ${libImap_SOURCES}
436 ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
438 message(STATUS "Using pregenerated RFC 5322 parser")
439 set(libImap_SOURCES ${libImap_SOURCES}
440 ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
443 set(trojita_desktop_SOURCES
444 ${path_DesktopGui}/main.cpp
448 list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
449 set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc APPEND PROPERTY OBJECT_DEPENDS
450 ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.ico
451 ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h
452 ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h
456 if(Qt5LinguistForTrojita_FOUND)
457 file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
458 qt5_wrap_po(trojita_QM ${lang_PO})
459 set(language_summary "")
460 foreach(po ${lang_PO})
461 string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
462 list(APPEND language_summary ${lang})
464 list(SORT language_summary)
465 list(LENGTH language_summary num_languages)
467 message(STATUS "Available languages: ${language_summary}")
469 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/trojita/locale" REGEX "(x_test)|(.*\\.ts)" EXCLUDE)
472 message(STATUS "No .po files found, will not install any languages")
475 message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
478 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
480 set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
484 add_custom_target(version DEPENDS version_fake_file)
485 add_custom_command(OUTPUT version_fake_file ${version_files}
486 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)
487 set_source_files_properties(${version_files}
488 PROPERTIES GENERATED TRUE
489 HEADER_FILE_ONLY TRUE)
491 add_library(Common STATIC ${libCommon_SOURCES})
492 set_property(TARGET Common APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
493 add_dependencies(Common version)
494 qt5_use_modules(Common Core Network)
496 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
497 set_property(TARGET AppVersion APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
498 add_dependencies(AppVersion version)
499 target_link_libraries(AppVersion Common)
500 qt5_use_modules(AppVersion Core)
502 if(WITH_SHARED_PLUGINS)
503 add_library(Plugins SHARED ${libPlugins_SOURCES})
505 add_library(Plugins STATIC ${libPlugins_SOURCES})
506 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
508 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
509 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
510 qt5_use_modules(Plugins Core)
512 add_library(UiUtils STATIC ${libUiUtils_SOURCES})
513 set_property(TARGET UiUtils APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
514 target_link_libraries(UiUtils Plugins Common)
515 qt5_use_modules(UiUtils Core Gui Network)
517 add_library(Streams STATIC ${libStreams_SOURCES})
518 set_property(TARGET Streams APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
520 set_property(TARGET Streams APPEND PROPERTY INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR})
521 target_link_libraries(Streams ${ZLIB_LIBRARIES})
523 qt5_use_modules(Streams Network)
525 add_library(IPC STATIC ${libIPC_SOURCES})
526 set_property(TARGET IPC APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
528 qt5_use_modules(IPC DBus Widgets)
530 qt5_use_modules(IPC Core)
533 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
534 qt5_use_modules(qwwsmtpclient Network)
536 add_library(MSA STATIC ${libMSA_SOURCES})
537 set_property(TARGET MSA APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
538 target_link_libraries(MSA Imap Streams qwwsmtpclient)
539 qt5_use_modules(MSA Network)
541 add_library(Composer STATIC ${libComposer_SOURCES})
542 set_property(TARGET Composer APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
543 target_link_libraries(Composer Common MSA Streams UiUtils qwwsmtpclient)
544 qt5_use_modules(Composer Gui Network)
546 add_library(Imap STATIC ${libImap_SOURCES})
547 set_property(TARGET Imap APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
548 target_link_libraries(Imap Common Streams UiUtils)
549 qt5_use_modules(Imap Gui Network Sql)
551 ## ClearText password plugin
552 if(WITH_CLEARTEXT_PLUGIN)
553 trojita_add_plugin(trojita_plugin_ClearTextPasswordPlugin WITH_CLEARTEXT_PLUGIN src/Plugins/ClearTextPassword/ClearTextPassword.cpp)
557 if(WITH_QTKEYCHAIN_PLUGIN)
558 trojita_add_plugin(trojita_plugin_QtKeychainPasswordPlugin WITH_QTKEYCHAIN_PLUGIN src/Plugins/QtKeyChain/QtKeyChainPassword.cpp)
559 qt5_use_modules(trojita_plugin_QtKeychainPasswordPlugin Core DBus)
560 target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QTKEYCHAIN_LIBRARIES})
561 set_property(TARGET trojita_plugin_QtKeychainPasswordPlugin APPEND PROPERTY INCLUDE_DIRECTORIES ${QTKEYCHAIN_INCLUDE_DIRS})
564 ## AbookAddressbook plugin
565 if(WITH_ABOOKADDRESSBOOK_PLUGIN)
566 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins/AbookAddressbook)
567 set(libAbookAddressbook_HEADERS
568 ${path_AbookAddressbook}/AbookAddressbook.h
569 ${path_AbookAddressbook}/be-contacts.h
571 set(libAbookAddressbook_SOURCES
572 ${path_AbookAddressbook}/AbookAddressbook.cpp
573 ${path_AbookAddressbook}/be-contacts.cpp
575 set(libAbookAddressbook_UI
576 ${path_AbookAddressbook}/be-contacts.ui
577 ${path_AbookAddressbook}/onecontact.ui
580 qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
582 trojita_add_plugin(trojita_plugin_AbookAddressbookPlugin WITH_ABOOKADDRESSBOOK_PLUGIN ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
583 set_property(TARGET trojita_plugin_AbookAddressbookPlugin APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
585 qt5_use_modules(trojita_plugin_AbookAddressbookPlugin Widgets)
587 set(be_contacts_SOURCES
588 ${path_AbookAddressbook}/main.cpp
591 add_executable(be.contacts WIN32 ${be_contacts_SOURCES})
592 set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
593 target_link_libraries(be.contacts Plugins)
594 if("${WITH_ABOOKADDRESSBOOK_PLUGIN}" STREQUAL "STATIC")
595 set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
596 target_link_libraries(be.contacts trojita_plugin_AbookAddressbookPlugin)
598 qt5_use_modules(be.contacts Widgets)
601 # Generate file static_plugins.h.in
602 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
603 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
604 foreach(PLUGIN ${STATIC_PLUGINS})
605 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
607 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
610 qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
611 qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
613 add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
614 set_property(TARGET DesktopGui APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
615 # The following is needed for the LineEdit widget within the .ui files.
616 # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
617 set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
618 target_link_libraries(DesktopGui Common UiUtils Composer Imap IPC MSA Plugins Streams qwwsmtpclient)
620 # On Windows build a real Win32 GUI application without console window
621 # On other platforms WIN32 flag is ignored
622 add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
623 set_property(TARGET trojita APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
624 target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS})
625 qt5_use_modules(DesktopGui Network WebKitWidgets)
626 qt5_use_modules(trojita Widgets Network)
630 if(WITH_SHARED_PLUGINS)
631 install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
634 include(SanitizedDesktopFile)
636 if(WITH_ABOOKADDRESSBOOK_PLUGIN)
637 install(TARGETS be.contacts RUNTIME DESTINATION bin)
641 copy_desktop_file_without_cruft("${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.desktop" "${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop")
642 install(TARGETS trojita RUNTIME DESTINATION bin)
643 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications/" RENAME trojita.desktop)
644 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.appdata.xml DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/appdata/")
645 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps/")
646 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps/")
655 set(test_LibMailboxSync_SOURCES
656 tests/Utils/ModelEvents.cpp
657 tests/Utils/LibMailboxSync.cpp
659 add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
660 qt5_use_modules(test_LibMailboxSync Test Network)
661 set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
662 ${CMAKE_CURRENT_SOURCE_DIR}/tests
663 ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
664 target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer)
666 macro(trojita_test dir fname)
667 set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
668 add_executable(test_${fname} ${test_${fname}_SOURCES})
669 target_link_libraries(test_${fname} Imap MSA Streams Common Composer test_LibMailboxSync)
670 qt5_use_modules(test_${fname} Network Sql Test Widgets)
671 set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
672 if(NOT CMAKE_CROSSCOMPILING)
673 add_test(test_${fname} test_${fname})
678 trojita_test(Composer Composer_Submission)
679 trojita_test(Composer Composer_responses)
680 trojita_test(Composer Html_formatting)
681 qt5_use_modules(test_Composer_responses WebKitWidgets)
682 qt5_use_modules(test_Html_formatting WebKitWidgets)
683 trojita_test(Imap Imap_DisappearingMailboxes)
684 trojita_test(Imap Imap_Idle)
685 trojita_test(Imap Imap_LowLevelParser)
686 trojita_test(Imap Imap_Message)
687 trojita_test(Imap Imap_Model)
688 trojita_test(Imap Imap_MsgPartNetAccessManager)
689 trojita_test(Imap Imap_Parser_parse)
690 trojita_test(Imap Imap_Responses)
691 trojita_test(Imap Imap_SelectedMailboxUpdates)
692 trojita_test(Imap Imap_Tasks_CreateMailbox)
693 trojita_test(Imap Imap_Tasks_DeleteMailbox)
694 trojita_test(Imap Imap_Tasks_ListChildMailboxes)
695 trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
696 trojita_test(Imap Imap_Tasks_OpenConnection)
697 trojita_test(Imap Imap_Threading)
698 trojita_test(Imap Imap_BodyParts)
699 trojita_test(Imap Imap_Offline)
700 trojita_test(Imap Imap_CopyAndFlagOperations)
701 trojita_test(Misc Rfc5322)
702 trojita_test(Misc RingBuffer)
703 trojita_test(Misc SenderIdentitiesModel)
704 trojita_test(Misc SqlCache)
705 trojita_test(Misc algorithms)
706 trojita_test(Misc rfccodecs)
710 if(WIN32) # Check if we are on Windows
711 if(MSVC10) # Check if we are using the Visual Studio compiler 2010
712 # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
713 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
716 message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
717 message(WARNING "Please let us know how well it works.")