cmake: Fix a typo in user-facing message from the build system
[trojita.git] / CMakeLists.txt
blob1a9b06c320c1f8989397b4a21e46afafc32c1161
1 project(trojita)
2 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
4 if(WIN32)
5     # Due to QtMain linking
6     cmake_minimum_required(VERSION 2.8.11)
7     if(POLICY CMP0020)
8         cmake_policy(SET CMP0020 NEW)
9     endif()
10 elseif(WITH_QT5)
11     # The Qt5's qt5_use_modules is only available on 2.8.9 or later -- sweet, isn't it?
12     cmake_minimum_required(VERSION 2.8.9)
13 else()
14     cmake_minimum_required(VERSION 2.8.7)
15 endif()
17 if(POLICY CMP0054)
18     # Silence warnings in TrojitaOption.cmake; we are fine with only doing the
19     # expansion by hand
20     cmake_policy(SET CMP0054 NEW)
21 endif()
23 if(POLICY CMP0043)
24     # We make use of CMAKE_CXXFLAGS_DEBUG...
25     cmake_policy(SET CMP0043 OLD)
26 endif()
28 # Set a default build type if none was specified. This was shamelessly stolen
29 # from VTK's cmake setup because these guys produce both CMake and a project that
30 # manipulates this variable, and the web is full of posts where people say that
31 # it is apparently evil to just set the build type in a way an earlier version of
32 # this patch did. Oh, and the location of this check/update matters, apparently.
34 # Yes, this is just plain crazy.
35 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
36     message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
37     set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
38     # Set the possible values of build type for cmake-gui
39     set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
40 endif()
42 # POSITION_INDEPENDENT_CODE is only available on cmake 2.8.9 or later
43 # Add needed flags for supported compilers which simulate POSITION_INDEPENDENT_CODE property
44 if(CMAKE_VERSION VERSION_LESS "2.8.9")
45     if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
46         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
47     else()
48         message(FATAL_ERROR "Needs GNU or Clang C++ compiler or CMake 2.8.9 (or later)")
49     endif()
50 else()
51     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
52 endif()
54 include(FindCXXFeatures)
55 if(NOT CXXFeatures_auto_FOUND)
56     message(SEND_ERROR "Your compiler doesn't support C++11's auto")
57 endif()
58 if(NOT CXXFeatures_static_assert_FOUND)
59     message(SEND_ERROR "Your compiler doesn't support C++11's static_assert")
60 endif()
61 if(NOT CXXFeatures_alignof_FOUND)
62     if(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT MSVC)
63         message(SEND_ERROR "Your compiler doesn't support C++11's alignof and it also isn't gcc or MSVC. Either would work.")
64     endif()
65 endif()
66 if(NOT CXXFeatures_nullptr_FOUND)
67     # Yes, this is extremely fragile; it will break on any code which wants to
68     # distinguish between an int and nullptr_t. So far, we don't have anything
69     # like that in Trojita. Let's just pretend that it won't ever happen, and
70     # if it happens, then let's hope that an "ambiguous overload" would come up.
71     add_definitions(-Dnullptr=0)
72     message(WARNING "Your C++ compiler doesn't support C++11's nullptr. Activating a very hackish workaround "
73             "which can break existing code because nullptr is not plain 0.")
74 endif()
75 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
77 include(TrojitaOption)
79 trojita_option(WITH_DESKTOP "Build desktop version" ON)
80 trojita_option(WITH_HARMATTAN "Build MeeGo Harmattan version" OFF "NOT WITH_DESKTOP")
81 trojita_option(WITH_QT5 "Build with Qt5 library" OFF)
82 trojita_option(WITH_DBUS "Build with DBus library" AUTO)
83 trojita_option(WITH_RAGEL "Build with Ragel library" AUTO)
84 trojita_option(WITH_ZLIB "Build with zlib library" AUTO)
85 trojita_option(WITH_SHARED_PLUGINS "Enable shared dynamic plugins" ON)
86 trojita_option(WITH_TESTS "Build tests" ON "NOT WITH_HARMATTAN")
88 if(WIN32)
89     trojita_option(WITH_NSIS "Build Windows NSIS installer" AUTO "WITH_DESKTOP")
90 endif()
92 if(UNIX AND NOT APPLE)
93     set(QTKEYCHAIN_DEPENDS ";WITH_DBUS")
94 else()
95     set(QTKEYCHAIN_DEPENDS "")
96 endif()
98 if(WITH_QT5)
99     message(STATUS "Building the Qt5 version")
100     find_package(Qt5Core 5.2 REQUIRED)
101     find_package(Qt5Gui REQUIRED)
102     find_package(Qt5Network REQUIRED)
103     find_package(Qt5Sql REQUIRED)
104     find_package(Qt5WebKitWidgets REQUIRED)
105     find_package(Qt5Widgets REQUIRED)
106     find_package(Qt5LinguistTools)
107     trojita_find_package(Qt5DBus "" "http://qt-project.org" "Qt5 D-Bus support" "Needed for IPC and for some plugins" WITH_DBUS)
108     trojita_find_package(Qt5Test "" "http://qt-project.org" "Qt5 QTest library" "Needed for automated tests" WITH_TESTS)
109     if(Qt5LinguistTools_FOUND)
110         find_package(Qt5LinguistForTrojita)
111     endif()
112 else()
113     message(STATUS "Building the Qt4 version")
114     set(QT_USE_QTNETWORK 1)
115     set(QT_USE_QTSQL 1)
116     set(QT_USE_QTWEBKIT 1)
117     if(WITH_DBUS)
118         set(QT_USE_QTDBUS 1)
119     endif()
120     if(WITH_TESTS)
121         set(QT_USE_QTTEST 1)
122     endif()
123     if(WITH_HARMATTAN)
124         set(QT_USE_QTDECLARATIVE 1)
125     endif()
126     trojita_find_package(Qt4 4.6 "http://qt-project.org" "Qt4" "Needed for building" REQUIRED)
127     include(${QT_USE_FILE})
128     trojita_check_qt4_module(QTCORE REQUIRED)
129     trojita_check_qt4_module(QTGUI REQUIRED)
130     trojita_check_qt4_module(QTNETWORK REQUIRED)
131     trojita_check_qt4_module(QTSQL REQUIRED)
132     trojita_check_qt4_module(QTWEBKIT REQUIRED)
133     trojita_check_qt4_module(QTDBUS WITH_DBUS)
134     trojita_check_qt4_module(QTTEST WITH_TESTS)
135     trojita_check_qt4_module(QTDECLARATIVE WITH_HARMATTAN)
136     trojita_find_package(LinguistForTrojita "" "" "" "")
137     if(NOT QT_QCONFIG MATCHES "openssl" OR QT_QCONFIG MATCHES "no-openssl")
138         message(FATAL_ERROR "Your copy of Qt was build without SSL support. Please get openssl and rebuild Qt or a Qt binary with SSL support compiled in")
139     endif()
140 endif()
142 trojita_plugin_option(WITH_CLEARTEXT_PLUGIN "Build Cleartext password plugin" STATIC)
143 trojita_plugin_option(WITH_QTKEYCHAIN_PLUGIN "Build Qtkeychain password plugin" "NOT WITH_HARMATTAN${QTKEYCHAIN_DEPENDS}")
145 trojita_find_package(Git "" "" "" "")
147 if(WIN32)
148     trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
149 endif()
151 # Add support for Mingw RC compiler
152 if(WIN32)
153     enable_language(RC)
154     include(CMakeDetermineRCCompiler)
156     if(MINGW)
157         set(CMAKE_RC_COMPILER_INIT windres)
158         set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
159     endif()
160 endif()
162 if (WITH_QT5)
163     trojita_find_package(Qt5Keychain QUIET "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library (Qt5 version)" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
164 else()
165     trojita_find_package(QtKeychain QUIET "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
166 endif()
167 if(Qt5Keychain_FOUND OR QtKeychain_FOUND)
168     message(STATUS "Found QtKeychain library (includes at ${QTKEYCHAIN_INCLUDE_DIRS}, lib at ${QTKEYCHAIN_LIBRARIES})")
169 else()
170     message(STATUS "Could not find QtKeychain library")
171 endif()
173 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
174     set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
175 endif()
176 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
178 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
179     set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
180 endif()
181 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
183 if(NOT PLUGIN_DIR)
184     if(IS_ABSOLUTE ${CMAKE_INSTALL_PLUGIN_DIR})
185         set(PLUGIN_DIR "${CMAKE_INSTALL_PLUGIN_DIR}")
186     else()
187         set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
188     endif()
189 endif()
190 mark_as_advanced(PLUGIN_DIR)
192 include(GNUInstallDirs)
194 # When manipulating CXXFLAGS, we put the user's CXXFLAGS *after* that so that they take priority.
195 if(MSVC)
196     # See below for some reationale for these optimizations
197     set(CMAKE_CXX_FLAGS "/O2 ${CMAKE_CXX_FLAGS}")
199     # We have no information about the warnings and their usefullness. Reports are welcome.
200     # We might enable warnings on MSVC in future.
201 else()
202     # -Werror is not a default for sanity reasons (one cannot know what warnings a future compiler
203     # might bring along), but it's a default in debug mode. The idea is that developers should care
204     # about a warning-free build, and that this is easier than messing with yet another configure option.
205     set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
206     # Also see CMP0043...
208     # Optimizations are enabled unconditionally because they make a big difference in the speed of the
209     # resulting binaries, and that it is better to allow an opt-out from them by adjusting CXXFLAGS through
210     # an env var at cmake time if needed.
211     # The reason for not manipulating just CMAKE_CXX_FLAGS_DEBUG is that unrecognized build types ("DebugFull")
212     # should still benefit from these optimizations. Yup, it would be even better if CMake did a sane thing
213     # and warned when users set an unrecognized and unused build type, but that just isn't the case.
214     set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
216     # Build warnings are useful tools (and Trojita should be warning-free anyway), enable them on all
217     # configurations. They are warnings, not errors.
218     set(CMAKE_CXX_FLAGS "-Wall -Wsign-compare ${CMAKE_CXX_FLAGS}")
219 endif()
221 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
222 # The following is required so that the moc_*.cpp and ui_*.h are found
223 include_directories(${CMAKE_CURRENT_BINARY_DIR})
224 add_definitions(-DQT_STRICT_ITERATORS)
226 # Make sure that plugins not export all symbols, only that which are explicitly marked
227 include(GenerateExportHeader)
228 add_compiler_export_flags()
230 if(NOT WITH_QT5 AND CMAKE_VERSION VERSION_LESS 2.8.10)
231     set(SUPPORTS_TARGET_INCLUDES 0)
232     include_directories(
233         ${QT_MKSPECS_DIR}/default
234         ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/
235         ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4/io/
236         ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer
237         ${CMAKE_CURRENT_SOURCE_DIR}/tests
238         ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_LibMailboxSync)
239 else()
240     set(SUPPORTS_TARGET_INCLUDES 1)
241 endif()
243 set(CMAKE_AUTOMOC True)
245 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
247 if(WIN32) # Check if we are on Windows
248     # On win32, qt can statically link to zlib and export their symbols.
249     # We check if we can find the string " zlib " in the QT_CONFIG list in
250     # ${QT_MKSPECS_DIR}/qconfig.pri and include on success ${QT_QTCORE_LIBRARY}
251     # and ${QTDIR}/src/3rdparty/zlib as lib and include folder
252     if(QT_QTCORE_FOUND)
253         message(STATUS "We are on Windows with Qt. Checking if zlib is built into Qt")
255         if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
256             file(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents_ZLIB_CHECK)
257             string(REGEX MATCH "QT_CONFIG[^\n]+" QT_CONFIG_ZLIB_CHECK ${_qconfig_FILE_contents_ZLIB_CHECK})
259             set(ENV_QTDIR $ENV{QTDIR})
260             if(NOT DEFINED ENV_QTDIR)
261                 message(STATUS "QTDIR not specified in environment, will not use zlib")
262             elseif(QT_CONFIG_ZLIB_CHECK)
263                 if(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
264                     message(STATUS "Found zlib in QT_QCONFIG. zlib seems to be built into Qt")
265                     set(ZLIB_LIBRARY_RELEASE ${QT_QTCORE_LIBRARY_RELEASE})
266                     set(ZLIB_LIBRARY_DEBUG ${QT_QTCORE_LIBRARY_DEBUG})
267                     set(ZLIB_LIBRARY ${QT_QTCORE_LIBRARY})
269                     string(REGEX REPLACE "\\\\" "/" QTDIR ${ENV_QTDIR})
270                     set(ZLIB_INCLUDE_DIR "${QTDIR}/src/3rdparty/zlib")
272                     set(ZLIB_FOUND TRUE)
273                     set(ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
274                     mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR ZLIB_FOUND)
275                 else(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
276                     message(STATUS "Could not determine if Qt was built with zlib support.")
277                 endif(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
279             endif()
280         endif(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
281     endif(QT_QTCORE_FOUND)
282 endif()
284 if(NOT ZLIB_FOUND)
285     trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
286 endif()
288 if(WITH_ZLIB)
289     set(TROJITA_HAVE_ZLIB True)
290     message(STATUS "Support for COMPRESS=DEFLATE enabled")
291 else()
292     set(TROJITA_HAVE_ZLIB False)
293     message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
294 endif()
296 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
297     ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
299 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES DESCRIPTION "\n" WHAT ALL)
301 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
302 set(libCommon_SOURCES
303     ${path_Common}/Application.cpp
304     ${path_Common}/ConnectionId.cpp
305     ${path_Common}/DeleteAfter.cpp
306     ${path_Common}/FileLogger.cpp
307     ${path_Common}/MetaTypes.cpp
308     ${path_Common}/Paths.cpp
309     ${path_Common}/SettingsNames.cpp
312 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
313 set(libPlugins_SOURCES
314     ${path_Plugins}/AddressbookPlugin.cpp
315     ${path_Plugins}/PasswordPlugin.cpp
316     ${path_Plugins}/PluginJob.cpp
317     ${path_Plugins}/PluginManager.cpp
320 set(path_UiUtils ${CMAKE_CURRENT_SOURCE_DIR}/src/UiUtils)
321 set(libUiUtils_SOURCES
322     ${path_UiUtils}/Color.cpp
323     ${path_UiUtils}/Formatting.cpp
324     ${path_UiUtils}/IconLoader.cpp
325     ${path_UiUtils}/PasswordWatcher.cpp
326     ${path_UiUtils}/PlainTextFormatter.cpp
329 set(path_IPC ${CMAKE_CURRENT_SOURCE_DIR}/src/IPC)
331 if(WITH_DBUS)
332     set(libIPC_SOURCES
333         ${path_IPC}/DBusInterface.cpp
334         ${path_IPC}/MainWindowBridge.cpp
335     )
336 else()
337     set(libIPC_SOURCES
338         ${path_IPC}/None.cpp
339     )
340 endif()
342 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
343 set(libComposer_SOURCES
344     ${path_Composer}/ComposerAttachments.cpp
345     ${path_Composer}/Mailto.cpp
346     ${path_Composer}/MessageComposer.cpp
347     ${path_Composer}/QuoteText.cpp
348     ${path_Composer}/Recipients.cpp
349     ${path_Composer}/ReplaceSignature.cpp
350     ${path_Composer}/SenderIdentitiesModel.cpp
351     ${path_Composer}/SubjectMangling.cpp
352     ${path_Composer}/Submission.cpp
355 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
356 set(libMSA_SOURCES
357     ${path_MSA}/AbstractMSA.cpp
358     ${path_MSA}/Account.cpp
359     ${path_MSA}/FakeMSA.cpp
360     ${path_MSA}/ImapSubmit.cpp
361     ${path_MSA}/SMTP.cpp
362     ${path_MSA}/Sendmail.cpp
365 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
366 set(libStreams_SOURCES
367     ${path_Streams}/DeletionWatcher.cpp
368     ${path_Streams}/FakeSocket.cpp
369     ${path_Streams}/IODeviceSocket.cpp
370     ${path_Streams}/Socket.cpp
371     ${path_Streams}/SocketFactory.cpp
374 if(WITH_ZLIB)
375     set(libStreams_SOURCES ${libStreams_SOURCES}
376         ${path_Streams}/3rdparty/rfc1951.cpp)
377     include_directories(${ZLIB_INCLUDE_DIR})
378 endif()
380 if(NOT WITH_QT5)
381     set(path_mimetypesqt4 ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4)
382     set(libMimetypesQt4_SOURCES
383         ${path_mimetypesqt4}/io/qstandardpaths.cpp
384         ${path_mimetypesqt4}/mimetypes/qmimedatabase.cpp
385         ${path_mimetypesqt4}/mimetypes/qmimeglobpattern.cpp
386         ${path_mimetypesqt4}/mimetypes/qmimemagicrule.cpp
387         ${path_mimetypesqt4}/mimetypes/qmimemagicrulematcher.cpp
388         ${path_mimetypesqt4}/mimetypes/qmimetype.cpp
389         ${path_mimetypesqt4}/mimetypes/qmimetypeparser.cpp
390         ${path_mimetypesqt4}/mimetypes/qmimeprovider.cpp
391     )
392     if(WIN32)
393         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
394             ${path_mimetypesqt4}/io/qstandardpaths_win.cpp)
395     elseif(APPLE)
396         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
397             ${path_mimetypesqt4}/io/qstandardpaths_mac.cpp)
398     elseif (OS2)
399         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
400             ${path_mimetypesqt4}/io/qstandardpaths_os2.cpp)
401     elseif (UNIX)
402         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
403             ${path_mimetypesqt4}/io/qstandardpaths_unix.cpp)
404     else()
405         message(FATAL_ERROR "Unsupported platform -- mimetypes-Qt4 support only Unix, MacOSX, Windows and OS/2")
406     endif()
407 endif()
409 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
410 set(libDesktopGui_SOURCES
411     ${path_DesktopGui}/AttachmentView.cpp
412     ${path_DesktopGui}/AutoCompletion.cpp
413     ${path_DesktopGui}/CompleteMessageWidget.cpp
414     ${path_DesktopGui}/ComposeWidget.cpp
415     ${path_DesktopGui}/ComposerAttachmentsList.cpp
416     ${path_DesktopGui}/ComposerTextEdit.cpp
417     ${path_DesktopGui}/EmbeddedWebView.cpp
418     ${path_DesktopGui}/EnvelopeView.cpp
419     ${path_DesktopGui}/ExternalElementsWidget.cpp
420     ${path_DesktopGui}/FindBar.cpp
421     ${path_DesktopGui}/FlowLayout.cpp
422     ${path_DesktopGui}/FromAddressProxyModel.cpp
423     ${path_DesktopGui}/LineEdit.cpp
424     ${path_DesktopGui}/LoadablePartWidget.cpp
425     ${path_DesktopGui}/MailBoxTreeView.cpp
426     ${path_DesktopGui}/MessageListWidget.cpp
427     ${path_DesktopGui}/MessageSourceWidget.cpp
428     ${path_DesktopGui}/MessageView.cpp
429     ${path_DesktopGui}/MsgListView.cpp
430     ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
431     ${path_DesktopGui}/OverlayWidget.cpp
432     ${path_DesktopGui}/PartWalker.cpp
433     ${path_DesktopGui}/PartWidget.cpp
434     ${path_DesktopGui}/PartWidgetFactoryVisitor.cpp
435     ${path_DesktopGui}/PasswordDialog.cpp
436     ${path_DesktopGui}/ProgressPopUp.cpp
437     ${path_DesktopGui}/ProtocolLoggerWidget.cpp
438     ${path_DesktopGui}/ReplaceCharValidator.cpp
439     ${path_DesktopGui}/SettingsDialog.cpp
440     ${path_DesktopGui}/SimplePartWidget.cpp
441     ${path_DesktopGui}/Spinner.cpp
442     ${path_DesktopGui}/TagListWidget.cpp
443     ${path_DesktopGui}/TagWidget.cpp
444     ${path_DesktopGui}/TaskProgressIndicator.cpp
445     ${path_DesktopGui}/UserAgentWebPage.cpp
446     ${path_DesktopGui}/Util.cpp
447     ${path_DesktopGui}/Window.cpp
448     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
449     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
450     ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
452 set(libDesktopGui_UI
453     ${path_DesktopGui}/AboutDialog.ui
454     ${path_DesktopGui}/ComposeWidget.ui
455     ${path_DesktopGui}/CreateMailboxDialog.ui
456     ${path_DesktopGui}/EditIdentity.ui
457     ${path_DesktopGui}/PasswordDialog.ui
458     ${path_DesktopGui}/ProgressPopUp.ui
459     ${path_DesktopGui}/SettingsCachePage.ui
460     ${path_DesktopGui}/SettingsGeneralPage.ui
461     ${path_DesktopGui}/SettingsImapPage.ui
462     ${path_DesktopGui}/SettingsOutgoingPage.ui
463     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
465 set(libDesktopGui_RESOURCES
466     ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
467     ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
470 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
472 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
474 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
475 set(libImap_SOURCES
476     ${path_Imap}/ConnectionState.cpp
477     ${path_Imap}/Encoders.cpp
478     ${path_Imap}/Exceptions.cpp
479     ${path_Imap}/Parser/3rdparty/kcodecs.cpp
480     ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
482     ${path_Imap}/Parser/Command.cpp
483     ${path_Imap}/Parser/Data.cpp
484     ${path_Imap}/Parser/LowLevelParser.cpp
485     ${path_Imap}/Parser/MailAddress.cpp
486     ${path_Imap}/Parser/Message.cpp
487     ${path_Imap}/Parser/Parser.cpp
488     ${path_Imap}/Parser/Response.cpp
489     ${path_Imap}/Parser/Sequence.cpp
490     ${path_Imap}/Parser/ThreadingNode.cpp
492     ${path_Imap}/Network/FileDownloadManager.cpp
493     ${path_Imap}/Network/ForbiddenReply.cpp
494     ${path_Imap}/Network/MsgPartNetAccessManager.cpp
495     ${path_Imap}/Network/MsgPartNetworkReply.cpp
496     ${path_Imap}/Network/QQuickNetworkReplyWrapper.cpp
498     ${path_Imap}/Model/Cache.cpp
499     ${path_Imap}/Model/CombinedCache.cpp
500     ${path_Imap}/Model/DragAndDrop.cpp
501     ${path_Imap}/Model/DiskPartCache.cpp
502     ${path_Imap}/Model/DummyNetworkWatcher.cpp
503     ${path_Imap}/Model/FindInterestingPart.cpp
504     ${path_Imap}/Model/FlagsOperation.cpp
505     ${path_Imap}/Model/FullMessageCombiner.cpp
506     ${path_Imap}/Model/ImapAccess.cpp
507     ${path_Imap}/Model/MailboxFinder.cpp
508     ${path_Imap}/Model/MailboxMetadata.cpp
509     ${path_Imap}/Model/MailboxModel.cpp
510     ${path_Imap}/Model/MailboxTree.cpp
511     ${path_Imap}/Model/MemoryCache.cpp
512     ${path_Imap}/Model/Model.cpp
513     ${path_Imap}/Model/MsgListModel.cpp
514     ${path_Imap}/Model/NetworkWatcher.cpp
515     ${path_Imap}/Model/OneMessageModel.cpp
516     ${path_Imap}/Model/ParserState.cpp
517     ${path_Imap}/Model/PrettyMailboxModel.cpp
518     ${path_Imap}/Model/PrettyMsgListModel.cpp
519     ${path_Imap}/Model/SpecialFlagNames.cpp
520     ${path_Imap}/Model/SQLCache.cpp
521     ${path_Imap}/Model/SubtreeModel.cpp
522     ${path_Imap}/Model/SystemNetworkWatcher.cpp
523     ${path_Imap}/Model/TaskFactory.cpp
524     ${path_Imap}/Model/TaskPresentationModel.cpp
525     ${path_Imap}/Model/ThreadingMsgListModel.cpp
526     ${path_Imap}/Model/Utils.cpp
527     ${path_Imap}/Model/VisibleTasksModel.cpp
529     # The ModelTest is only needed when debugging manually
530     #${path_Imap}/Model/ModelTest/modeltest.cpp
531     # The ModelWatcher is another debugging aid
532     ${path_Imap}/Model/ModelWatcher.cpp
534     ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
536     ${path_Imap}/Tasks/AppendTask.cpp
537     ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
538     ${path_Imap}/Tasks/CreateMailboxTask.cpp
539     ${path_Imap}/Tasks/DeleteMailboxTask.cpp
540     ${path_Imap}/Tasks/EnableTask.cpp
541     ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
542     ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
543     ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
544     ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
545     ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
546     ${path_Imap}/Tasks/FetchMsgPartTask.cpp
547     ${path_Imap}/Tasks/GenUrlAuthTask.cpp
548     ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
549     ${path_Imap}/Tasks/IdTask.cpp
550     ${path_Imap}/Tasks/IdleLauncher.cpp
551     ${path_Imap}/Tasks/ImapTask.cpp
552     ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
553     ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
554     ${path_Imap}/Tasks/NoopTask.cpp
555     ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
556     ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
557     ${path_Imap}/Tasks/OfflineConnectionTask.cpp
558     ${path_Imap}/Tasks/OpenConnectionTask.cpp
559     ${path_Imap}/Tasks/SortTask.cpp
560     ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
561     ${path_Imap}/Tasks/ThreadTask.cpp
562     ${path_Imap}/Tasks/UidSubmitTask.cpp
563     ${path_Imap}/Tasks/UnSelectTask.cpp
564     ${path_Imap}/Tasks/UpdateFlagsTask.cpp
565     ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
568 if(WITH_RAGEL)
569     message(STATUS "Using Ragel for the RFC 5322 parser")
570     ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
571     set(libImap_SOURCES ${libImap_SOURCES}
572         ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
573 else()
574     message(STATUS "Using pregenerated RFC 5322 parser")
575     set(libImap_SOURCES ${libImap_SOURCES}
576         ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
577 endif()
579 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/AbookAddressbook)
580 set(libAbookAddressbook_SOURCES
581     ${path_AbookAddressbook}/AbookAddressbook.cpp
582     ${path_AbookAddressbook}/be-contacts.cpp
584 set(libAbookAddressbook_UI
585     ${path_AbookAddressbook}/be-contacts.ui
586     ${path_AbookAddressbook}/onecontact.ui
589 set(trojita_desktop_SOURCES
590     ${path_DesktopGui}/main.cpp
593 if(WIN32)
594     list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
595     set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc APPEND PROPERTY OBJECT_DEPENDS
596         ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.ico
597         ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h
598         ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h
599     )
600 endif()
602 set(be_contacts_SOURCES
603     ${CMAKE_CURRENT_SOURCE_DIR}/src/be.contacts/main.cpp
606 set(libQNAMWebView_SOURCES
607     ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/plugin.cpp
608     ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qdeclarativewebview.cpp
611 set(trojitaHarmattan_SOURCES
612     ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/main.cpp
613     ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer/qmlapplicationviewer.cpp
616 if(LinguistForTrojita_FOUND OR Qt5LinguistForTrojita_FOUND)
617     file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
618     if(WITH_QT5)
619         qt5_wrap_po(trojita_QM ${lang_PO})
620     else()
621         qt4_wrap_po(trojita_QM ${lang_PO})
622     endif()
623     set(language_summary "")
624     foreach(po ${lang_PO})
625         string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
626         list(APPEND language_summary ${lang})
627     endforeach()
628     list(SORT language_summary)
629     list(LENGTH language_summary num_languages)
630     if(num_languages)
631         message(STATUS "Available languages: ${language_summary}")
632         if(WITH_DESKTOP)
633             install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/trojita/locale" REGEX "(x_test)|(.*\\.ts)" EXCLUDE)
634         endif()
635     else()
636         message(STATUS "No .po files found, will not install any languages")
637     endif()
638 else()
639     message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
640 endif()
642 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
643 if(WITH_NSIS)
644     set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
645     set(NSIS TRUE)
646 endif()
648 add_custom_target(version DEPENDS version_fake_file)
649 add_custom_command(OUTPUT version_fake_file ${version_files}
650     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)
651 set_source_files_properties(${version_files}
652     PROPERTIES GENERATED TRUE
653     HEADER_FILE_ONLY TRUE)
655 add_library(Common STATIC ${libCommon_SOURCES})
656 set_property(TARGET Common APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
657 add_dependencies(Common version)
658 target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
660 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
661 set_property(TARGET AppVersion APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
662 add_dependencies(AppVersion version)
663 target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
665 if(WITH_SHARED_PLUGINS)
666     add_library(Plugins SHARED ${libPlugins_SOURCES})
667 else()
668     add_library(Plugins STATIC ${libPlugins_SOURCES})
669     set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
670 endif()
671 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
672 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
673 if(WITH_QT5)
674     qt5_use_modules(Plugins Core)
675 else()
676     target_link_libraries(Plugins ${QT_QTCORE_LIBRARY})
677 endif()
679 add_library(UiUtils STATIC ${libUiUtils_SOURCES})
680 set_property(TARGET UiUtils APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
681 target_link_libraries(UiUtils Plugins Common ${QT_QTCORE_LIBRARY})
683 add_library(Streams STATIC ${libStreams_SOURCES})
684 set_property(TARGET Streams APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
685 target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
686 if(WITH_ZLIB)
687     target_link_libraries(Streams ${ZLIB_LIBRARIES})
688 endif()
690 add_library(IPC STATIC ${libIPC_SOURCES})
691 set_property(TARGET IPC APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
692 if(WITH_DBUS)
693     target_link_libraries(IPC ${QT_QTDBUS_LIBRARY})
694     if(WITH_QT5)
695         qt5_use_modules(IPC DBus Widgets)
696     endif()
697 else()
698     if(WITH_QT5)
699         qt5_use_modules(IPC Core)
700     endif()
701 endif()
703 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
704 target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
706 add_library(MSA STATIC ${libMSA_SOURCES})
707 set_property(TARGET MSA APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
708 target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
710 add_library(Composer STATIC ${libComposer_SOURCES})
711 set_property(TARGET Composer APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
712 target_link_libraries(Composer Common MSA Streams UiUtils qwwsmtpclient ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
713 if(NOT WITH_QT5)
714     target_link_libraries(Composer MimetypesQt4)
715 endif()
717 add_library(Imap STATIC ${libImap_SOURCES})
718 set_property(TARGET Imap APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
719 target_link_libraries(Imap Common Streams UiUtils ${QT_QTNETWORK_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
720 if(WITH_ZLIB)
721     target_link_libraries(Imap ${ZLIB_LIBRARIES})
722 endif()
724 if(NOT WITH_QT5)
725     add_library(MimetypesQt4 STATIC ${libMimetypesQt4_SOURCES})
726     if(SUPPORTS_TARGET_INCLUDES)
727         set_property(TARGET MimetypesQt4 APPEND PROPERTY INCLUDE_DIRECTORIES
728             ${QT_MKSPECS_DIR}/default ${path_mimetypesqt4}/io/)
729     endif()
730     target_link_libraries(MimetypesQt4 ${QT_QTCORE_LIBRARY})
731     if(APPLE)
732         find_library(CARBON_LIBRARY Carbon REQUIRED)
733         target_link_libraries(MimetypesQt4 ${CARBON_LIBRARY})
734     endif()
735 endif()
737 ## ClearText password plugin
738 if(WITH_CLEARTEXT_PLUGIN)
739     trojita_add_plugin(trojita_plugin_ClearTextPasswordPlugin WITH_CLEARTEXT_PLUGIN src/Plugins/ClearTextPassword/ClearTextPassword.cpp)
740 endif()
742 ## QtKeyChain plugin
743 if(WITH_QTKEYCHAIN_PLUGIN)
744     trojita_add_plugin(trojita_plugin_QtKeychainPasswordPlugin WITH_QTKEYCHAIN_PLUGIN src/Plugins/QtKeyChain/QtKeyChainPassword.cpp)
745     if(WITH_QT5)
746         qt5_use_modules(trojita_plugin_QtKeychainPasswordPlugin Core DBus)
747     else()
748         target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
749     endif()
750     target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QTKEYCHAIN_LIBRARIES})
751     if(SUPPORTS_TARGET_INCLUDES)
752         set_property(TARGET trojita_plugin_QtKeychainPasswordPlugin APPEND PROPERTY INCLUDE_DIRECTORIES ${QTKEYCHAIN_INCLUDE_DIRS})
753     else()
754         include_directories(${QTKEYCHAIN_INCLUDE_DIRS})
755     endif()
756 endif()
758 # Generate file static_plugins.h.in
759 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
760 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
761 foreach(PLUGIN ${STATIC_PLUGINS})
762     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
763 endforeach()
764 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
766 if(WITH_DESKTOP)
767     if(WITH_QT5)
768         qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
769         qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
770         qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
771     else()
772         qt4_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
773         qt4_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
774         qt4_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
775     endif()
777     add_library(AbookAddressbook STATIC ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
778     set_property(TARGET AbookAddressbook APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
779     target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
781     add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
782     set_property(TARGET DesktopGui APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
783     # The following is needed for the LineEdit widget within the .ui files.
784     # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
785     if(SUPPORTS_TARGET_INCLUDES)
786         set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
787     endif()
788     target_link_libraries(DesktopGui Common UiUtils Composer Imap IPC MSA Plugins Streams qwwsmtpclient AbookAddressbook ${QT_QTWEBKIT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
790     # On Windows build a real Win32 GUI application without console window
791     # On other platforms WIN32 flag is ignored
792     add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
793     set_property(TARGET trojita APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
794     target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
795     if(NOT WITH_QT5)
796         target_link_libraries(trojita MimetypesQt4)
797     endif()
798     if(WITH_ZLIB)
799         target_link_libraries(trojita ${ZLIB_LIBRARIES})
800     endif()
802     add_executable(be.contacts WIN32 ${be_contacts_SOURCES})
803     set_property(TARGET be.contacts APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
804     target_link_libraries(be.contacts AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
805 elseif(WITH_HARMATTAN)
806     add_library(trojitaqnamwebviewplugin SHARED ${libQNAMWebView_SOURCES})
807     add_executable(trojita-tp ${trojitaHarmattan_SOURCES})
808     set_property(TARGET trojita-tp APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII)
809     if(SUPPORTS_TARGET_INCLUDES)
810         set_property(TARGET trojita-tp APPEND PROPERTY INCLUDE_DIRECTORIES
811             ${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer)
812     endif()
813     target_link_libraries(trojita-tp AppVersion Imap MSA Streams qwwsmtpclient Common Composer MimetypesQt4
814         ${QT_QTSQL_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
815 endif()
817 if(WITH_QT5)
818     qt5_use_modules(AppVersion Core)
819     qt5_use_modules(Common Core Network)
820     qt5_use_modules(UiUtils Core Gui Network)
821     qt5_use_modules(Streams Network)
822     qt5_use_modules(qwwsmtpclient Network)
823     qt5_use_modules(MSA Network)
824     qt5_use_modules(Composer Gui Network)
825     qt5_use_modules(Imap Gui Network Sql)
826     if (WITH_DESKTOP)
827         qt5_use_modules(DesktopGui Network WebKitWidgets)
828         qt5_use_modules(AbookAddressbook Widgets)
829         qt5_use_modules(be.contacts Widgets)
830         qt5_use_modules(trojita Widgets Network)
831     endif()
832 endif()
835 if(WITH_SHARED_PLUGINS)
836     install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
837 endif()
839 include(SanitizedDesktopFile)
841 if(WITH_DESKTOP)
842     copy_desktop_file_without_cruft("${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.desktop" "${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop")
843     install(TARGETS trojita be.contacts RUNTIME DESTINATION bin)
844     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications/" RENAME trojita.desktop)
845     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.appdata.xml DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/appdata/")
846     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps/")
847     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps/")
848 endif()
850 if(WITH_HARMATTAN)
851     set(trojita_harmattan_path ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan)
852     install(TARGETS trojita-tp RUNTIME DESTINATION bin)
853     install(TARGETS trojitaqnamwebviewplugin LIBRARY DESTINATION bin/net/flaska/QNAMWebView)
854     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qmldir DESTINATION bin/net/flaska/QNAMWebView)
855     install(DIRECTORY ${trojita_harmattan_path}/qml DESTINATION ${CMAKE_INSTALL_PREFIX})
856     install(FILES ${trojita_harmattan_path}/trojita-tp.desktop DESTINATION share/applications)
857     install(FILES ${trojita_harmattan_path}/trojita-tp80.png DESTINATION share/icons/hicolor/80x80/apps)
858 endif()
860 if(WITH_NSIS)
861     include(TrojitaNSIS)
862 endif()
865 if(WITH_TESTS)
866     set(test_LibMailboxSync_SOURCES
867         tests/Utils/ModelEvents.cpp
868         tests/Utils/LibMailboxSync.cpp
869     )
870     add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
871     if(WITH_QT5)
872         qt5_use_modules(test_LibMailboxSync Test Network)
873     endif()
874     if(SUPPORTS_TARGET_INCLUDES)
875         set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
876             ${CMAKE_CURRENT_SOURCE_DIR}/tests
877             ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
878     endif()
879     target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
881     macro(trojita_test dir fname)
882         set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
883         add_executable(test_${fname} ${test_${fname}_SOURCES})
884         target_link_libraries(test_${fname} Imap MSA Streams Common Composer test_LibMailboxSync)
885         if(WITH_QT5)
886             qt5_use_modules(test_${fname} Network Sql Test Widgets)
887         else()
888             target_link_libraries(test_${fname} ${QT_QTSQL_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
889         endif()
890         if(WITH_ZLIB)
891             target_link_libraries(test_${fname} ${ZLIB_LIBRARIES})
892         endif()
893         if(SUPPORTS_TARGET_INCLUDES)
894             set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
895         endif()
896         if(NOT CMAKE_CROSSCOMPILING)
897             add_test(test_${fname} test_${fname})
898         endif()
899     endmacro()
901     enable_testing()
902     trojita_test(Composer Composer_Submission)
903     trojita_test(Composer Composer_responses)
904     trojita_test(Composer Html_formatting)
905     if(WITH_QT5)
906         qt5_use_modules(test_Composer_responses WebKitWidgets)
907         qt5_use_modules(test_Html_formatting WebKitWidgets)
908     else()
909         target_link_libraries(test_Html_formatting ${QT_QTWEBKIT_LIBRARY})
910     endif()
911     trojita_test(Imap Imap_DisappearingMailboxes)
912     trojita_test(Imap Imap_Idle)
913     trojita_test(Imap Imap_LowLevelParser)
914     trojita_test(Imap Imap_Message)
915     trojita_test(Imap Imap_Model)
916     trojita_test(Imap Imap_MsgPartNetAccessManager)
917     trojita_test(Imap Imap_Parser_parse)
918     trojita_test(Imap Imap_Responses)
919     trojita_test(Imap Imap_SelectedMailboxUpdates)
920     trojita_test(Imap Imap_Tasks_CreateMailbox)
921     trojita_test(Imap Imap_Tasks_DeleteMailbox)
922     trojita_test(Imap Imap_Tasks_ListChildMailboxes)
923     trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
924     trojita_test(Imap Imap_Tasks_OpenConnection)
925     trojita_test(Imap Imap_Threading)
926     trojita_test(Imap Imap_BodyParts)
927     trojita_test(Imap Imap_Offline)
928     trojita_test(Imap Imap_CopyAndFlagOperations)
929     trojita_test(Misc Rfc5322)
930     trojita_test(Misc RingBuffer)
931     trojita_test(Misc SenderIdentitiesModel)
932     trojita_test(Misc SqlCache)
933     trojita_test(Misc algorithms)
934     trojita_test(Misc rfccodecs)
936 endif()
938 if(WIN32) # Check if we are on Windows
939     if(MSVC10) # Check if we are using the Visual Studio compiler 2010
940         # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
941         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
942     elseif(MINGW)
943     else()
944         message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
945         message(WARNING "Please let us know how well it works.")
946     endif()
947 endif()