CMakeLists.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. project(gui)
  2. find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2)
  3. set(CMAKE_AUTOMOC TRUE)
  4. set(CMAKE_AUTOUIC TRUE)
  5. set(CMAKE_AUTORCC TRUE)
  6. if(CMAKE_BUILD_TYPE MATCHES Debug)
  7. add_definitions(-DQT_QML_DEBUG)
  8. endif()
  9. IF(BUILD_UPDATER)
  10. add_subdirectory(updater)
  11. endif()
  12. set(MIRALL_RC_SRC ../../resources.qrc)
  13. if (EXISTS "${OEM_THEME_DIR}/theme.qrc")
  14. list(APPEND MIRALL_RC_SRC ${OEM_THEME_DIR}/theme.qrc)
  15. set(theme_dir ${OEM_THEME_DIR}/theme)
  16. else()
  17. list(APPEND MIRALL_RC_SRC ../../theme.qrc)
  18. set(theme_dir ${CMAKE_SOURCE_DIR}/theme)
  19. endif()
  20. #set (QML_IMPORT_PATH "${CMAKE_SOURCE_DIR}/src/gui/tray" CACHE STRING "Extra qml module import paths" FORCE)
  21. set(client_UI_SRCS
  22. accountsettings.ui
  23. conflictdialog.ui
  24. folderwizardsourcepage.ui
  25. folderwizardtargetpage.ui
  26. generalsettings.ui
  27. legalnotice.ui
  28. ignorelisteditor.ui
  29. ignorelisttablewidget.ui
  30. networksettings.ui
  31. synclogdialog.ui
  32. settingsdialog.ui
  33. sharedialog.ui
  34. sharelinkwidget.ui
  35. shareusergroupwidget.ui
  36. shareuserline.ui
  37. sslerrordialog.ui
  38. addcertificatedialog.ui
  39. proxyauthdialog.ui
  40. mnemonicdialog.ui
  41. tray/Window.qml
  42. tray/UserLine.qml
  43. wizard/flow2authwidget.ui
  44. wizard/owncloudadvancedsetuppage.ui
  45. wizard/owncloudconnectionmethoddialog.ui
  46. wizard/owncloudhttpcredspage.ui
  47. wizard/owncloudoauthcredspage.ui
  48. wizard/owncloudsetupnocredspage.ui
  49. wizard/owncloudwizardresultpage.ui
  50. wizard/webview.ui
  51. )
  52. set(client_SRCS
  53. accountmanager.cpp
  54. accountsettings.cpp
  55. application.cpp
  56. conflictdialog.cpp
  57. conflictsolver.cpp
  58. connectionvalidator.cpp
  59. folder.cpp
  60. folderman.cpp
  61. folderstatusmodel.cpp
  62. folderstatusdelegate.cpp
  63. folderstatusview.cpp
  64. folderwatcher.cpp
  65. folderwizard.cpp
  66. generalsettings.cpp
  67. legalnotice.cpp
  68. ignorelisteditor.cpp
  69. ignorelisttablewidget.cpp
  70. lockwatcher.cpp
  71. logbrowser.cpp
  72. navigationpanehelper.cpp
  73. networksettings.cpp
  74. ocsnavigationappsjob.cpp
  75. ocsjob.cpp
  76. ocssharejob.cpp
  77. ocsshareejob.cpp
  78. openfilemanager.cpp
  79. owncloudgui.cpp
  80. owncloudsetupwizard.cpp
  81. selectivesyncdialog.cpp
  82. settingsdialog.cpp
  83. sharedialog.cpp
  84. sharelinkwidget.cpp
  85. sharemanager.cpp
  86. shareusergroupwidget.cpp
  87. sharee.cpp
  88. socketapi.cpp
  89. sslbutton.cpp
  90. sslerrordialog.cpp
  91. syncrunfilelog.cpp
  92. systray.cpp
  93. thumbnailjob.cpp
  94. userinfo.cpp
  95. accountstate.cpp
  96. addcertificatedialog.cpp
  97. authenticationdialog.cpp
  98. proxyauthhandler.cpp
  99. proxyauthdialog.cpp
  100. synclogdialog.cpp
  101. tooltipupdater.cpp
  102. notificationconfirmjob.cpp
  103. guiutility.cpp
  104. elidedlabel.cpp
  105. headerbanner.cpp
  106. iconjob.cpp
  107. remotewipe.cpp
  108. tray/ActivityData.cpp
  109. tray/ActivityListModel.cpp
  110. tray/UserModel.cpp
  111. tray/NotificationHandler.cpp
  112. creds/credentialsfactory.cpp
  113. creds/httpcredentialsgui.cpp
  114. creds/oauth.cpp
  115. creds/flow2auth.cpp
  116. creds/webflowcredentials.cpp
  117. creds/webflowcredentialsdialog.cpp
  118. wizard/postfixlineedit.cpp
  119. wizard/abstractcredswizardpage.cpp
  120. wizard/owncloudadvancedsetuppage.cpp
  121. wizard/owncloudconnectionmethoddialog.cpp
  122. wizard/owncloudhttpcredspage.cpp
  123. wizard/owncloudoauthcredspage.cpp
  124. wizard/flow2authcredspage.cpp
  125. wizard/flow2authwidget.cpp
  126. wizard/owncloudsetuppage.cpp
  127. wizard/owncloudwizardcommon.cpp
  128. wizard/owncloudwizard.cpp
  129. wizard/owncloudwizardresultpage.cpp
  130. wizard/webviewpage.cpp
  131. wizard/webview.cpp
  132. wizard/slideshow.cpp
  133. )
  134. IF(NOT NO_SHIBBOLETH)
  135. list(APPEND client_SRCS
  136. creds/shibbolethcredentials.cpp
  137. creds/shibboleth/shibbolethwebview.cpp
  138. creds/shibboleth/shibbolethuserjob.cpp
  139. wizard/owncloudshibbolethcredspage.cpp
  140. )
  141. endif()
  142. IF(BUILD_UPDATER)
  143. set(updater_SRCS
  144. updater/ocupdater.cpp
  145. updater/updateinfo.cpp
  146. updater/updater.cpp
  147. )
  148. endif()
  149. IF( APPLE )
  150. list(APPEND client_SRCS cocoainitializer_mac.mm)
  151. list(APPEND client_SRCS socketapisocket_mac.mm)
  152. list(APPEND client_SRCS systray.mm)
  153. if(SPARKLE_FOUND AND BUILD_UPDATER)
  154. # Define this, we need to check in updater.cpp
  155. add_definitions(-DHAVE_SPARKLE)
  156. list(APPEND updater_SRCS updater/sparkleupdater_mac.mm updater/sparkleupdater.h)
  157. list(APPEND updater_DEPS ${SPARKLE_LIBRARY})
  158. # Sparkle.framework is installed from here because macdeployqt's CopyFramework breaks on this bundle
  159. # as its logic is tightly tailored around Qt5 frameworks
  160. install(DIRECTORY "${SPARKLE_LIBRARY}"
  161. DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks" USE_SOURCE_PERMISSIONS)
  162. endif()
  163. ENDIF()
  164. IF( NOT WIN32 AND NOT APPLE )
  165. set(client_SRCS ${client_SRCS} folderwatcher_linux.cpp)
  166. ENDIF()
  167. IF( WIN32 )
  168. set(client_SRCS ${client_SRCS} folderwatcher_win.cpp)
  169. ENDIF()
  170. IF( APPLE )
  171. list(APPEND client_SRCS folderwatcher_mac.cpp)
  172. ENDIF()
  173. set(3rdparty_SRC
  174. ../3rdparty/QProgressIndicator/QProgressIndicator.cpp
  175. ../3rdparty/qtlockedfile/qtlockedfile.cpp
  176. ../3rdparty/qtsingleapplication/qtlocalpeer.cpp
  177. ../3rdparty/qtsingleapplication/qtsingleapplication.cpp
  178. ../3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp
  179. ../3rdparty/kmessagewidget/kmessagewidget.cpp
  180. )
  181. if(NOT WIN32)
  182. list(APPEND 3rdparty_SRC ../3rdparty/qtlockedfile/qtlockedfile_unix.cpp)
  183. else()
  184. list(APPEND 3rdparty_SRC ../3rdparty/qtlockedfile/qtlockedfile_win.cpp )
  185. endif()
  186. IF( NOT WIN32 AND NOT APPLE AND LIBCLOUDPROVIDERS_FOUND)
  187. message("Building with libcloudproviderssupport")
  188. add_definitions(-DWITH_LIBCLOUDPROVIDERS)
  189. set(client_SRCS ${client_SRCS} cloudproviders/cloudprovidermanager.cpp)
  190. set(client_SRCS ${client_SRCS} cloudproviders/cloudproviderwrapper.cpp)
  191. include_directories(${GLib2_INCLUDE_DIRS})
  192. include_directories(${GIO_INCLUDE_DIRS})
  193. include_directories(${LIBCLOUDPROVIDERS_INCLUDE_DIR})
  194. ENDIF()
  195. find_package(Qt5LinguistTools)
  196. if(Qt5LinguistTools_FOUND)
  197. qt5_add_translation(client_I18N ${TRANSLATIONS})
  198. endif()
  199. IF( WIN32 )
  200. configure_file(
  201. ${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in
  202. ${CMAKE_CURRENT_BINARY_DIR}/version.rc
  203. @ONLY)
  204. set(client_version ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
  205. IF(NOT MSVC)
  206. set(client_manifest ${CMAKE_CURRENT_SOURCE_DIR}/manifest-mingw.rc)
  207. ENDIF()
  208. ENDIF()
  209. set( final_src
  210. ${MIRALL_RC_SRC}
  211. ${client_SRCS}
  212. ${client_UI_SRCS}
  213. ${client_version}
  214. ${client_manifest}
  215. ${guiMoc}
  216. ${client_I18N}
  217. ${3rdparty_SRC}
  218. ${3rdparty_MOC}
  219. )
  220. if(Qt5Keychain_FOUND)
  221. list(APPEND libsync_LINK_TARGETS qt5keychain)
  222. endif()
  223. # add executable icon on windows and osx
  224. # UPSTREAM our ECMAddAppIcon.cmake then require that version here
  225. # find_package(ECM 1.7.0 REQUIRED NO_MODULE)
  226. # list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
  227. include(ECMAddAppIcon)
  228. # For historical reasons we can not use the application_shortname
  229. # for ownCloud but must rather set it manually.
  230. if (NOT DEFINED APPLICATION_ICON_NAME)
  231. set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME})
  232. endif()
  233. file(GLOB_RECURSE OWNCLOUD_ICONS "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-icon*")
  234. if(APPLE)
  235. file(GLOB_RECURSE OWNCLOUD_SIDEBAR_ICONS "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-sidebar*")
  236. MESSAGE(STATUS "OWNCLOUD_SIDEBAR_ICONS: ${APPLICATION_ICON_NAME}: ${OWNCLOUD_SIDEBAR_ICONS}")
  237. endif()
  238. ecm_add_app_icon(final_src ICONS "${OWNCLOUD_ICONS}" SIDEBAR_ICONS "${OWNCLOUD_SIDEBAR_ICONS}" OUTFILE_BASENAME "${APPLICATION_ICON_NAME}")
  239. if(UNIX AND NOT APPLE)
  240. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
  241. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
  242. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
  243. endif()
  244. if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  245. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
  246. endif()
  247. if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
  248. if(NOT WIN32)
  249. file(GLOB _icons "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-icon.png")
  250. foreach(_file ${_icons})
  251. string(REPLACE "${theme_dir}/colored/" "" _res ${_file})
  252. string(REPLACE "-${APPLICATION_ICON_NAME}-icon.png" "" _res ${_res})
  253. install(FILES ${_file} RENAME ${APPLICATION_ICON_NAME}.png DESTINATION ${DATADIR}/icons/hicolor/${_res}x${_res}/apps)
  254. endforeach(_file)
  255. install(FILES ${client_I18N} DESTINATION ${SHAREDIR}/${APPLICATION_EXECUTABLE}/i18n)
  256. else()
  257. file(GLOB_RECURSE VISUAL_ELEMENTS "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-w10startmenu*")
  258. install(FILES ${VISUAL_ELEMENTS} DESTINATION bin/visualelements)
  259. install(FILES "${theme_dir}/${APPLICATION_EXECUTABLE}.VisualElementsManifest.xml" DESTINATION bin)
  260. install(FILES ${client_I18N} DESTINATION i18n)
  261. endif()
  262. # we may not add MACOSX_BUNDLE here, if not building one
  263. # add_executable( ${APPLICATION_EXECUTABLE} main.cpp ${final_src})
  264. add_executable( ${APPLICATION_EXECUTABLE} WIN32 main.cpp ${final_src})
  265. else()
  266. # set(CMAKE_INSTALL_PREFIX ".") # Examples use /Applications. hurmpf.
  267. set(MACOSX_BUNDLE_ICON_FILE "${APPLICATION_ICON_NAME}.icns")
  268. # we must add MACOSX_BUNDLE only if building a bundle
  269. add_executable( ${APPLICATION_EXECUTABLE} WIN32 MACOSX_BUNDLE main.cpp ${final_src})
  270. set (QM_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/Translations)
  271. install(FILES ${client_I18N} DESTINATION ${QM_DIR})
  272. get_target_property(_qmake Qt5::qmake LOCATION)
  273. execute_process(COMMAND ${_qmake} -query QT_INSTALL_TRANSLATIONS
  274. OUTPUT_VARIABLE QT_TRANSLATIONS_DIR
  275. OUTPUT_STRIP_TRAILING_WHITESPACE
  276. )
  277. file(GLOB qt_I18N ${QT_TRANSLATIONS_DIR}/qt_??.qm ${QT_TRANSLATIONS_DIR}/qt_??_??.qm)
  278. install(FILES ${qt_I18N} DESTINATION ${QM_DIR})
  279. file(GLOB qtbase_I18N ${QT_TRANSLATIONS_DIR}/qtbase_??.qm ${QT_TRANSLATIONS_DIR}/qt_??_??.qm)
  280. install(FILES ${qtbase_I18N} DESTINATION ${QM_DIR})
  281. file(GLOB qtkeychain_I18N ${QT_TRANSLATIONS_DIR}/qtkeychain*.qm)
  282. install(FILES ${qtkeychain_I18N} DESTINATION ${QM_DIR})
  283. endif()
  284. IF(BUILD_UPDATER)
  285. add_library(updater STATIC ${updater_SRCS})
  286. target_link_libraries(updater ${synclib_NAME} ${updater_DEPS} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml)
  287. target_include_directories(updater PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
  288. endif()
  289. set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
  290. RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY}
  291. )
  292. # Only relevant for Linux? On OS X it by default properly checks in the bundle directory next to the exe
  293. set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
  294. INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )
  295. target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::GuiPrivate Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::WebEngineWidgets)
  296. target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
  297. IF(BUILD_UPDATER)
  298. target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
  299. endif()
  300. target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} )
  301. IF( LIBCLOUDPROVIDERS_FOUND )
  302. string(TOLOWER "${APPLICATION_VENDOR}" DBUS_VENDOR)
  303. string(REGEX REPLACE "[^A-z0-9]" "" DBUS_VENDOR "${DBUS_VENDOR}")
  304. string(REGEX REPLACE "[^A-z0-9]" "" DBUS_APPLICATION_NAME "${APPLICATION_SHORTNAME}")
  305. if(NOT DBUS_PREFIX)
  306. set(DBUS_PREFIX "com")
  307. endif(NOT DBUS_PREFIX)
  308. set(LIBCLOUDPROVIDERS_DBUS_BUS_NAME "${DBUS_PREFIX}.${DBUS_VENDOR}.${DBUS_APPLICATION_NAME}")
  309. set(LIBCLOUDPROVIDERS_DBUS_OBJECT_PATH "/${DBUS_PREFIX}/${DBUS_VENDOR}/${DBUS_APPLICATION_NAME}")
  310. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cloudproviders/cloudproviderconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/cloudproviderconfig.h)
  311. target_link_libraries( ${APPLICATION_EXECUTABLE} ${GLib2_LDFLAGS} ${GIO_LDFLAGS} ${LIBCLOUDPROVIDERS_LIBRARY} )
  312. ENDIF()
  313. target_include_directories(${APPLICATION_EXECUTABLE} PRIVATE
  314. ${CMAKE_SOURCE_DIR}/src/3rdparty/QProgressIndicator
  315. ${CMAKE_SOURCE_DIR}/src/3rdparty/qtlockedfile
  316. ${CMAKE_SOURCE_DIR}/src/3rdparty/qtsingleapplication
  317. ${CMAKE_SOURCE_DIR}/src/3rdparty/kmessagewidget
  318. ${CMAKE_CURRENT_BINARY_DIR}
  319. ${CMAKE_CURRENT_SOURCE_DIR}
  320. )
  321. ## handle DBUS for Fdo notifications
  322. if( UNIX AND NOT APPLE )
  323. find_package(Qt5 COMPONENTS DBus)
  324. target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::DBus)
  325. target_compile_definitions(${APPLICATION_EXECUTABLE} PRIVATE "USE_FDO_NOTIFICATIONS")
  326. endif()
  327. if (APPLE)
  328. find_package(Qt5 COMPONENTS MacExtras)
  329. target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::MacExtras)
  330. endif()
  331. if (NOT NO_SHIBBOLETH)
  332. find_package(Qt5 COMPONENTS WebKitWidgets)
  333. target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::WebKitWidgets)
  334. endif()
  335. if(WITH_CRASHREPORTER)
  336. target_link_libraries(${APPLICATION_EXECUTABLE} crashreporter-handler)
  337. if(UNIX AND NOT MAC)
  338. find_package(Threads REQUIRED)
  339. target_link_libraries( ${APPLICATION_EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
  340. endif()
  341. endif()
  342. # application.cpp still uses QDesktopServices::storageLocation
  343. target_compile_definitions(${APPLICATION_EXECUTABLE} PRIVATE "QT_DISABLE_DEPRECATED_BEFORE=0")
  344. install(TARGETS ${APPLICATION_EXECUTABLE}
  345. RUNTIME DESTINATION bin
  346. LIBRARY DESTINATION lib
  347. ARCHIVE DESTINATION lib
  348. BUNDLE DESTINATION "."
  349. )
  350. # FIXME: The following lines are dup in src/gui and src/cmd because it needs to be done after both are installed
  351. #FIXME: find a nice solution to make the second if(BUILD_OWNCLOUD_OSX_BUNDLE) unnecessary
  352. # currently it needs to be done because the code right above needs to be executed no matter
  353. # if building a bundle or not and the install_qt4_executable needs to be called afterwards
  354. #
  355. # OSX: Run macdeployqt for src/gui and for src/cmd using the -executable option
  356. if(BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY)
  357. get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
  358. get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
  359. find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${QT_BIN_DIR}")
  360. set(cmd_NAME ${APPLICATION_EXECUTABLE}cmd)
  361. if(CMAKE_BUILD_TYPE MATCHES Debug)
  362. set(NO_STRIP "-no-strip")
  363. else()
  364. set(NO_STRIP "")
  365. endif()
  366. add_custom_command(TARGET ${APPLICATION_EXECUTABLE} POST_BUILD
  367. COMMAND "${MACDEPLOYQT_EXECUTABLE}"
  368. "$<TARGET_FILE_DIR:${APPLICATION_EXECUTABLE}>/../.."
  369. -qmldir=${CMAKE_SOURCE_DIR}/src/gui
  370. -always-overwrite
  371. -executable="$<TARGET_FILE_DIR:${APPLICATION_EXECUTABLE}>/${cmd_NAME}"
  372. ${NO_STRIP}
  373. COMMENT "Running macdeployqt..."
  374. )
  375. endif()
  376. if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT WIN32)
  377. configure_file(${CMAKE_SOURCE_DIR}/mirall.desktop.in
  378. ${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop)
  379. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop DESTINATION ${DATADIR}/applications )
  380. endif()