SVN_SILENT made messages (after extraction)
[trojita.git] / CMakeLists.txt
blobf77adfd4f930a60ea06e09db577da16008500f2e
1 if(WITH_UBUNTU)
2     set(WITH_DESKTOP OFF)
3     set(WITH_QT5 ON)
4 endif()
6 if(WITH_QT5)
7     # The Qt5's qt5_use_modules is only available on 2.8.9 or later -- sweet, isn't it?
8     cmake_minimum_required(VERSION 2.8.9)
9 else()
10     cmake_minimum_required(VERSION 2.8.7)
11 endif()
12 project(trojita)
13 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
15 # POSITION_INDEPENDENT_CODE is only available on cmake 2.8.9 or later
16 # Add needed flags for supported compilers which simulate POSITION_INDEPENDENT_CODE property
17 if(CMAKE_VERSION VERSION_LESS "2.8.9")
18     if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
19         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
20     else()
21         message(FATAL_ERROR "Needs GNU or Clang C++ compiler or CMake 2.8.9 (or later)")
22     endif()
23 else()
24     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
25 endif()
27 include(FindCXXFeatures)
28 if(NOT CXXFeatures_auto_FOUND)
29     message(SEND_ERROR "Your compiler doesn't support C++11's auto")
30 endif()
31 if(NOT CXXFeatures_static_assert_FOUND)
32     message(SEND_ERROR "Your compiler doesn't support C++11's static_assert")
33 endif()
34 if(NOT CXXFeatures_alignof_FOUND)
35     if(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT MSVC)
36         message(SEND_ERROR "Your compiler doesn't support C++11's alignof and it also isn't gcc or MSVC. Either would work.")
37     endif()
38 endif()
39 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
41 include(TrojitaOption)
43 trojita_option(WITH_DESKTOP "Build desktop version" ON)
44 trojita_option(WITH_HARMATTAN "Build MeeGo Harmattan version" OFF "NOT WITH_DESKTOP")
45 trojita_option(WITH_UBUNTU "Build for the Ubuntu SDK" OFF "NOT WITH_DESKTOP;WITH_QT5")
46 trojita_option(WITH_QT5 "Build with Qt5 library" OFF)
47 trojita_option(WITH_RAGEL "Build with Ragel library" AUTO)
48 trojita_option(WITH_ZLIB "Build with zlib library" AUTO)
49 trojita_option(WITH_SHARED_PLUGINS "Enable shared dynamic plugins" ON)
50 trojita_option(WITH_TESTS "Build tests" ON "NOT WITH_HARMATTAN")
51 trojita_option(DEV_FATAL_WARNINGS "Turn build warnings into errors (developers only)" OFF)
53 if(WIN32)
54     trojita_option(WITH_NSIS "Build Windows NSIS installer" AUTO)
55 endif()
57 trojita_plugin_option(WITH_CLEARTEXT_PLUGIN "Build Cleartext password plugin" STATIC)
58 trojita_plugin_option(WITH_QTKEYCHAIN_PLUGIN "Build Qtkeychain password plugin" "NOT WITH_HARMATTAN")
60 if(WITH_QT5)
61     message(STATUS "Building the Qt5 version")
62     find_package(Qt5Core 5.2 REQUIRED)
63     find_package(Qt5Gui REQUIRED)
64     find_package(Qt5Network REQUIRED)
65     find_package(Qt5Sql REQUIRED)
66     find_package(Qt5WebKitWidgets REQUIRED)
67     find_package(Qt5Widgets REQUIRED)
68     find_package(Qt5LinguistTools)
69     if(WITH_TESTS)
70         find_package(Qt5Test REQUIRED)
71     endif()
72     if(Qt5LinguistTools_FOUND)
73         find_package(Qt5LinguistForTrojita)
74     endif()
75     if(WITH_UBUNTU)
76         message(STATUS "Building the Ubuntu Components GUI")
77         find_package(Qt5Quick REQUIRED)
78         find_package(Qt5Qml REQUIRED)
79     endif()
80 else()
81     message(STATUS "Building the Qt4 version")
82     set(QT_USE_QTNETWORK 1)
83     set(QT_USE_QTSQL 1)
84     set(QT_USE_QTWEBKIT 1)
85     if(WITH_TESTS)
86         set(QT_USE_QTTEST 1)
87     endif()
88     if(WITH_HARMATTAN)
89         set(QT_USE_QTDECLARATIVE 1)
90     endif()
91     trojita_find_package(Qt4 4.6 "http://qt-project.org" "Qt4" "Needed for building" REQUIRED)
92     include(${QT_USE_FILE})
93     trojita_check_qt4_module(QTCORE REQUIRED)
94     trojita_check_qt4_module(QTGUI REQUIRED)
95     trojita_check_qt4_module(QTNETWORK REQUIRED)
96     trojita_check_qt4_module(QTSQL REQUIRED)
97     trojita_check_qt4_module(QTWEBKIT REQUIRED)
98     trojita_check_qt4_module(QTTEST WITH_TESTS)
99     trojita_check_qt4_module(QTDECLARATIVE WITH_HARMATTAN)
100     trojita_find_package(LinguistForTrojita "" "" "" "")
101     if(NOT QT_QCONFIG MATCHES "openssl" OR QT_QCONFIG MATCHES "no-openssl")
102         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")
103     endif()
104 endif()
106 trojita_find_package(Git "" "" "" "")
108 if(WIN32)
109     trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
110 endif()
112 # Add support for Mingw RC compiler
113 if(WIN32)
114     enable_language(RC)
115     include(CMakeDetermineRCCompiler)
117     if(MINGW)
118         set(CMAKE_RC_COMPILER_INIT windres)
119         set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
120     endif()
121 endif()
123 if (WITH_QT5)
124     trojita_find_package(Qt5Keychain "" "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library (Qt5 version)" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
125 else()
126     trojita_find_package(QtKeychain "" "https://github.com/frankosterfeld/qtkeychain" "QtKeychain library" "Needed for QtKeychain password plugin" WITH_QTKEYCHAIN_PLUGIN)
127 endif()
128 if(Qt5Keychain_FOUND OR QtKeychain_FOUND)
129     message(STATUS "Found QtKeychain library (includes at ${QTKEYCHAIN_INCLUDE_DIRS}, lib at ${QTKEYCHAIN_LIBRARIES})")
130 endif()
132 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
133     set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
134 endif()
135 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
137 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
138     set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
139 endif()
140 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
142 if(NOT PLUGIN_DIR)
143     if(IS_ABSOLUTE ${CMAKE_INSTALL_PLUGIN_DIR})
144         set(PLUGIN_DIR "${CMAKE_INSTALL_PLUGIN_DIR}")
145     else()
146         set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
147     endif()
148 endif()
149 mark_as_advanced(PLUGIN_DIR)
151 if(NOT WIN32 AND NOT MSVC)
152     # Check if we are NOT on Windows and don't use MSVC since -g is not supported by VC
153     # and Wall makes the build very noisy.
154     # At first, enable optimizations. In my testing, these do *not* make debugging any harder than no optimization and
155     # they (of course) optimize away stuff like QByteArray::operator[] etc.
156     # We put the user's CXXFLAGS *after* that so that they take priority.
157     set(CMAKE_CXX_FLAGS "-O2 -g ${CMAKE_CXX_FLAGS}")
158     # Now enable build warnings; these are useful tools (and Trojita should be warning-free anyway). We do not set
159     # -Werror for sanity reasons, though (one cannot know what warnings a future compiler might bring along).
160     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wsign-compare")
161 endif(NOT WIN32 AND NOT MSVC)
162 if(DEV_FATAL_WARNINGS)
163     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
164 endif()
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})
169 add_definitions(-DQT_STRICT_ITERATORS)
171 # Make sure that plugins not export all symbols, only that which are explicitly marked
172 include(GenerateExportHeader)
173 add_compiler_export_flags()
175 if(NOT WITH_QT5 AND CMAKE_VERSION VERSION_LESS 2.8.10)
176     set(SUPPORTS_TARGET_INCLUDES 0)
177     include_directories(
178         ${QT_MKSPECS_DIR}/default
179         ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/
180         ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4/io/
181         ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer
182         ${CMAKE_CURRENT_SOURCE_DIR}/tests
183         ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_LibMailboxSync)
184 else()
185     set(SUPPORTS_TARGET_INCLUDES 1)
186 endif()
188 set(CMAKE_AUTOMOC True)
190 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
192 if(WIN32) # Check if we are on Windows
193     # On win32, qt can statically link to zlib and export their symbols.
194     # We check if we can find the string " zlib " in the QT_CONFIG list in
195     # ${QT_MKSPECS_DIR}/qconfig.pri and include on success ${QT_QTCORE_LIBRARY}
196     # and ${QTDIR}/src/3rdparty/zlib as lib and include folder
197     if(QT_QTCORE_FOUND)
198         message(STATUS "We are on Windows with Qt. Checking if zlib is built into Qt")
200         if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
201             file(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents_ZLIB_CHECK)
202             string(REGEX MATCH "QT_CONFIG[^\n]+" QT_CONFIG_ZLIB_CHECK ${_qconfig_FILE_contents_ZLIB_CHECK})
204             set(ENV_QTDIR $ENV{QTDIR})
205             if(NOT DEFINED ENV_QTDIR)
206                 message(STATUS "QTDIR not specified in environment, will not use zlib")
207             elseif(QT_CONFIG_ZLIB_CHECK)
208                 if(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
209                     message(STATUS "Found zlib in QT_QCONFIG. zlib seems to be built into Qt")
210                     set(ZLIB_LIBRARY_RELEASE ${QT_QTCORE_LIBRARY_RELEASE})
211                     set(ZLIB_LIBRARY_DEBUG ${QT_QTCORE_LIBRARY_DEBUG})
212                     set(ZLIB_LIBRARY ${QT_QTCORE_LIBRARY})
214                     string(REGEX REPLACE "\\\\" "/" QTDIR ${ENV_QTDIR})
215                     set(ZLIB_INCLUDE_DIR "${QTDIR}/src/3rdparty/zlib")
217                     set(ZLIB_FOUND TRUE)
218                     set(ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
219                     mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR ZLIB_FOUND)
220                 else(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
221                     message(STATUS "Could not determine if Qt was built with zlib support.")
222                 endif(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
224             endif()
225         endif(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
226     endif(QT_QTCORE_FOUND)
227 endif()
229 if(NOT ZLIB_FOUND)
230     trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
231 endif()
233 if(WITH_ZLIB)
234     set(TROJITA_HAVE_ZLIB True)
235     message(STATUS "Support for COMPRESS=DEFLATE enabled")
236 else()
237     set(TROJITA_HAVE_ZLIB False)
238     message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
239 endif()
241 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
242     ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
244 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES DESCRIPTION "\n" WHAT ALL)
246 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
247 set(libCommon_SOURCES
248     ${path_Common}/Application.cpp
249     ${path_Common}/ConnectionId.cpp
250     ${path_Common}/DeleteAfter.cpp
251     ${path_Common}/FileLogger.cpp
252     ${path_Common}/MetaTypes.cpp
253     ${path_Common}/Paths.cpp
254     ${path_Common}/SettingsNames.cpp
257 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
258 set(libPlugins_SOURCES
259     ${path_Plugins}/AddressbookPlugin.cpp
260     ${path_Plugins}/PasswordPlugin.cpp
261     ${path_Plugins}/PluginJob.cpp
262     ${path_Plugins}/PluginManager.cpp
265 set(path_UiUtils ${CMAKE_CURRENT_SOURCE_DIR}/src/UiUtils)
266 set(libUiUtils_SOURCES
267     ${path_UiUtils}/Formatting.cpp
268     ${path_UiUtils}/PasswordWatcher.cpp
271 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
272 set(libComposer_SOURCES
273     ${path_Composer}/ComposerAttachments.cpp
274     ${path_Composer}/Mailto.cpp
275     ${path_Composer}/MessageComposer.cpp
276     ${path_Composer}/PlainTextFormatter.cpp
277     ${path_Composer}/Recipients.cpp
278     ${path_Composer}/ReplaceSignature.cpp
279     ${path_Composer}/SenderIdentitiesModel.cpp
280     ${path_Composer}/SubjectMangling.cpp
281     ${path_Composer}/Submission.cpp
284 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
285 set(libMSA_SOURCES
286     ${path_MSA}/AbstractMSA.cpp
287     ${path_MSA}/Account.cpp
288     ${path_MSA}/FakeMSA.cpp
289     ${path_MSA}/ImapSubmit.cpp
290     ${path_MSA}/SMTP.cpp
291     ${path_MSA}/Sendmail.cpp
294 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
295 set(libStreams_SOURCES
296     ${path_Streams}/DeletionWatcher.cpp
297     ${path_Streams}/FakeSocket.cpp
298     ${path_Streams}/IODeviceSocket.cpp
299     ${path_Streams}/Socket.cpp
300     ${path_Streams}/SocketFactory.cpp
303 if(WITH_ZLIB)
304     set(libStreams_SOURCES ${libStreams_SOURCES}
305         ${path_Streams}/3rdparty/rfc1951.cpp)
306     include_directories(${ZLIB_INCLUDE_DIR})
307 endif()
309 if(NOT WITH_QT5)
310     set(path_mimetypesqt4 ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4)
311     set(libMimetypesQt4_SOURCES
312         ${path_mimetypesqt4}/io/qstandardpaths.cpp
313         ${path_mimetypesqt4}/mimetypes/qmimedatabase.cpp
314         ${path_mimetypesqt4}/mimetypes/qmimeglobpattern.cpp
315         ${path_mimetypesqt4}/mimetypes/qmimemagicrule.cpp
316         ${path_mimetypesqt4}/mimetypes/qmimemagicrulematcher.cpp
317         ${path_mimetypesqt4}/mimetypes/qmimetype.cpp
318         ${path_mimetypesqt4}/mimetypes/qmimetypeparser.cpp
319         ${path_mimetypesqt4}/mimetypes/qmimeprovider.cpp
320     )
321     if(WIN32)
322         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
323             ${path_mimetypesqt4}/io/qstandardpaths_win.cpp)
324     elseif(APPLE)
325         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
326             ${path_mimetypesqt4}/io/qstandardpaths_mac.cpp)
327     elseif (OS2)
328         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
329             ${path_mimetypesqt4}/io/qstandardpaths_os2.cpp)
330     elseif (UNIX)
331         set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
332             ${path_mimetypesqt4}/io/qstandardpaths_unix.cpp)
333     else()
334         message(FATAL_ERROR "Unsupported platform -- mimetypes-Qt4 support only Unix, MacOSX, Windows and OS/2")
335     endif()
336 endif()
338 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
339 set(libDesktopGui_SOURCES
340     ${path_DesktopGui}/AttachmentView.cpp
341     ${path_DesktopGui}/AutoCompletion.cpp
342     ${path_DesktopGui}/CompleteMessageWidget.cpp
343     ${path_DesktopGui}/ComposeWidget.cpp
344     ${path_DesktopGui}/ComposerAttachmentsList.cpp
345     ${path_DesktopGui}/ComposerTextEdit.cpp
346     ${path_DesktopGui}/EmbeddedWebView.cpp
347     ${path_DesktopGui}/EnvelopeView.cpp
348     ${path_DesktopGui}/ExternalElementsWidget.cpp
349     ${path_DesktopGui}/FindBar.cpp
350     ${path_DesktopGui}/FlowLayout.cpp
351     ${path_DesktopGui}/FromAddressProxyModel.cpp
352     ${path_DesktopGui}/LineEdit.cpp
353     ${path_DesktopGui}/LoadablePartWidget.cpp
354     ${path_DesktopGui}/MailBoxTreeView.cpp
355     ${path_DesktopGui}/MessageListWidget.cpp
356     ${path_DesktopGui}/MessageSourceWidget.cpp
357     ${path_DesktopGui}/MessageView.cpp
358     ${path_DesktopGui}/MsgListView.cpp
359     ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
360     ${path_DesktopGui}/OverlayWidget.cpp
361     ${path_DesktopGui}/PartWidget.cpp
362     ${path_DesktopGui}/PartWidgetFactory.cpp
363     ${path_DesktopGui}/PasswordDialog.cpp
364     ${path_DesktopGui}/ProgressPopUp.cpp
365     ${path_DesktopGui}/ProtocolLoggerWidget.cpp
366     ${path_DesktopGui}/ReplaceCharValidator.cpp
367     ${path_DesktopGui}/SettingsDialog.cpp
368     ${path_DesktopGui}/SimplePartWidget.cpp
369     ${path_DesktopGui}/Spinner.cpp
370     ${path_DesktopGui}/TagListWidget.cpp
371     ${path_DesktopGui}/TagWidget.cpp
372     ${path_DesktopGui}/TaskProgressIndicator.cpp
373     ${path_DesktopGui}/UserAgentWebPage.cpp
374     ${path_DesktopGui}/Util.cpp
375     ${path_DesktopGui}/Window.cpp
376     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
377     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
378     ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
380 set(libDesktopGui_UI
381     ${path_DesktopGui}/AboutDialog.ui
382     ${path_DesktopGui}/ComposeWidget.ui
383     ${path_DesktopGui}/CreateMailboxDialog.ui
384     ${path_DesktopGui}/EditIdentity.ui
385     ${path_DesktopGui}/PasswordDialog.ui
386     ${path_DesktopGui}/ProgressPopUp.ui
387     ${path_DesktopGui}/SettingsCachePage.ui
388     ${path_DesktopGui}/SettingsGeneralPage.ui
389     ${path_DesktopGui}/SettingsImapPage.ui
390     ${path_DesktopGui}/SettingsOutgoingPage.ui
391     ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
393 set(libDesktopGui_RESOURCES
394     ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
395     ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
398 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
400 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
402 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
403 set(libImap_SOURCES
404     ${path_Imap}/ConnectionState.cpp
405     ${path_Imap}/Encoders.cpp
406     ${path_Imap}/Exceptions.cpp
407     ${path_Imap}/Parser/3rdparty/kcodecs.cpp
408     ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
410     ${path_Imap}/Parser/Command.cpp
411     ${path_Imap}/Parser/Data.cpp
412     ${path_Imap}/Parser/LowLevelParser.cpp
413     ${path_Imap}/Parser/MailAddress.cpp
414     ${path_Imap}/Parser/Message.cpp
415     ${path_Imap}/Parser/Parser.cpp
416     ${path_Imap}/Parser/Response.cpp
417     ${path_Imap}/Parser/Sequence.cpp
418     ${path_Imap}/Parser/ThreadingNode.cpp
420     ${path_Imap}/Network/FileDownloadManager.cpp
421     ${path_Imap}/Network/ForbiddenReply.cpp
422     ${path_Imap}/Network/MsgPartNetAccessManager.cpp
423     ${path_Imap}/Network/MsgPartNetworkReply.cpp
424     ${path_Imap}/Network/QQuickNetworkReplyWrapper.cpp
426     ${path_Imap}/Model/Cache.cpp
427     ${path_Imap}/Model/CombinedCache.cpp
428     ${path_Imap}/Model/DragAndDrop.cpp
429     ${path_Imap}/Model/DiskPartCache.cpp
430     ${path_Imap}/Model/DummyNetworkWatcher.cpp
431     ${path_Imap}/Model/FindInterestingPart.cpp
432     ${path_Imap}/Model/FlagsOperation.cpp
433     ${path_Imap}/Model/FullMessageCombiner.cpp
434     ${path_Imap}/Model/ImapAccess.cpp
435     ${path_Imap}/Model/MailboxFinder.cpp
436     ${path_Imap}/Model/MailboxMetadata.cpp
437     ${path_Imap}/Model/MailboxModel.cpp
438     ${path_Imap}/Model/MailboxTree.cpp
439     ${path_Imap}/Model/MemoryCache.cpp
440     ${path_Imap}/Model/Model.cpp
441     ${path_Imap}/Model/MsgListModel.cpp
442     ${path_Imap}/Model/NetworkWatcher.cpp
443     ${path_Imap}/Model/OneMessageModel.cpp
444     ${path_Imap}/Model/ParserState.cpp
445     ${path_Imap}/Model/PrettyMailboxModel.cpp
446     ${path_Imap}/Model/PrettyMsgListModel.cpp
447     ${path_Imap}/Model/SpecialFlagNames.cpp
448     ${path_Imap}/Model/SQLCache.cpp
449     ${path_Imap}/Model/SubtreeModel.cpp
450     ${path_Imap}/Model/SystemNetworkWatcher.cpp
451     ${path_Imap}/Model/TaskFactory.cpp
452     ${path_Imap}/Model/TaskPresentationModel.cpp
453     ${path_Imap}/Model/ThreadingMsgListModel.cpp
454     ${path_Imap}/Model/Utils.cpp
455     ${path_Imap}/Model/VisibleTasksModel.cpp
457     # The ModelTest is only needed when debugging manually
458     #${path_Imap}/Model/ModelTest/modeltest.cpp
459     # The ModelWatcher is another debugging aid
460     ${path_Imap}/Model/ModelWatcher.cpp
462     ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
464     ${path_Imap}/Tasks/AppendTask.cpp
465     ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
466     ${path_Imap}/Tasks/CreateMailboxTask.cpp
467     ${path_Imap}/Tasks/DeleteMailboxTask.cpp
468     ${path_Imap}/Tasks/EnableTask.cpp
469     ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
470     ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
471     ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
472     ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
473     ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
474     ${path_Imap}/Tasks/FetchMsgPartTask.cpp
475     ${path_Imap}/Tasks/GenUrlAuthTask.cpp
476     ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
477     ${path_Imap}/Tasks/IdTask.cpp
478     ${path_Imap}/Tasks/IdleLauncher.cpp
479     ${path_Imap}/Tasks/ImapTask.cpp
480     ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
481     ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
482     ${path_Imap}/Tasks/NoopTask.cpp
483     ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
484     ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
485     ${path_Imap}/Tasks/OfflineConnectionTask.cpp
486     ${path_Imap}/Tasks/OpenConnectionTask.cpp
487     ${path_Imap}/Tasks/SortTask.cpp
488     ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
489     ${path_Imap}/Tasks/ThreadTask.cpp
490     ${path_Imap}/Tasks/UidSubmitTask.cpp
491     ${path_Imap}/Tasks/UnSelectTask.cpp
492     ${path_Imap}/Tasks/UpdateFlagsTask.cpp
493     ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
496 if(WITH_RAGEL)
497     message(STATUS "Using Ragel for the RFC 5322 parser")
498     ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
499     set(libImap_SOURCES ${libImap_SOURCES}
500         ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
501 else()
502     message(STATUS "Using pregenerated RFC 5322 parser")
503     set(libImap_SOURCES ${libImap_SOURCES}
504         ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
505 endif()
507 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/AbookAddressbook)
508 set(libAbookAddressbook_SOURCES
509     ${path_AbookAddressbook}/AbookAddressbook.cpp
510     ${path_AbookAddressbook}/be-contacts.cpp
512 set(libAbookAddressbook_UI
513     ${path_AbookAddressbook}/be-contacts.ui
514     ${path_AbookAddressbook}/onecontact.ui
517 set(trojita_desktop_SOURCES
518     ${path_DesktopGui}/main.cpp
521 if(WIN32)
522     list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
523 endif()
525 set(be_contacts_SOURCES
526     ${CMAKE_CURRENT_SOURCE_DIR}/src/be.contacts/main.cpp
529 set(libQNAMWebView_SOURCES
530     ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/plugin.cpp
531     ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qdeclarativewebview.cpp
534 set(trojitaHarmattan_SOURCES
535     ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/main.cpp
536     ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer/qmlapplicationviewer.cpp
539 set(trojitaUbuntu_SOURCES
540         ${CMAKE_CURRENT_SOURCE_DIR}/src/Ubuntu/main.cpp
543 if(LinguistForTrojita_FOUND OR Qt5LinguistForTrojita_FOUND)
544     file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
545     if(WITH_QT5)
546         qt5_wrap_po(trojita_QM ${lang_PO})
547     else()
548         qt4_wrap_po(trojita_QM ${lang_PO})
549     endif()
550     set(language_summary "")
551     foreach(po ${lang_PO})
552         string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
553         list(APPEND language_summary ${lang})
554     endforeach()
555     list(SORT language_summary)
556     list(LENGTH language_summary num_languages)
557     if(num_languages)
558         message(STATUS "Available languages: ${language_summary}")
559         if(WITH_DESKTOP)
560             install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION share/trojita/locale REGEX "(x_test)|(.*\\.ts)" EXCLUDE)
561         endif()
562     else()
563         message(STATUS "No .po files found, will not install any languages")
564     endif()
565 else()
566     message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
567 endif()
569 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
570 if(WITH_NSIS)
571     set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
572     set(NSIS TRUE)
573 endif()
575 add_custom_target(version DEPENDS version_fake_file)
576 add_custom_command(OUTPUT version_fake_file ${version_files}
577     COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DNSIS=${NSIS} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TrojitaVersion.cmake)
578 set_source_files_properties(${version_files}
579     PROPERTIES GENERATED TRUE
580     HEADER_FILE_ONLY TRUE)
582 add_library(Common STATIC ${libCommon_SOURCES})
583 add_dependencies(Common version)
584 target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
586 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
587 add_dependencies(AppVersion version)
588 target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
590 if(WITH_SHARED_PLUGINS)
591     add_library(Plugins SHARED ${libPlugins_SOURCES})
592 else()
593     add_library(Plugins STATIC ${libPlugins_SOURCES})
594     set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
595 endif()
596 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
597 if(WITH_QT5)
598     qt5_use_modules(Plugins Core)
599 else()
600     target_link_libraries(Plugins ${QT_QTCORE_LIBRARY})
601 endif()
603 add_library(UiUtils STATIC ${libUiUtils_SOURCES})
604 target_link_libraries(UiUtils Plugins ${QT_QTCORE_LIBRARY})
606 add_library(Streams STATIC ${libStreams_SOURCES})
607 target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
608 if(WITH_ZLIB)
609     target_link_libraries(Streams ${ZLIB_LIBRARIES})
610 endif()
612 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
613 target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
615 add_library(MSA STATIC ${libMSA_SOURCES})
616 target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
618 add_library(Composer STATIC ${libComposer_SOURCES})
619 target_link_libraries(Composer Common MSA Streams qwwsmtpclient ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
620 if(NOT WITH_QT5)
621     target_link_libraries(Composer MimetypesQt4)
622 endif()
624 add_library(Imap STATIC ${libImap_SOURCES})
625 target_link_libraries(Imap Common Streams UiUtils ${QT_QTNETWORK_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
626 if(WITH_ZLIB)
627     target_link_libraries(Imap ${ZLIB_LIBRARIES})
628 endif()
630 if(NOT WITH_QT5)
631     add_library(MimetypesQt4 STATIC ${libMimetypesQt4_SOURCES})
632     if(SUPPORTS_TARGET_INCLUDES)
633         set_property(TARGET MimetypesQt4 APPEND PROPERTY INCLUDE_DIRECTORIES
634             ${QT_MKSPECS_DIR}/default ${path_mimetypesqt4}/io/)
635     endif()
636     target_link_libraries(MimetypesQt4 ${QT_QTCORE_LIBRARY})
637     if(APPLE)
638         find_library(CARBON_LIBRARY Carbon REQUIRED)
639         target_link_libraries(MimetypesQt4 ${CARBON_LIBRARY})
640     endif()
641 endif()
643 ## ClearText password plugin
644 if(WITH_CLEARTEXT_PLUGIN)
645     trojita_add_plugin(trojita_plugin_ClearTextPasswordPlugin WITH_CLEARTEXT_PLUGIN src/Plugins/ClearTextPassword/ClearTextPassword.cpp)
646 endif()
648 ## QtKeyChain plugin
649 if(WITH_QTKEYCHAIN_PLUGIN)
650     trojita_add_plugin(trojita_plugin_QtKeychainPasswordPlugin WITH_QTKEYCHAIN_PLUGIN src/Plugins/QtKeyChain/QtKeyChainPassword.cpp)
651     if(WITH_QT5)
652         qt5_use_modules(trojita_plugin_QtKeychainPasswordPlugin Core DBus)
653     else()
654         target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
655     endif()
656     target_link_libraries(trojita_plugin_QtKeychainPasswordPlugin ${QTKEYCHAIN_LIBRARIES})
657     if(SUPPORTS_TARGET_INCLUDES)
658         set_property(TARGET trojita_plugin_QtKeychainPasswordPlugin APPEND PROPERTY INCLUDE_DIRECTORIES ${QTKEYCHAIN_INCLUDE_DIRS})
659     else()
660         include_directories(${QTKEYCHAIN_INCLUDE_DIRS})
661     endif()
662 endif()
664 # Generate file static_plugins.h.in
665 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
666 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
667 foreach(PLUGIN ${STATIC_PLUGINS})
668     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
669 endforeach()
670 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
672 if(WITH_DESKTOP)
673     if(WITH_QT5)
674         qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
675         qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
676         qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
677     else()
678         qt4_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
679         qt4_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
680         qt4_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
681     endif()
683     add_library(AbookAddressbook STATIC ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
684     target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
686     add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
687     # The following is needed for the LineEdit widget within the .ui files.
688     # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
689     if(SUPPORTS_TARGET_INCLUDES)
690         set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
691     endif()
692     target_link_libraries(DesktopGui Common UiUtils Composer Imap MSA Plugins Streams qwwsmtpclient AbookAddressbook ${QT_QTWEBKIT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
694     # On Windows build a real Win32 GUI application without console window
695     # On other platforms WIN32 flag is ignored
696     add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
697     target_link_libraries(trojita AppVersion Common UiUtils DesktopGui ${STATIC_PLUGINS} ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
698     if(NOT WITH_QT5)
699         target_link_libraries(trojita MimetypesQt4)
700     endif()
701     if(WITH_ZLIB)
702         target_link_libraries(trojita ${ZLIB_LIBRARIES})
703     endif()
705     add_executable(be.contacts ${be_contacts_SOURCES})
706     target_link_libraries(be.contacts AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
707 elseif(WITH_HARMATTAN)
708     add_library(trojitaqnamwebviewplugin SHARED ${libQNAMWebView_SOURCES})
709     add_executable(trojita-tp ${trojitaHarmattan_SOURCES})
710     if(SUPPORTS_TARGET_INCLUDES)
711         set_property(TARGET trojita-tp APPEND PROPERTY INCLUDE_DIRECTORIES
712             ${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer)
713     endif()
714     target_link_libraries(trojita-tp AppVersion Imap MSA Streams qwwsmtpclient Common Composer MimetypesQt4
715         ${QT_QTSQL_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
716 endif()
718 #// add the Ubuntu Libs Here ALSO
719 if(WITH_UBUNTU)
720     add_executable(trojita-ubu ${trojitaUbuntu_SOURCES})
722     set_property(TARGET trojita-ubu APPEND PROPERTY INCLUDE_DIRECTORIES
723         ${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Ubuntu)
725     target_link_libraries(trojita-ubu AppVersion Imap MSA Streams qwwsmtpclient Common Composer Plugins )
726 endif()
728 if(WITH_QT5)
729     qt5_use_modules(AppVersion Core)
730     qt5_use_modules(Common Core Network)
731     qt5_use_modules(UiUtils Core Gui Network)
732     qt5_use_modules(Streams Network)
733     qt5_use_modules(qwwsmtpclient Network)
734     qt5_use_modules(MSA Network)
735     qt5_use_modules(Composer Gui Network)
736     qt5_use_modules(Imap Gui Network Sql)
737     if (WITH_DESKTOP)
738         qt5_use_modules(DesktopGui Network WebKitWidgets)
739         qt5_use_modules(AbookAddressbook Widgets)
740         qt5_use_modules(be.contacts Widgets)
741         qt5_use_modules(trojita Widgets Network)
742     elseif(WITH_UBUNTU)
743         qt5_use_modules(trojita-ubu Network Core Qml Quick)
744     endif()
745 endif()
748 if(WITH_SHARED_PLUGINS)
749     install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
750 endif()
752 include(SanitizedDesktopFile)
754 if(WITH_DESKTOP)
755     copy_desktop_file_without_cruft("${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.desktop" "${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop")
756     install(TARGETS trojita be.contacts RUNTIME DESTINATION bin)
757     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/trojita-DesktopGui.desktop DESTINATION share/applications/ RENAME trojita.desktop)
758     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.appdata.xml DESTINATION share/appdata/)
759     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION share/icons/hicolor/32x32/apps/)
760     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION share/icons/hicolor/scalable/apps/)
761 endif()
763 if(WITH_UBUNTU)
765     set(TROJITA_UBUNTU_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/Ubuntu)
766     set(AUTOPILOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/autopilot/trojita)
768     set(UBUNTU_QMLS
769         ${TROJITA_UBUNTU_PATH}/qml/trojita/AddressWidget.qml
770         ${TROJITA_UBUNTU_PATH}/qml/trojita/OneMessagePage.qml
771         ${TROJITA_UBUNTU_PATH}/qml/trojita/icon-m-settings-keychain.svg
772         ${TROJITA_UBUNTU_PATH}/qml/trojita/ImapSettings.qml
773         ${TROJITA_UBUNTU_PATH}/qml/trojita/PasswordInputSheet.qml
774         ${TROJITA_UBUNTU_PATH}/qml/trojita/MailboxListPage.qml
775         ${TROJITA_UBUNTU_PATH}/qml/trojita/PercentageSectionScroller.qml
776         ${TROJITA_UBUNTU_PATH}/qml/trojita/SslSheet.qml
777         ${TROJITA_UBUNTU_PATH}/qml/trojita/SettingsToolbar.qml
778         ${TROJITA_UBUNTU_PATH}/qml/trojita/SettingsTabs.qml
779         ${TROJITA_UBUNTU_PATH}/qml/trojita/SmtpSettings.qml
780         ${TROJITA_UBUNTU_PATH}/qml/trojita/main.qml
781         ${TROJITA_UBUNTU_PATH}/qml/trojita/MessageListPage.qml
782         ${TROJITA_UBUNTU_PATH}/qml/trojita/MessageListToolbar.qml
783         ${TROJITA_UBUNTU_PATH}/qml/trojita/InfoDialog.qml
784         ${TROJITA_UBUNTU_PATH}/qml/trojita/Utils.js
785         ${TROJITA_UBUNTU_PATH}/qml/trojita/contact.svg
786         ${TROJITA_UBUNTU_PATH}/qml/trojita/contact_grey.svg
787         ${TROJITA_UBUNTU_PATH}/qml/trojita/delete.svg
788         ${TROJITA_UBUNTU_PATH}/qml/trojita/email.svg
789         ${TROJITA_UBUNTU_PATH}/qml/trojita/favorite-selected.svg
790         ${TROJITA_UBUNTU_PATH}/qml/trojita/favorite-unselected.svg
791         ${TROJITA_UBUNTU_PATH}/qml/trojita/attach.svg
792         ${TROJITA_UBUNTU_PATH}/qml/trojita/back.svg
793         ${TROJITA_UBUNTU_PATH}/qml/trojita/key.svg
794         ${TROJITA_UBUNTU_PATH}/qml/trojita/settings.svg
795         ${TROJITA_UBUNTU_PATH}/qml/trojita/save.svg
796         ${TROJITA_UBUNTU_PATH}/qml/trojita/cancel.svg
797         ${TROJITA_UBUNTU_PATH}/qml/trojita/language-chooser.svg
798         ${TROJITA_UBUNTU_PATH}/qml/trojita/navigation-menu.svg
799     )
800     set(AUTOPILOT_FILES
801         ${AUTOPILOT_DIR}/__init__.py
802         ${AUTOPILOT_DIR}/emulators.py
803         ${AUTOPILOT_DIR}/tests/__init__.py
804         ${AUTOPILOT_DIR}/tests/test_trojita.py
805     )
807     #make QML visable to QtCreator
808     add_custom_target(
809         components_QmlFiles
810         ALL SOURCES ${UBUNTU_QMLS}
811     )
812     # make autopilot tests visible in QtCreator
813     add_custom_target(
814         autopilot_Files
815         ALL SOURCES ${AUTOPILOT_FILES}
816     )
818     add_custom_target(ubuntu_QmlComponents ALL
819         COMMAND ${CMAKE_COMMAND} -E copy_directory
820             ${TROJITA_UBUNTU_PATH}/qml/trojita
821             ${CMAKE_CURRENT_BINARY_DIR}/qml/trojita
822         COMMENT "Copying QML files to build tree"
823     )
825     install(
826         DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qml
827         DESTINATION share/trojita-ubu
828     )
830     install(
831         TARGETS trojita-ubu
832         RUNTIME DESTINATION bin
833     )
834     copy_desktop_file_without_cruft("${TROJITA_UBUNTU_PATH}/trojita-ubu.desktop" "${CMAKE_CURRENT_BINARY_DIR}/trojita-ubu.desktop")
835     install(
836         FILES ${CMAKE_CURRENT_BINARY_DIR}/trojita-ubu.desktop
837         DESTINATION share/applications
838     )
840     install(
841         FILES ${TROJITA_UBUNTU_PATH}/trojita-ubu.png
842         DESTINATION share/icons/hicolor/64x64/apps
843     )
845     execute_process(COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
846         OUTPUT_VARIABLE PYTHON_PACKAGE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
847     )
849     install(DIRECTORY ${AUTOPILOT_DIR}
850         DESTINATION ${PYTHON_PACKAGE_DIR}
851     )
852 endif()
854 if(WITH_HARMATTAN)
855     set(trojita_harmattan_path ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan)
856     install(TARGETS trojita-tp RUNTIME DESTINATION bin)
857     install(TARGETS trojitaqnamwebviewplugin LIBRARY DESTINATION bin/net/flaska/QNAMWebView)
858     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qmldir DESTINATION bin/net/flaska/QNAMWebView)
859     install(DIRECTORY ${trojita_harmattan_path}/qml DESTINATION ${CMAKE_INSTALL_PREFIX})
860     install(FILES ${trojita_harmattan_path}/trojita-tp.desktop DESTINATION share/applications)
861     install(FILES ${trojita_harmattan_path}/trojita-tp80.png DESTINATION share/icons/hicolor/80x80/apps)
862 endif()
864 if(WITH_NSIS)
865     if(CMAKE_SIZEOF_VOID_P STREQUAL 4)
866         set(MAKENSIS_OUTPUT Trojita-installer.exe)
867     else()
868         set(MAKENSIS_FLAGS -DX86_64 ${MAKENSIS_FLAGS})
869         set(MAKENSIS_OUTPUT Trojita-installer-x86_64.exe)
870     endif()
872     if(NOT CMAKE_VERBOSE_MAKEFILE)
873         set(MAKENSIS_FLAGS -V2 -DQUIET ${MAKENSIS_FLAGS})
874     endif()
876     set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -NOCD)
878     add_custom_command(OUTPUT ${MAKENSIS_OUTPUT}
879         COMMAND ${MAKENSIS}
880         ARGS ${MAKENSIS_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi
881         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi ${CMAKE_CURRENT_BINARY_DIR}/trojita.exe version)
882     add_custom_target(installer ALL DEPENDS ${MAKENSIS_OUTPUT})
883 endif()
886 if(WITH_TESTS)
887     set(test_LibMailboxSync_SOURCES
888         tests/Utils/ModelEvents.cpp
889         tests/Utils/LibMailboxSync.cpp
890     )
891     add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
892     if(WITH_QT5)
893         qt5_use_modules(test_LibMailboxSync Test Network)
894     endif()
895     if(SUPPORTS_TARGET_INCLUDES)
896         set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
897             ${CMAKE_CURRENT_SOURCE_DIR}/tests
898             ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
899     endif()
900     target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
902     macro(trojita_test dir fname)
903         set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
904         add_executable(test_${fname} ${test_${fname}_SOURCES})
905         target_link_libraries(test_${fname} Imap MSA Streams Common Composer test_LibMailboxSync)
906         if(WITH_QT5)
907             qt5_use_modules(test_${fname} Network Sql Test Widgets)
908         else()
909             target_link_libraries(test_${fname} ${QT_QTSQL_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
910         endif()
911         if(WITH_ZLIB)
912             target_link_libraries(test_${fname} ${ZLIB_LIBRARIES})
913         endif()
914         if(SUPPORTS_TARGET_INCLUDES)
915             set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
916         endif()
917         if(NOT CMAKE_CROSSCOMPILING)
918             add_test(test_${fname} test_${fname})
919         endif()
920     endmacro()
922     enable_testing()
923     trojita_test(Composer Composer_Submission)
924     trojita_test(Composer Composer_responses)
925     trojita_test(Composer Html_formatting)
926     if(WITH_QT5)
927         qt5_use_modules(test_Composer_responses WebKitWidgets)
928         qt5_use_modules(test_Html_formatting WebKitWidgets)
929     else()
930         target_link_libraries(test_Html_formatting ${QT_QTWEBKIT_LIBRARY})
931     endif()
932     trojita_test(Imap Imap_DisappearingMailboxes)
933     trojita_test(Imap Imap_Idle)
934     trojita_test(Imap Imap_LowLevelParser)
935     trojita_test(Imap Imap_Message)
936     trojita_test(Imap Imap_Model)
937     trojita_test(Imap Imap_Parser_parse)
938     trojita_test(Imap Imap_Responses)
939     trojita_test(Imap Imap_SelectedMailboxUpdates)
940     trojita_test(Imap Imap_Tasks_CreateMailbox)
941     trojita_test(Imap Imap_Tasks_DeleteMailbox)
942     trojita_test(Imap Imap_Tasks_ListChildMailboxes)
943     trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
944     trojita_test(Imap Imap_Tasks_OpenConnection)
945     trojita_test(Imap Imap_Threading)
946     trojita_test(Imap Imap_BodyParts)
947     trojita_test(Imap Imap_Offline)
948     trojita_test(Imap Imap_CopyAndFlagOperations)
949     trojita_test(Misc Rfc5322)
950     trojita_test(Misc RingBuffer)
951     trojita_test(Misc SenderIdentitiesModel)
952     trojita_test(Misc SqlCache)
953     trojita_test(Misc algorithms)
954     trojita_test(Misc rfccodecs)
955 endif()
957 if(WIN32) # Check if we are on Windows
958     if(MSVC10) # Check if we are using the Visual Studio compiler 2010
959         # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
960         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
961     elseif(MINGW)
962     else()
963         message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
964         message(WARNING "Please let us know how well it works.")
965     endif()
966 endif()
968 # FIXME: fix build warnings