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(Qt5Gui REQUIRED)
54 find_package(Qt5Network REQUIRED)
55 find_package(Qt5Sql REQUIRED)
56 find_package(Qt5WebKitWidgets REQUIRED)
57 find_package(Qt5Widgets REQUIRED)
58 find_package(Qt5LinguistTools)
60 find_package(Qt5Test REQUIRED)
62 if(Qt5LinguistTools_FOUND)
63 find_package(Qt5LinguistForTrojita)
66 message(STATUS "Building the Qt4 version")
67 set(QT_USE_QTNETWORK 1)
69 set(QT_USE_QTWEBKIT 1)
74 set(QT_USE_QTDECLARATIVE 1)
76 trojita_find_package(Qt4 4.6 "http://qt-project.org" "Qt4" "Needed for building" REQUIRED)
77 include(${QT_USE_FILE})
78 trojita_check_qt4_module(QTCORE REQUIRED)
79 trojita_check_qt4_module(QTGUI REQUIRED)
80 trojita_check_qt4_module(QTNETWORK REQUIRED)
81 trojita_check_qt4_module(QTSQL REQUIRED)
82 trojita_check_qt4_module(QTWEBKIT REQUIRED)
83 trojita_check_qt4_module(QTTEST WITH_TESTS)
84 trojita_check_qt4_module(QTDECLARATIVE WITH_HARMATTAN)
85 trojita_find_package(LinguistForTrojita "" "" "" "")
88 if(NOT QT_QCONFIG MATCHES "openssl" OR QT_QCONFIG MATCHES "no-openssl")
89 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}/MessageComposer.cpp
242 ${path_Composer}/PlainTextFormatter.cpp
243 ${path_Composer}/Recipients.cpp
244 ${path_Composer}/ReplaceSignature.cpp
245 ${path_Composer}/SenderIdentitiesModel.cpp
246 ${path_Composer}/SubjectMangling.cpp
247 ${path_Composer}/Submission.cpp
250 set(path_MSA ${CMAKE_CURRENT_SOURCE_DIR}/src/MSA)
252 ${path_MSA}/AbstractMSA.cpp
253 ${path_MSA}/FakeMSA.cpp
254 ${path_MSA}/ImapSubmit.cpp
256 ${path_MSA}/Sendmail.cpp
259 set(path_Streams ${CMAKE_CURRENT_SOURCE_DIR}/src/Streams)
260 set(libStreams_SOURCES
261 ${path_Streams}/DeletionWatcher.cpp
262 ${path_Streams}/FakeSocket.cpp
263 ${path_Streams}/IODeviceSocket.cpp
264 ${path_Streams}/Socket.cpp
265 ${path_Streams}/SocketFactory.cpp
269 set(libStreams_SOURCES ${libStreams_SOURCES}
270 ${path_Streams}/3rdparty/rfc1951.cpp)
271 include_directories(${ZLIB_INCLUDE_DIR})
275 set(path_mimetypesqt4 ${CMAKE_CURRENT_SOURCE_DIR}/src/mimetypes-qt4)
276 set(libMimetypesQt4_SOURCES
277 ${path_mimetypesqt4}/io/qstandardpaths.cpp
278 ${path_mimetypesqt4}/mimetypes/qmimedatabase.cpp
279 ${path_mimetypesqt4}/mimetypes/qmimeglobpattern.cpp
280 ${path_mimetypesqt4}/mimetypes/qmimemagicrule.cpp
281 ${path_mimetypesqt4}/mimetypes/qmimemagicrulematcher.cpp
282 ${path_mimetypesqt4}/mimetypes/qmimetype.cpp
283 ${path_mimetypesqt4}/mimetypes/qmimetypeparser.cpp
284 ${path_mimetypesqt4}/mimetypes/qmimeprovider.cpp
287 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
288 ${path_mimetypesqt4}/io/qstandardpaths_win.cpp)
290 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
291 ${path_mimetypesqt4}/io/qstandardpaths_mac.cpp)
293 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
294 ${path_mimetypesqt4}/io/qstandardpaths_os2.cpp)
296 set(libMimetypesQt4_SOURCES ${libMimetypesQt4_SOURCES}
297 ${path_mimetypesqt4}/io/qstandardpaths_unix.cpp)
299 message(FATAL_ERROR "Unsupported platform -- mimetypes-Qt4 support only Unix, MacOSX, Windows and OS/2")
303 set(path_DesktopGui ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui)
304 set(libDesktopGui_SOURCES
305 ${path_DesktopGui}/AttachmentView.cpp
306 ${path_DesktopGui}/AutoCompletion.cpp
307 ${path_DesktopGui}/CompleteMessageWidget.cpp
308 ${path_DesktopGui}/ComposeWidget.cpp
309 ${path_DesktopGui}/ComposerAttachmentsList.cpp
310 ${path_DesktopGui}/ComposerTextEdit.cpp
311 ${path_DesktopGui}/EmbeddedWebView.cpp
312 ${path_DesktopGui}/EnvelopeView.cpp
313 ${path_DesktopGui}/ExternalElementsWidget.cpp
314 ${path_DesktopGui}/FindBar.cpp
315 ${path_DesktopGui}/FlowLayout.cpp
316 ${path_DesktopGui}/FromAddressProxyModel.cpp
317 ${path_DesktopGui}/LineEdit.cpp
318 ${path_DesktopGui}/LoadablePartWidget.cpp
319 ${path_DesktopGui}/MailBoxTreeView.cpp
320 ${path_DesktopGui}/MessageListWidget.cpp
321 ${path_DesktopGui}/MessageSourceWidget.cpp
322 ${path_DesktopGui}/MessageView.cpp
323 ${path_DesktopGui}/MsgListView.cpp
324 ${path_DesktopGui}/OnePanelAtTimeWidget.cpp
325 ${path_DesktopGui}/OverlayWidget.cpp
326 ${path_DesktopGui}/PartWidget.cpp
327 ${path_DesktopGui}/PartWidgetFactory.cpp
328 ${path_DesktopGui}/PasswordDialog.cpp
329 ${path_DesktopGui}/ProgressPopUp.cpp
330 ${path_DesktopGui}/ProtocolLoggerWidget.cpp
331 ${path_DesktopGui}/ReplaceCharValidator.cpp
332 ${path_DesktopGui}/SettingsDialog.cpp
333 ${path_DesktopGui}/SimplePartWidget.cpp
334 ${path_DesktopGui}/Spinner.cpp
335 ${path_DesktopGui}/TagListWidget.cpp
336 ${path_DesktopGui}/TagWidget.cpp
337 ${path_DesktopGui}/TaskProgressIndicator.cpp
338 ${path_DesktopGui}/UserAgentWebPage.cpp
339 ${path_DesktopGui}/Util.cpp
340 ${path_DesktopGui}/Window.cpp
341 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigDialog.cpp
342 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.cpp
343 ${path_DesktopGui}/ShortcutHandler/ShortcutHandler.cpp
346 ${path_DesktopGui}/AboutDialog.ui
347 ${path_DesktopGui}/ComposeWidget.ui
348 ${path_DesktopGui}/CreateMailboxDialog.ui
349 ${path_DesktopGui}/EditIdentity.ui
350 ${path_DesktopGui}/PasswordDialog.ui
351 ${path_DesktopGui}/ProgressPopUp.ui
352 ${path_DesktopGui}/SettingsCachePage.ui
353 ${path_DesktopGui}/SettingsGeneralPage.ui
354 ${path_DesktopGui}/SettingsImapPage.ui
355 ${path_DesktopGui}/SettingsOutgoingPage.ui
356 ${path_DesktopGui}/ShortcutHandler/ShortcutConfigWidget.ui
358 set(libDesktopGui_RESOURCES
359 ${CMAKE_CURRENT_SOURCE_DIR}/src/icons.qrc
360 ${CMAKE_CURRENT_SOURCE_DIR}/src/license.qrc
363 set(libqwwsmtpclient_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/qwwsmtpclient/qwwsmtpclient.cpp)
365 set(libAppVersion_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/AppVersion/SetCoreApplication.cpp)
367 set(path_Imap ${CMAKE_CURRENT_SOURCE_DIR}/src/Imap)
369 ${path_Imap}/ConnectionState.cpp
370 ${path_Imap}/Encoders.cpp
371 ${path_Imap}/Exceptions.cpp
372 ${path_Imap}/Parser/3rdparty/kcodecs.cpp
373 ${path_Imap}/Parser/3rdparty/rfccodecs.cpp
375 ${path_Imap}/Parser/Command.cpp
376 ${path_Imap}/Parser/Data.cpp
377 ${path_Imap}/Parser/LowLevelParser.cpp
378 ${path_Imap}/Parser/MailAddress.cpp
379 ${path_Imap}/Parser/Message.cpp
380 ${path_Imap}/Parser/Parser.cpp
381 ${path_Imap}/Parser/Response.cpp
382 ${path_Imap}/Parser/Sequence.cpp
383 ${path_Imap}/Parser/ThreadingNode.cpp
385 ${path_Imap}/Network/FileDownloadManager.cpp
386 ${path_Imap}/Network/ForbiddenReply.cpp
387 ${path_Imap}/Network/MsgPartNetAccessManager.cpp
388 ${path_Imap}/Network/MsgPartNetworkReply.cpp
390 ${path_Imap}/Model/Cache.cpp
391 ${path_Imap}/Model/CombinedCache.cpp
392 ${path_Imap}/Model/DragAndDrop.cpp
393 ${path_Imap}/Model/DiskPartCache.cpp
394 ${path_Imap}/Model/FindInterestingPart.cpp
395 ${path_Imap}/Model/FlagsOperation.cpp
396 ${path_Imap}/Model/FullMessageCombiner.cpp
397 ${path_Imap}/Model/ImapAccess.cpp
398 ${path_Imap}/Model/MailboxMetadata.cpp
399 ${path_Imap}/Model/MailboxModel.cpp
400 ${path_Imap}/Model/MailboxTree.cpp
401 ${path_Imap}/Model/MemoryCache.cpp
402 ${path_Imap}/Model/Model.cpp
403 ${path_Imap}/Model/MsgListModel.cpp
404 ${path_Imap}/Model/NetworkWatcher.cpp
405 ${path_Imap}/Model/OneMessageModel.cpp
406 ${path_Imap}/Model/ParserState.cpp
407 ${path_Imap}/Model/PrettyMailboxModel.cpp
408 ${path_Imap}/Model/PrettyMsgListModel.cpp
409 ${path_Imap}/Model/SpecialFlagNames.cpp
410 ${path_Imap}/Model/SQLCache.cpp
411 ${path_Imap}/Model/SubtreeModel.cpp
412 ${path_Imap}/Model/TaskFactory.cpp
413 ${path_Imap}/Model/TaskPresentationModel.cpp
414 ${path_Imap}/Model/ThreadingMsgListModel.cpp
415 ${path_Imap}/Model/Utils.cpp
416 ${path_Imap}/Model/VisibleTasksModel.cpp
418 # The ModelTest is only needed when debugging manually
419 #${path_Imap}/Model/ModelTest/modeltest.cpp
420 # The ModelWatcher is another debugging aid
421 ${path_Imap}/Model/ModelWatcher.cpp
423 ${path_Imap}/Model/kdeui-itemviews/kdescendantsproxymodel.cpp
425 ${path_Imap}/Tasks/AppendTask.cpp
426 ${path_Imap}/Tasks/CopyMoveMessagesTask.cpp
427 ${path_Imap}/Tasks/CreateMailboxTask.cpp
428 ${path_Imap}/Tasks/DeleteMailboxTask.cpp
429 ${path_Imap}/Tasks/EnableTask.cpp
430 ${path_Imap}/Tasks/ExpungeMailboxTask.cpp
431 ${path_Imap}/Tasks/ExpungeMessagesTask.cpp
432 ${path_Imap}/Tasks/Fake_ListChildMailboxesTask.cpp
433 ${path_Imap}/Tasks/Fake_OpenConnectionTask.cpp
434 ${path_Imap}/Tasks/FetchMsgMetadataTask.cpp
435 ${path_Imap}/Tasks/FetchMsgPartTask.cpp
436 ${path_Imap}/Tasks/GenUrlAuthTask.cpp
437 ${path_Imap}/Tasks/GetAnyConnectionTask.cpp
438 ${path_Imap}/Tasks/IdTask.cpp
439 ${path_Imap}/Tasks/IdleLauncher.cpp
440 ${path_Imap}/Tasks/ImapTask.cpp
441 ${path_Imap}/Tasks/KeepMailboxOpenTask.cpp
442 ${path_Imap}/Tasks/ListChildMailboxesTask.cpp
443 ${path_Imap}/Tasks/NoopTask.cpp
444 ${path_Imap}/Tasks/NumberOfMessagesTask.cpp
445 ${path_Imap}/Tasks/ObtainSynchronizedMailboxTask.cpp
446 ${path_Imap}/Tasks/OfflineConnectionTask.cpp
447 ${path_Imap}/Tasks/OpenConnectionTask.cpp
448 ${path_Imap}/Tasks/SortTask.cpp
449 ${path_Imap}/Tasks/SubscribeUnsubscribeTask.cpp
450 ${path_Imap}/Tasks/ThreadTask.cpp
451 ${path_Imap}/Tasks/UidSubmitTask.cpp
452 ${path_Imap}/Tasks/UnSelectTask.cpp
453 ${path_Imap}/Tasks/UpdateFlagsTask.cpp
454 ${path_Imap}/Tasks/UpdateFlagsOfAllMessagesTask.cpp
458 message(STATUS "Using Ragel for the RFC 5322 parser")
459 ragel_parser(${path_Imap}/Parser/Rfc5322HeaderParser.cpp)
460 set(libImap_SOURCES ${libImap_SOURCES}
461 ${CMAKE_CURRENT_BINARY_DIR}/Rfc5322HeaderParser.generated.cpp)
463 message(STATUS "Using pregenerated RFC 5322 parser")
464 set(libImap_SOURCES ${libImap_SOURCES}
465 ${path_Imap}/Parser/Rfc5322HeaderParser.generated.cpp)
468 set(path_AbookAddressbook ${CMAKE_CURRENT_SOURCE_DIR}/src/AbookAddressbook)
469 set(libAbookAddressbook_SOURCES
470 ${path_AbookAddressbook}/AbookAddressbook.cpp
471 ${path_AbookAddressbook}/be-contacts.cpp
473 set(libAbookAddressbook_UI
474 ${path_AbookAddressbook}/be-contacts.ui
475 ${path_AbookAddressbook}/onecontact.ui
478 set(trojita_desktop_SOURCES
479 ${path_DesktopGui}/main.cpp
483 list(APPEND trojita_desktop_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/trojita_win32.rc)
486 set(be_contacts_SOURCES
487 ${CMAKE_CURRENT_SOURCE_DIR}/src/be.contacts/main.cpp
490 set(libQNAMWebView_SOURCES
491 ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/plugin.cpp
492 ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qdeclarativewebview.cpp
495 set(trojitaHarmattan_SOURCES
496 ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/main.cpp
497 ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer/qmlapplicationviewer.cpp
500 if(LinguistForTrojita_FOUND OR Qt5LinguistForTrojita_FOUND)
501 file(GLOB_RECURSE lang_PO "${CMAKE_CURRENT_SOURCE_DIR}/po/trojita_common_*.po")
503 qt5_wrap_po(trojita_QM ${lang_PO})
505 qt4_wrap_po(trojita_QM ${lang_PO})
507 set(language_summary "")
508 foreach(po ${lang_PO})
509 string(REGEX REPLACE "^(.*)/trojita_common_(.*).po" "\\2" lang ${po})
510 list(APPEND language_summary ${lang})
512 list(SORT language_summary)
513 list(LENGTH language_summary num_languages)
515 message(STATUS "Available languages: ${language_summary}")
517 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/ DESTINATION share/trojita/locale FILES_MATCHING PATTERN *.qm)
520 message(STATUS "No .po files found, will not install any languages")
523 message(STATUS "Qt Linguist (lupdate/lrelease/lconvert) not found, disabling localization support")
526 set(version_files ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.h ${CMAKE_CURRENT_BINARY_DIR}/trojita-git-version.h)
528 set(version_files ${version_files} ${CMAKE_CURRENT_BINARY_DIR}/trojita-version.nsi)
532 add_custom_target(version DEPENDS version_fake_file)
533 add_custom_command(OUTPUT version_fake_file ${version_files}
534 COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DNSIS=${NSIS} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TrojitaVersion.cmake)
535 set_source_files_properties(${version_files}
536 PROPERTIES GENERATED TRUE
537 HEADER_FILE_ONLY TRUE)
539 add_library(Common ${libCommon_SOURCES})
540 add_dependencies(Common version)
541 target_link_libraries(Common ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
543 add_library(AppVersion ${libAppVersion_SOURCES})
544 add_dependencies(AppVersion version)
545 target_link_libraries(AppVersion Common ${QT_QTCORE_LIBRARY})
547 if(WITH_SHARED_PLUGINS)
548 add_library(Plugins SHARED ${libPlugins_SOURCES})
550 add_library(Plugins STATIC ${libPlugins_SOURCES})
551 set_property(TARGET Plugins APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN)
553 set_target_properties(Plugins PROPERTIES OUTPUT_NAME trojita_plugins)
555 qt5_use_modules(Plugins Core)
557 target_link_libraries(Plugins ${QT_QTCORE_LIBRARY})
560 add_library(Streams ${libStreams_SOURCES})
561 target_link_libraries(Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
563 target_link_libraries(Streams ${ZLIB_LIBRARIES})
566 add_library(qwwsmtpclient ${libqwwsmtpclient_SOURCES})
567 target_link_libraries(qwwsmtpclient ${QT_QTNETWORK_LIBRARY} ${QT_QTCORE_LIBRARY})
569 add_library(MSA ${libMSA_SOURCES})
570 target_link_libraries(MSA Imap Streams qwwsmtpclient ${QT_QTCORE_LIBRARY})
572 add_library(Composer ${libComposer_SOURCES})
573 target_link_libraries(Composer Common MSA Streams qwwsmtpclient ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
575 target_link_libraries(Composer MimetypesQt4)
578 add_library(Imap ${libImap_SOURCES})
579 target_link_libraries(Imap Common Streams ${QT_QTNETWORK_LIBRARY} ${QT_QTSQL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
581 target_link_libraries(Imap ${ZLIB_LIBRARIES})
585 add_library(MimetypesQt4 ${libMimetypesQt4_SOURCES})
586 if(SUPPORTS_TARGET_INCLUDES)
587 set_property(TARGET MimetypesQt4 APPEND PROPERTY INCLUDE_DIRECTORIES
588 ${QT_MKSPECS_DIR}/default ${path_mimetypesqt4}/io/)
590 target_link_libraries(MimetypesQt4 ${QT_QTCORE_LIBRARY})
593 # Generate file static_plugins.h.in
594 get_property(STATIC_PLUGINS GLOBAL PROPERTY TROJITA_STATIC_PLUGINS)
595 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "#include <QtPlugin>\n")
596 foreach(PLUGIN ${STATIC_PLUGINS})
597 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in "Q_IMPORT_PLUGIN(${PLUGIN})\n")
599 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h.in ${CMAKE_CURRENT_BINARY_DIR}/static_plugins.h)
603 qt5_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
604 qt5_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
605 qt5_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
607 qt4_wrap_ui(libAbookAddressbook_UI_OUT ${libAbookAddressbook_UI})
608 qt4_wrap_ui(libDesktopGui_UI_OUT ${libDesktopGui_UI})
609 qt4_add_resources(libDesktopGui_RESOURCES_OUT ${libDesktopGui_RESOURCES})
612 add_library(AbookAddressbook ${libAbookAddressbook_SOURCES} ${libAbookAddressbook_UI_OUT})
613 target_link_libraries(AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
615 add_library(DesktopGui ${libDesktopGui_SOURCES} ${libDesktopGui_UI_OUT} ${libDesktopGui_RESOURCES_OUT})
616 # The following is needed for the LineEdit widget within the .ui files.
617 # The ${path_DesktopGui} is needed so that the generated ui_*.h file can find the headers of the custom widgets
618 if(SUPPORTS_TARGET_INCLUDES)
619 set_property(TARGET DesktopGui APPEND PROPERTY INCLUDE_DIRECTORIES ${path_DesktopGui})
621 target_link_libraries(DesktopGui Common Composer Imap MSA Plugins Streams qwwsmtpclient AbookAddressbook ${QT_QTWEBKIT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
623 # On Windows build a real Win32 GUI application without console window
624 # On other platforms WIN32 flag is ignored
625 add_executable(trojita WIN32 ${trojita_desktop_SOURCES} ${trojita_QM})
626 target_link_libraries(trojita AppVersion Common DesktopGui ${STATIC_PLUGINS} ${QT_QTMAIN_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
628 target_link_libraries(trojita MimetypesQt4)
631 target_link_libraries(trojita ${ZLIB_LIBRARIES})
634 add_executable(be.contacts ${be_contacts_SOURCES})
635 target_link_libraries(be.contacts AbookAddressbook ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
636 elseif(WITH_HARMATTAN)
637 add_library(trojitaqnamwebviewplugin SHARED ${libQNAMWebView_SOURCES})
638 add_executable(trojita-tp ${trojitaHarmattan_SOURCES})
639 if(SUPPORTS_TARGET_INCLUDES)
640 set_property(TARGET trojita-tp APPEND PROPERTY INCLUDE_DIRECTORIES
641 ${QT_MKSPECS_DIR}/default ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan/qmlapplicationviewer)
643 target_link_libraries(trojita-tp AppVersion Imap MSA Streams qwwsmtpclient Common Composer MimetypesQt4
644 ${QT_QTSQL_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
648 qt5_use_modules(AppVersion Core)
649 qt5_use_modules(Common Core Network)
650 qt5_use_modules(Streams Network)
651 qt5_use_modules(qwwsmtpclient Network)
652 qt5_use_modules(MSA Network)
653 qt5_use_modules(Composer Gui Network)
654 qt5_use_modules(Imap Gui Network Sql)
655 qt5_use_modules(DesktopGui Network WebKitWidgets)
656 qt5_use_modules(AbookAddressbook Widgets)
657 qt5_use_modules(be.contacts Widgets)
658 qt5_use_modules(trojita Widgets Network)
661 if(WITH_SHARED_PLUGINS)
662 install(TARGETS Plugins DESTINATION ${CMAKE_INSTALL_LIBDIR})
666 install(TARGETS trojita be.contacts RUNTIME DESTINATION bin)
667 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Gui/trojita.desktop DESTINATION share/applications/)
668 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.png DESTINATION share/icons/hicolor/32x32/apps/)
669 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/icons/trojita.svg DESTINATION share/icons/hicolor/scalable/apps/)
673 set(trojita_harmattan_path ${CMAKE_CURRENT_SOURCE_DIR}/src/Harmattan)
674 install(TARGETS trojita-tp RUNTIME DESTINATION bin)
675 install(TARGETS trojitaqnamwebviewplugin LIBRARY DESTINATION bin/net/flaska/QNAMWebView)
676 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/QmlSupport/QNAMWebView/qmldir DESTINATION bin/net/flaska/QNAMWebView)
677 install(DIRECTORY ${trojita_harmattan_path}/qml DESTINATION ${CMAKE_INSTALL_PREFIX})
678 install(FILES ${trojita_harmattan_path}/trojita-tp.desktop DESTINATION share/applications)
679 install(FILES ${trojita_harmattan_path}/trojita-tp80.png DESTINATION share/icons/hicolor/80x80/apps)
683 if(CMAKE_SIZEOF_VOID_P STREQUAL 4)
684 set(MAKENSIS_OUTPUT Trojita-installer.exe)
686 set(MAKENSIS_FLAGS -DX86_64 ${MAKENSIS_FLAGS})
687 set(MAKENSIS_OUTPUT Trojita-installer-x86_64.exe)
690 if(NOT CMAKE_VERBOSE_MAKEFILE)
691 set(MAKENSIS_FLAGS -V2 -DQUIET ${MAKENSIS_FLAGS})
694 set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -NOCD)
696 add_custom_command(OUTPUT ${MAKENSIS_OUTPUT}
698 ARGS ${MAKENSIS_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi
699 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/trojita.nsi ${CMAKE_CURRENT_BINARY_DIR}/trojita.exe version)
700 add_custom_target(installer ALL DEPENDS ${MAKENSIS_OUTPUT})
705 set(test_LibMailboxSync_SOURCES
706 tests/Utils/ModelEvents.cpp
707 tests/Utils/LibMailboxSync.cpp
709 add_library(test_LibMailboxSync ${test_LibMailboxSync_SOURCES})
711 qt5_use_modules(test_LibMailboxSync Test Network)
713 if(SUPPORTS_TARGET_INCLUDES)
714 set_property(TARGET test_LibMailboxSync APPEND PROPERTY INCLUDE_DIRECTORIES
715 ${CMAKE_CURRENT_SOURCE_DIR}/tests
716 ${CMAKE_CURRENT_SOURCE_DIR}/tests/Utils)
718 target_link_libraries(test_LibMailboxSync Imap MSA Streams Common Composer ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY})
720 macro(trojita_test dir fname)
721 set(test_${fname}_SOURCES tests/${dir}/test_${fname}.cpp)
722 add_executable(test_${fname} ${test_${fname}_SOURCES})
723 target_link_libraries(test_${fname} Imap MSA Streams Common Composer test_LibMailboxSync)
725 qt5_use_modules(test_${fname} Network Sql Test Widgets)
727 target_link_libraries(test_${fname} ${QT_QTSQL_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
730 target_link_libraries(test_${fname} ${ZLIB_LIBRARIES})
732 if(SUPPORTS_TARGET_INCLUDES)
733 set_property(TARGET test_${fname} APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/tests)
735 if(NOT CMAKE_CROSSCOMPILING)
736 add_test(test_${fname} test_${fname})
741 trojita_test(Composer Composer_Submission)
742 trojita_test(Composer Composer_responses)
743 trojita_test(Composer Html_formatting)
745 qt5_use_modules(test_Composer_responses WebKitWidgets)
746 qt5_use_modules(test_Html_formatting WebKitWidgets)
748 target_link_libraries(test_Html_formatting ${QT_QTWEBKIT_LIBRARY})
750 trojita_test(Imap Imap_DisappearingMailboxes)
751 trojita_test(Imap Imap_Idle)
752 trojita_test(Imap Imap_LowLevelParser)
753 trojita_test(Imap Imap_Message)
754 trojita_test(Imap Imap_Model)
755 trojita_test(Imap Imap_Parser_parse)
756 trojita_test(Imap Imap_Responses)
757 trojita_test(Imap Imap_SelectedMailboxUpdates)
758 trojita_test(Imap Imap_Tasks_CreateMailbox)
759 trojita_test(Imap Imap_Tasks_DeleteMailbox)
760 trojita_test(Imap Imap_Tasks_ListChildMailboxes)
761 trojita_test(Imap Imap_Tasks_ObtainSynchronizedMailbox)
762 trojita_test(Imap Imap_Tasks_OpenConnection)
763 trojita_test(Imap Imap_Threading)
764 trojita_test(Imap Imap_BodyParts)
765 trojita_test(Imap Imap_Offline)
766 trojita_test(Imap Imap_CopyAndFlagOperations)
767 trojita_test(Misc Rfc5322)
768 trojita_test(Misc RingBuffer)
769 trojita_test(Misc SenderIdentitiesModel)
770 trojita_test(Misc SqlCache)
771 trojita_test(Misc algorithms)
772 trojita_test(Misc rfccodecs)
775 if(WIN32) # Check if we are on Windows
776 if(MSVC10) # Check if we are using the Visual Studio compiler 2010
777 # Because of linker errors (see http://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error)
778 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
781 message(WARNING "You are using a compiler which we have not tested yet (not MSVC10 or MINGW).")
782 message(WARNING "Please let us know how well it works.")
786 # FIXME: fix build warnings