2 # The Qt5's qt5_use_modules is only available on 2.8.9 or later -- sweet, isn't it?
3 cmake_minimum_required(VERSION 2.8.9)
5 cmake_minimum_required(VERSION 2.8.7)
8 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
10 # POSITION_INDEPENDENT_CODE is only available on cmake 2.8.9 or later
11 # Add needed flags for supported compilers which simulate POSITION_INDEPENDENT_CODE property
12 if(CMAKE_VERSION VERSION_LESS "2.8.9")
13 if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
14 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
16 message(FATAL_ERROR "Needs GNU or Clang C++ compiler or CMake 2.8.9 (or later)")
19 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
22 include(FindCXXFeatures)
23 if(NOT CXXFeatures_auto_FOUND)
24 message(SEND_ERROR "Your compiler doesn't support C++11's auto")
26 if(NOT CXXFeatures_static_assert_FOUND)
27 message(SEND_ERROR "Your compiler doesn't support C++11's static_assert")
29 if(NOT CXXFeatures_alignof_FOUND)
30 if(NOT CMAKE_COMPILER_IS_GNUCXX AND NOT MSVC)
31 message(SEND_ERROR "Your compiler doesn't support C++11's alignof and it also isn't gcc or MSVC. Either would work.")
34 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
36 include(TrojitaOption)
38 trojita_option(WITH_DESKTOP "Build desktop version" ON)
39 trojita_option(WITH_HARMATTAN "Build MeeGo Harmattan version" OFF "NOT WITH_DESKTOP")
40 trojita_option(WITH_QT5 "Build with Qt5 library" OFF)
41 trojita_option(WITH_RAGEL "Build with Ragel library" AUTO)
42 trojita_option(WITH_ZLIB "Build with zlib library" AUTO)
43 trojita_option(WITH_SHARED_PLUGINS "Enable shared dynamic plugins" ON)
44 trojita_option(WITH_TESTS "Build tests" ON "NOT WITH_HARMATTAN")
45 trojita_option(DEV_FATAL_WARNINGS "Turn build warnings into errors (developers only)" OFF)
48 trojita_option(WITH_NSIS "Build Windows NSIS installer" AUTO)
52 message(STATUS "Building the Qt5 version")
53 find_package(Qt5Core 5.2 REQUIRED)
54 find_package(Qt5Gui REQUIRED)
55 find_package(Qt5Network REQUIRED)
56 find_package(Qt5Sql REQUIRED)
57 find_package(Qt5WebKitWidgets REQUIRED)
58 find_package(Qt5Widgets REQUIRED)
59 find_package(Qt5LinguistTools)
61 find_package(Qt5Test REQUIRED)
63 if(Qt5LinguistTools_FOUND)
64 find_package(Qt5LinguistForTrojita)
67 message(STATUS "Building the Qt4 version")
68 set(QT_USE_QTNETWORK 1)
70 set(QT_USE_QTWEBKIT 1)
75 set(QT_USE_QTDECLARATIVE 1)
77 trojita_find_package(Qt4 4.6 "http://qt-project.org" "Qt4" "Needed for building" REQUIRED)
78 include(${QT_USE_FILE})
79 trojita_check_qt4_module(QTCORE REQUIRED)
80 trojita_check_qt4_module(QTGUI REQUIRED)
81 trojita_check_qt4_module(QTNETWORK REQUIRED)
82 trojita_check_qt4_module(QTSQL REQUIRED)
83 trojita_check_qt4_module(QTWEBKIT REQUIRED)
84 trojita_check_qt4_module(QTTEST WITH_TESTS)
85 trojita_check_qt4_module(QTDECLARATIVE WITH_HARMATTAN)
86 trojita_find_package(LinguistForTrojita "" "" "" "")
87 if(NOT QT_QCONFIG MATCHES "openssl" OR QT_QCONFIG MATCHES "no-openssl")
88 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")
92 trojita_find_package(Git "" "" "" "")
95 trojita_find_package(MakeNSIS "" "http://nsis.sourceforge.net" "Nullsoft Scriptable Install System" "Needed for building Windows installer" WITH_NSIS)
98 # Add support for Mingw RC compiler
101 include(CMakeDetermineRCCompiler)
104 set(CMAKE_RC_COMPILER_INIT windres)
105 set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
109 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
110 set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}")
112 mark_as_advanced(CMAKE_INSTALL_LIBDIR)
114 if(NOT CMAKE_INSTALL_PLUGIN_DIR)
115 set(CMAKE_INSTALL_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/trojita")
117 mark_as_advanced(CMAKE_INSTALL_PLUGIN_DIR)
120 set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGIN_DIR}")
122 mark_as_advanced(PLUGIN_DIR)
124 if(NOT WIN32 AND NOT MSVC)
125 # Check if we are NOT on Windows and don't use MSVC since -g is not supported by VC
126 # and Wall makes the build very noisy.
127 # At first, enable optimizations. In my testing, these do *not* make debugging any harder than no optimization and
128 # they (of course) optimize away stuff like QByteArray::operator[] etc.
129 # We put the user's CXXFLAGS *after* that so that they take priority.
130 set(CMAKE_CXX_FLAGS "-O2 -g ${CMAKE_CXX_FLAGS}")
131 # Now enable build warnings; these are useful tools (and Trojita should be warning-free anyway). We do not set
132 # -Werror for sanity reasons, though (one cannot know what warnings a future compiler might bring along).
133 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wsign-compare")
134 endif(NOT WIN32 AND NOT MSVC)
135 if(DEV_FATAL_WARNINGS)
136 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
139 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
140 # The following is required so that the moc_*.cpp and ui_*.h are found
141 include_directories(${CMAKE_CURRENT_BINARY_DIR})
142 add_definitions(-DQT_STRICT_ITERATORS)
144 # Make sure that plugins not export all symbols, only that which are explicitly marked
145 include(GenerateExportHeader)
146 add_compiler_export_flags()
148 if(NOT WITH_QT5 AND CMAKE_VERSION VERSION_LESS 2.8.10)
149 set(SUPPORTS_TARGET_INCLUDES 0)
151 ${QT_MKSPECS_DIR}/default
152 ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/
153 ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4/io/
154 ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer
155 ${CMAKE_CURRENT_SOURCE_DIR}/tests
156 ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_LibMailboxSync)
158 set(SUPPORTS_TARGET_INCLUDES 1)
161 set(CMAKE_AUTOMOC True)
163 trojita_find_package(RagelForTrojita "" "" "" "" WITH_RAGEL)
165 if(WIN32) # Check if we are on Windows
166 # On win32, qt can statically link to zlib and export their symbols.
167 # We check if we can find the string " zlib " in the QT_CONFIG list in
168 # ${QT_MKSPECS_DIR}/qconfig.pri and include on success ${QT_QTCORE_LIBRARY}
169 # and ${QTDIR}/src/3rdparty/zlib as lib and include folder
171 message(STATUS "We are on Windows with Qt. Checking if zlib is built into Qt")
173 if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
174 file(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents_ZLIB_CHECK)
175 string(REGEX MATCH "QT_CONFIG[^\n]+" QT_CONFIG_ZLIB_CHECK ${_qconfig_FILE_contents_ZLIB_CHECK})
177 set(ENV_QTDIR $ENV{QTDIR})
178 if(NOT DEFINED ENV_QTDIR)
179 message(STATUS "QTDIR not specified in environment, will not use zlib")
180 elseif(QT_CONFIG_ZLIB_CHECK)
181 if(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
182 message(STATUS "Found zlib in QT_QCONFIG. zlib seems to be built into Qt")
183 set(ZLIB_LIBRARY_RELEASE ${QT_QTCORE_LIBRARY_RELEASE})
184 set(ZLIB_LIBRARY_DEBUG ${QT_QTCORE_LIBRARY_DEBUG})
185 set(ZLIB_LIBRARY ${QT_QTCORE_LIBRARY})
187 string(REGEX REPLACE "\\\\" "/" QTDIR ${ENV_QTDIR})
188 set(ZLIB_INCLUDE_DIR "${QTDIR}/src/3rdparty/zlib")
191 set(ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
192 mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR ZLIB_FOUND)
193 else(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
194 message(STATUS "Could not determine if Qt was built with zlib support.")
195 endif(QT_CONFIG_ZLIB_CHECK MATCHES " zlib ")
198 endif(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
199 endif(QT_QTCORE_FOUND)
203 trojita_find_package(ZLIB "" "" "" "" WITH_ZLIB)
207 set(TROJITA_HAVE_ZLIB True)
208 message(STATUS "Support for COMPRESS=DEFLATE enabled")
210 set(TROJITA_HAVE_ZLIB False)
211 message(STATUS "Disabling COMPRESS=DEFLATE, zlib is not available")
214 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/configure.cmake.in
215 ${CMAKE_CURRENT_BINARY_DIR}/configure.cmake.h)
217 feature_summary(FATAL_ON_MISSING_REQUIRED_PACKAGES DESCRIPTION "\n" WHAT ALL)
219 set(path_Common ${CMAKE_CURRENT_SOURCE_DIR}/src/Common)
220 set(libCommon_SOURCES
221 ${path_Common}/Application.cpp
222 ${path_Common}/ConnectionId.cpp
223 ${path_Common}/DeleteAfter.cpp
224 ${path_Common}/FileLogger.cpp
225 ${path_Common}/MetaTypes.cpp
226 ${path_Common}/Paths.cpp
227 ${path_Common}/SettingsNames.cpp
230 set(path_Plugins ${CMAKE_CURRENT_SOURCE_DIR}/src/Plugins)
231 set(libPlugins_SOURCES
232 ${path_Plugins}/AddressbookPlugin.cpp
233 ${path_Plugins}/PasswordPlugin.cpp
234 ${path_Plugins}/PluginJob.cpp
235 ${path_Plugins}/PluginManager.cpp
238 set(path_Composer ${CMAKE_CURRENT_SOURCE_DIR}/src/Composer)
239 set(libComposer_SOURCES
240 ${path_Composer}/ComposerAttachments.cpp
241 ${path_Composer}/Mailto.cpp
242 ${path_Composer}/MessageComposer.cpp
243 ${path_Composer}/PlainTextFormatter.cpp
244 ${path_Composer}/Recipients.cpp
245 ${path_Composer}/ReplaceSignature.cpp
246 ${path_Composer}/SenderIdentitiesModel.cpp
247 ${path_Composer}/SubjectMangling.cpp
248 ${path_Composer}/Submission.cpp
251 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
253 ${path_MSA}/AbstractMSA.cpp
254 ${path_MSA}/FakeMSA.cpp
255 ${path_MSA}/ImapSubmit.cpp
257 ${path_MSA}/Sendmail.cpp
260 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
261 set(libStreams_SOURCES
262 ${path_Streams}/DeletionWatcher.cpp
263 ${path_Streams}/FakeSocket.cpp
264 ${path_Streams}/IODeviceSocket.cpp
265 ${path_Streams}/Socket.cpp
266 ${path_Streams}/SocketFactory.cpp
270 set(libStreams_SOURCES ${libStreams_SOURCES}
271 ${path_Streams}/3rdparty/rfc1951.cpp)
272 include_directories(${ZLIB_INCLUDE_DIR})
276 set(path_mimetypesqt4 ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4)
277 set(libMimetypesQt4_SOURCES
278 ${path_mimetypesqt4}/io/qstandardpaths.cpp
279 ${path_mimetypesqt4}/mimetypes/qmimedatabase.cpp
280 ${path_mimetypesqt4}/mimetypes/qmimeglobpattern.cpp
281 ${path_mimetypesqt4}/mimetypes/qmimemagicrule.cpp
282 ${path_mimetypesqt4}/mimetypes/qmimemagicrulematcher.cpp
283 ${path_mimetypesqt4}/mimetypes/qmimetype.cpp
284 ${path_mimetypesqt4}/mimetypes/qmimetypeparser.cpp
285 ${path_mimetypesqt4}/mimetypes/qmimeprovider.cpp
288 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
289 ${path_mimetypesqt4}/io/qstandardpaths_win.cpp)
291 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
292 ${path_mimetypesqt4}/io/qstandardpaths_mac.cpp)
294 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
295 ${path_mimetypesqt4}/io/qstandardpaths_os2.cpp)
297 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
298 ${path_mimetypesqt4}/io/qstandardpaths_unix.cpp)
300 message(FATAL_ERROR "Unsupported platform -- mimetypes-Qt4 support only Unix, MacOSX, Windows and OS/2")
304 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
305 set(libDesktopGui_SOURCES
306 ${path_DesktopGui}/AttachmentView.cpp
307 ${path_DesktopGui}/AutoCompletion.cpp
308 ${path_DesktopGui}/CompleteMessageWidget.cpp
309 ${path_DesktopGui}/ComposeWidget.cpp
310 ${path_DesktopGui}/ComposerAttachmentsList.cpp
311 ${path_DesktopGui}/ComposerTextEdit.cpp
312 ${path_DesktopGui}/EmbeddedWebView.cpp
313 ${path_DesktopGui}/EnvelopeView.cpp
314 ${path_DesktopGui}/ExternalElementsWidget.cpp
315 ${path_DesktopGui}/FindBar.cpp
316 ${path_DesktopGui}/FlowLayout.cpp
317 ${path_DesktopGui}/FromAddressProxyModel.cpp
318 ${path_DesktopGui}/LineEdit.cpp
319 ${path_DesktopGui}/LoadablePartWidget.cpp
320 ${path_DesktopGui}/MailBoxTreeView.cpp
321 ${path_DesktopGui}/MessageListWidget.cpp
322 ${path_DesktopGui}/MessageSourceWidget.cpp
323 ${path_DesktopGui}/MessageView.cpp
324 ${path_DesktopGui}/MsgListView.cpp
325 ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
326 ${path_DesktopGui}/OverlayWidget.cpp
327 ${path_DesktopGui}/PartWidget.cpp
328 ${path_DesktopGui}/PartWidgetFactory.cpp
329 ${path_DesktopGui}/PasswordDialog.cpp
330 ${path_DesktopGui}/ProgressPopUp.cpp
331 ${path_DesktopGui}/ProtocolLoggerWidget.cpp
332 ${path_DesktopGui}/ReplaceCharValidator.cpp
333 ${path_DesktopGui}/SettingsDialog.cpp
334 ${path_DesktopGui}/SimplePartWidget.cpp
335 ${path_DesktopGui}/Spinner.cpp
336 ${path_DesktopGui}/TagListWidget.cpp
337 ${path_DesktopGui}/TagWidget.cpp
338 ${path_DesktopGui}/TaskProgressIndicator.cpp
339 ${path_DesktopGui}/UserAgentWebPage.cpp
340 ${path_DesktopGui}/Util.cpp
341 ${path_DesktopGui}/Window.cpp
342 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
343 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
344 ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
347 ${path_DesktopGui}/AboutDialog.ui
348 ${path_DesktopGui}/ComposeWidget.ui
349 ${path_DesktopGui}/CreateMailboxDialog.ui
350 ${path_DesktopGui}/EditIdentity.ui
351 ${path_DesktopGui}/PasswordDialog.ui
352 ${path_DesktopGui}/ProgressPopUp.ui
353 ${path_DesktopGui}/SettingsCachePage.ui
354 ${path_DesktopGui}/SettingsGeneralPage.ui
355 ${path_DesktopGui}/SettingsImapPage.ui
356 ${path_DesktopGui}/SettingsOutgoingPage.ui
357 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
359 set(libDesktopGui_RESOURCES
360 ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
361 ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
364 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
366 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
368 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
370 ${path_Imap}/ConnectionState.cpp
371 ${path_Imap}/Encoders.cpp
372 ${path_Imap}/Exceptions.cpp
373 ${path_Imap}/Parser/3rdparty/kcodecs.cpp
374 ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
376 ${path_Imap}/Parser/Command.cpp
377 ${path_Imap}/Parser/Data.cpp
378 ${path_Imap}/Parser/LowLevelParser.cpp
379 ${path_Imap}/Parser/MailAddress.cpp
380 ${path_Imap}/Parser/Message.cpp
381 ${path_Imap}/Parser/Parser.cpp
382 ${path_Imap}/Parser/Response.cpp
383 ${path_Imap}/Parser/Sequence.cpp
384 ${path_Imap}/Parser/ThreadingNode.cpp
386 ${path_Imap}/Network/FileDownloadManager.cpp
387 ${path_Imap}/Network/ForbiddenReply.cpp
388 ${path_Imap}/Network/MsgPartNetAccessManager.cpp
389 ${path_Imap}/Network/MsgPartNetworkReply.cpp
391 ${path_Imap}/Model/Cache.cpp
392 ${path_Imap}/Model/CombinedCache.cpp
393 ${path_Imap}/Model/DragAndDrop.cpp
394 ${path_Imap}/Model/DiskPartCache.cpp
395 ${path_Imap}/Model/FindInterestingPart.cpp
396 ${path_Imap}/Model/FlagsOperation.cpp
397 ${path_Imap}/Model/FullMessageCombiner.cpp
398 ${path_Imap}/Model/ImapAccess.cpp
399 ${path_Imap}/Model/MailboxFinder.cpp
400 ${path_Imap}/Model/MailboxMetadata.cpp
401 ${path_Imap}/Model/MailboxModel.cpp
402 ${path_Imap}/Model/MailboxTree.cpp
403 ${path_Imap}/Model/MemoryCache.cpp
404 ${path_Imap}/Model/Model.cpp
405 ${path_Imap}/Model/MsgListModel.cpp
406 ${path_Imap}/Model/NetworkWatcher.cpp
407 ${path_Imap}/Model/OneMessageModel.cpp
408 ${path_Imap}/Model/ParserState.cpp
409 ${path_Imap}/Model/PrettyMailboxModel.cpp
410 ${path_Imap}/Model/PrettyMsgListModel.cpp
411 ${path_Imap}/Model/SpecialFlagNames.cpp
412 ${path_Imap}/Model/SQLCache.cpp
413 ${path_Imap}/Model/SubtreeModel.cpp
414 ${path_Imap}/Model/TaskFactory.cpp
415 ${path_Imap}/Model/TaskPresentationModel.cpp
416 ${path_Imap}/Model/ThreadingMsgListModel.cpp
417 ${path_Imap}/Model/Utils.cpp
418 ${path_Imap}/Model/VisibleTasksModel.cpp
420 # The ModelTest is only needed when debugging manually
421 #${path_Imap}/Model/ModelTest/modeltest.cpp
422 # The ModelWatcher is another debugging aid
423 ${path_Imap}/Model/ModelWatcher.cpp
425 ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
427 ${path_Imap}/Tasks/AppendTask.cpp
428 ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
429 ${path_Imap}/Tasks/CreateMailboxTask.cpp
430 ${path_Imap}/Tasks/DeleteMailboxTask.cpp
431 ${path_Imap}/Tasks/EnableTask.cpp
432 ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
433 ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
434 ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
435 ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
436 ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
437 ${path_Imap}/Tasks/FetchMsgPartTask.cpp
438 ${path_Imap}/Tasks/GenUrlAuthTask.cpp
439 ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
440 ${path_Imap}/Tasks/IdTask.cpp
441 ${path_Imap}/Tasks/IdleLauncher.cpp
442 ${path_Imap}/Tasks/ImapTask.cpp
443 ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
444 ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
445 ${path_Imap}/Tasks/NoopTask.cpp
446 ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
447 ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
448 ${path_Imap}/Tasks/OfflineConnectionTask.cpp
449 ${path_Imap}/Tasks/OpenConnectionTask.cpp
450 ${path_Imap}/Tasks/SortTask.cpp
451 ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
452 ${path_Imap}/Tasks/ThreadTask.cpp
453 ${path_Imap}/Tasks/UidSubmitTask.cpp
454 ${path_Imap}/Tasks/UnSelectTask.cpp
455 ${path_Imap}/Tasks/UpdateFlagsTask.cpp
456 ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
460 message(STATUS "Using Ragel for the RFC 5322 parser")
461 ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
462 set(libImap_SOURCES ${libImap_SOURCES}
463 ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
465 message(STATUS "Using pregenerated RFC 5322 parser")
466 set(libImap_SOURCES ${libImap_SOURCES}
467 ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
470 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/AbookAddressbook)
471 set(libAbookAddressbook_SOURCES
472 ${path_AbookAddressbook}/AbookAddressbook.cpp
473 ${path_AbookAddressbook}/be-contacts.cpp
475 set(libAbookAddressbook_UI
476 ${path_AbookAddressbook}/be-contacts.ui
477 ${path_AbookAddressbook}/onecontact.ui
480 set(trojita_desktop_SOURCES
481 ${path_DesktopGui}/main.cpp
485 list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
488 set(be_contacts_SOURCES
489 ${CMAKE_CURRENT_SOURCE_DIR}/src/be.contacts/main.cpp
492 set(libQNAMWebView_SOURCES
493 ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/plugin.cpp
494 ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qdeclarativewebview.cpp
497 set(trojitaHarmattan_SOURCES
498 ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/main.cpp
499 ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer/qmlapplicationviewer.cpp
502 if(LinguistForTrojita_FOUND OR Qt5LinguistForTrojita_FOUND)
503 file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
505 qt5_wrap_po(trojita_QM ${lang_PO})
507 qt4_wrap_po(trojita_QM ${lang_PO})
509 set(language_summary "")
510 foreach(po ${lang_PO})
511 string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
512 list(APPEND language_summary ${lang})
514 list(SORT language_summary)
515 list(LENGTH language_summary num_languages)
517 message(STATUS "Available languages: ${language_summary}")
519 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION share/trojita/locale FILES_MATCHING PATTERN *.qm)
522 message(STATUS "No .po files found, will not install any languages")
525 message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
528 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
530 set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
534 add_custom_target(version DEPENDS version_fake_file)
535 add_custom_command(OUTPUT version_fake_file ${version_files}
536 COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DNSIS=${NSIS} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TrojitaVersion.cmake)
537 set_source_files_properties(${version_files}
538 PROPERTIES GENERATED TRUE
539 HEADER_FILE_ONLY TRUE)
541 add_library(Common STATIC ${libCommon_SOURCES})
542 add_dependencies(Common version)
543 target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
545 add_library(AppVersion STATIC ${libAppVersion_SOURCES})
546 add_dependencies(AppVersion version)
547 target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
549 if(WITH_SHARED_PLUGINS)
550 add_library(Plugins SHARED ${libPlugins_SOURCES})
552 add_library(Plugins STATIC ${libPlugins_SOURCES})
553 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
555 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
557 qt5_use_modules(Plugins Core)
559 target_link_libraries(Plugins ${QT_QTCORE_LIBRARY})
562 add_library(Streams STATIC ${libStreams_SOURCES})
563 target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
565 target_link_libraries(Streams ${ZLIB_LIBRARIES})
568 add_library(qwwsmtpclient STATIC ${libqwwsmtpclient_SOURCES})
569 target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
571 add_library(MSA STATIC ${libMSA_SOURCES})
572 target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
574 add_library(Composer STATIC ${libComposer_SOURCES})
575 target_link_libraries(Composer Common MSA Streams qwwsmtpclient ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
577 target_link_libraries(Composer MimetypesQt4)
580 add_library(Imap STATIC ${libImap_SOURCES})
581 target_link_libraries(Imap Common Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
583 target_link_libraries(Imap ${ZLIB_LIBRARIES})
587 add_library(MimetypesQt4 STATIC ${libMimetypesQt4_SOURCES})
588 if(SUPPORTS_TARGET_INCLUDES)
589 set_property(TARGET MimetypesQt4 APPEND PROPERTY INCLUDE_DIRECTORIES
590 ${QT_MKSPECS_DIR}/default ${path_mimetypesqt4}/io/)
592 target_link_libraries(MimetypesQt4 ${QT_QTCORE_LIBRARY})
595 # Generate file static_plugins.h.in
596 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
597 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
598 foreach(PLUGIN ${STATIC_PLUGINS})
599 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
601 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
605 qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
606 qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
607 qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
609 qt4_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
610 qt4_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
611 qt4_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
614 add_library(AbookAddressbook STATIC ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
615 target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
617 add_library(DesktopGui STATIC ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
618 # The following is needed for the LineEdit widget within the .ui files.
619 # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
620 if(SUPPORTS_TARGET_INCLUDES)
621 set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
623 target_link_libraries(DesktopGui Common Composer Imap MSA Plugins Streams qwwsmtpclient AbookAddressbook ${QT_QTWEBKIT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
625 # On Windows build a real Win32 GUI application without console window
626 # On other platforms WIN32 flag is ignored
627 add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
628 target_link_libraries(trojita AppVersion Common DesktopGui ${STATIC_PLUGINS} ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
630 target_link_libraries(trojita MimetypesQt4)
633 target_link_libraries(trojita ${ZLIB_LIBRARIES})
636 add_executable(be.contacts ${be_contacts_SOURCES})
637 target_link_libraries(be.contacts AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
638 elseif(WITH_HARMATTAN)
639 add_library(trojitaqnamwebviewplugin SHARED ${libQNAMWebView_SOURCES})
640 add_executable(trojita-tp ${trojitaHarmattan_SOURCES})
641 if(SUPPORTS_TARGET_INCLUDES)
642 set_property(TARGET trojita-tp APPEND PROPERTY INCLUDE_DIRECTORIES
643 ${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer)
645 target_link_libraries(trojita-tp AppVersion Imap MSA Streams qwwsmtpclient Common Composer MimetypesQt4
646 ${QT_QTSQL_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
650 qt5_use_modules(AppVersion Core)
651 qt5_use_modules(Common Core Network)
652 qt5_use_modules(Streams Network)
653 qt5_use_modules(qwwsmtpclient Network)
654 qt5_use_modules(MSA Network)
655 qt5_use_modules(Composer Gui Network)
656 qt5_use_modules(Imap Gui Network Sql)
657 qt5_use_modules(DesktopGui Network WebKitWidgets)
658 qt5_use_modules(AbookAddressbook Widgets)
659 qt5_use_modules(be.contacts Widgets)
660 qt5_use_modules(trojita Widgets Network)
663 if(WITH_SHARED_PLUGINS)
664 install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
668 install(TARGETS trojita be.contacts RUNTIME DESTINATION bin)
669 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.desktop DESTINATION share/applications/)
670 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION share/icons/hicolor/32x32/apps/)
671 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION share/icons/hicolor/scalable/apps/)
675 set(trojita_harmattan_path ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan)
676 install(TARGETS trojita-tp RUNTIME DESTINATION bin)
677 install(TARGETS trojitaqnamwebviewplugin LIBRARY DESTINATION bin/net/flaska/QNAMWebView)
678 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qmldir DESTINATION bin/net/flaska/QNAMWebView)
679 install(DIRECTORY ${trojita_harmattan_path}/qml DESTINATION ${CMAKE_INSTALL_PREFIX})
680 install(FILES ${trojita_harmattan_path}/trojita-tp.desktop DESTINATION share/applications)
681 install(FILES ${trojita_harmattan_path}/trojita-tp80.png DESTINATION share/icons/hicolor/80x80/apps)
685 if(CMAKE_SIZEOF_VOID_P STREQUAL 4)
686 set(MAKENSIS_OUTPUT Trojita-installer.exe)
688 set(MAKENSIS_FLAGS -DX86_64 ${MAKENSIS_FLAGS})
689 set(MAKENSIS_OUTPUT Trojita-installer-x86_64.exe)
692 if(NOT CMAKE_VERBOSE_MAKEFILE)
693 set(MAKENSIS_FLAGS -V2 -DQUIET ${MAKENSIS_FLAGS})
696 set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -NOCD)
698 add_custom_command(OUTPUT ${MAKENSIS_OUTPUT}
700 ARGS ${MAKENSIS_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi
701 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi ${CMAKE_CURRENT_BINARY_DIR}/trojita.exe version)
702 add_custom_target(installer ALL DEPENDS ${MAKENSIS_OUTPUT})
707 set(test_LibMailboxSync_SOURCES
708 tests/Utils/ModelEvents.cpp
709 tests/Utils/LibMailboxSync.cpp
711 add_library(test_LibMailboxSync STATIC ${test_LibMailboxSync_SOURCES})
713 qt5_use_modules(test_LibMailboxSync Test Network)
715 if(SUPPORTS_TARGET_INCLUDES)
716 set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
717 ${CMAKE_CURRENT_SOURCE_DIR}/tests
718 ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
720 target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
722 macro(trojita_test dir fname)
723 set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
724 add_executable(test_${fname} ${test_${fname}_SOURCES})
725 target_link_libraries(test_${fname} Imap MSA Streams Common Composer test_LibMailboxSync)
727 qt5_use_modules(test_${fname} Network Sql Test Widgets)
729 target_link_libraries(test_${fname} ${QT_QTSQL_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
732 target_link_libraries(test_${fname} ${ZLIB_LIBRARIES})
734 if(SUPPORTS_TARGET_INCLUDES)
735 set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
737 if(NOT CMAKE_CROSSCOMPILING)
738 add_test(test_${fname} test_${fname})
743 trojita_test(Composer Composer_Submission)
744 trojita_test(Composer Composer_responses)
745 trojita_test(Composer Html_formatting)
747 qt5_use_modules(test_Composer_responses WebKitWidgets)
748 qt5_use_modules(test_Html_formatting WebKitWidgets)
750 target_link_libraries(test_Html_formatting ${QT_QTWEBKIT_LIBRARY})
752 trojita_test(Imap Imap_DisappearingMailboxes)
753 trojita_test(Imap Imap_Idle)
754 trojita_test(Imap Imap_LowLevelParser)
755 trojita_test(Imap Imap_Message)
756 trojita_test(Imap Imap_Model)
757 trojita_test(Imap Imap_Parser_parse)
758 trojita_test(Imap Imap_Responses)
759 trojita_test(Imap Imap_SelectedMailboxUpdates)
760 trojita_test(Imap Imap_Tasks_CreateMailbox)
761 trojita_test(Imap Imap_Tasks_DeleteMailbox)
762 trojita_test(Imap Imap_Tasks_ListChildMailboxes)
763 trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
764 trojita_test(Imap Imap_Tasks_OpenConnection)
765 trojita_test(Imap Imap_Threading)
766 trojita_test(Imap Imap_BodyParts)
767 trojita_test(Imap Imap_Offline)
768 trojita_test(Imap Imap_CopyAndFlagOperations)
769 trojita_test(Misc Rfc5322)
770 trojita_test(Misc RingBuffer)
771 trojita_test(Misc SenderIdentitiesModel)
772 trojita_test(Misc SqlCache)
773 trojita_test(Misc algorithms)
774 trojita_test(Misc rfccodecs)
777 if(WIN32) # Check if we are on Windows
778 if(MSVC10) # Check if we are using the Visual Studio compiler 2010
779 # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
780 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
783 message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
784 message(WARNING "Please let us know how well it works.")
788 # FIXME: fix build warnings