CMakeLists.txt 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. cmake_minimum_required(VERSION 3.16)
  2. set(CMAKE_CXX_STANDARD 17)
  3. cmake_policy(SET CMP0071 NEW) # Enable use of QtQuick compiler/generated code
  4. project(client)
  5. include(FeatureSummary)
  6. set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  7. include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake)
  8. # CfAPI Shell Extensions
  9. set( CFAPI_SHELL_EXTENSIONS_LIB_NAME CfApiShellExtensions )
  10. set( CFAPI_SHELLEXT_APPID_REG "{E314A650-DCA4-416E-974E-18EA37C213EA}")
  11. set( CFAPI_SHELLEXT_APPID_DISPLAY_NAME "${APPLICATION_NAME} CfApi Shell Extensions" )
  12. set( CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_CLASS_ID "1E62D59A-6EA4-476C-B707-4A32E88ED822" )
  13. set( CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_CLASS_ID_REG "{${CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_CLASS_ID}}" )
  14. set( CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_DISPLAY_NAME "${APPLICATION_NAME} Custom State Handler" )
  15. set( CFAPI_SHELLEXT_THUMBNAIL_HANDLER_CLASS_ID "6FF9B5B6-389F-444A-9FDD-A286C36EA079" )
  16. set( CFAPI_SHELLEXT_THUMBNAIL_HANDLER_CLASS_ID_REG "{${CFAPI_SHELLEXT_THUMBNAIL_HANDLER_CLASS_ID}}" )
  17. set( CFAPI_SHELLEXT_THUMBNAIL_HANDLER_DISPLAY_NAME "${APPLICATION_NAME} Thumbnail Handler" )
  18. # URI Handler Scheme for Local File Editing
  19. set( APPLICATION_URI_HANDLER_SCHEME "nc")
  20. # Default suffix if the theme doesn't define one
  21. if(NOT DEFINED APPLICATION_VIRTUALFILE_SUFFIX)
  22. set(APPLICATION_VIRTUALFILE_SUFFIX "${APPLICATION_SHORTNAME}_virtual" CACHE STRING "Virtual file suffix (not including the .)")
  23. endif()
  24. # need this logic to not mess with re/uninstallations via macosx.pkgproj
  25. if(${APPLICATION_REV_DOMAIN} STREQUAL "com.owncloud.desktopclient")
  26. set(APPLICATION_REV_DOMAIN_INSTALLER "com.ownCloud.client")
  27. else()
  28. set(APPLICATION_REV_DOMAIN_INSTALLER ${APPLICATION_REV_DOMAIN})
  29. endif()
  30. # For usage in XML files we preprocess
  31. string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}")
  32. string(REPLACE "<" "&lt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
  33. string(REPLACE ">" "&gt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
  34. if (NOT DEFINED LINUX_PACKAGE_SHORTNAME)
  35. set(LINUX_PACKAGE_SHORTNAME "${APPLICATION_SHORTNAME}")
  36. endif()
  37. if (NOT DEFINED PACKAGE)
  38. set(PACKAGE "${LINUX_PACKAGE_SHORTNAME}-client")
  39. endif()
  40. set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
  41. include(ECMCoverageOption)
  42. if(NOT CRASHREPORTER_EXECUTABLE)
  43. set(CRASHREPORTER_EXECUTABLE "${APPLICATION_EXECUTABLE}_crash_reporter")
  44. endif()
  45. include(Warnings)
  46. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  47. add_compile_options(-fdiagnostics-color=always)
  48. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  49. add_compile_options(-fcolor-diagnostics)
  50. endif()
  51. include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
  52. # For config.h
  53. include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
  54. # Allows includes based on src/ like #include "common/utility.h" or #include "csync/csync.h"
  55. include_directories(
  56. ${CMAKE_CURRENT_SOURCE_DIR}/src
  57. ${CMAKE_CURRENT_BINARY_DIR}/src
  58. )
  59. # disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
  60. if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
  61. set( WITH_CRASHREPORTER OFF )
  62. endif()
  63. if(NOT WITH_CRASHREPORTER)
  64. message(STATUS "Build of crashreporter disabled.")
  65. endif()
  66. include(GNUInstallDirs)
  67. include(DefineInstallationPaths)
  68. include(GenerateExportHeader)
  69. include(GetGitRevisionDescription)
  70. get_git_head_revision(GIT_REFSPEC GIT_SHA1)
  71. add_definitions(
  72. -DQT_DISABLE_DEPRECATED_BEFORE=0x000000
  73. -DQT_USE_QSTRINGBUILDER
  74. -DQT_MESSAGELOGCONTEXT #enable function name and line number in debug output
  75. )
  76. # if we cannot get it from git, directly try .tag (packages)
  77. # this will work if the tar balls have been properly created
  78. # via git-archive.
  79. if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
  80. file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
  81. string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
  82. if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
  83. message("${sha1_candidate}")
  84. set (GIT_SHA1 "${sha1_candidate}")
  85. endif()
  86. endif()
  87. message(STATUS "GIT_SHA1 ${GIT_SHA1}")
  88. set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
  89. set(SHAREDIR ${CMAKE_INSTALL_FULL_DATADIR})
  90. # Build MacOS app bundle if wished
  91. if(APPLE AND BUILD_OWNCLOUD_OSX_BUNDLE)
  92. message(STATUS "Build MacOS app bundle")
  93. set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_NAME}.app")
  94. set(LIB_INSTALL_DIR "${APPLICATION_NAME}.app/Contents/MacOS")
  95. set(BIN_INSTALL_DIR "${APPLICATION_NAME}.app/Contents/MacOS")
  96. add_definitions(-DBUILD_OWNCLOUD_OSX_BUNDLE)
  97. endif()
  98. option(QUICK_COMPILER "Use QtQuick compiler to improve performance" OFF)
  99. # this option removes Http authentication, keychain, shibboleth etc and is intended for
  100. # external authentication mechanisms
  101. option(TOKEN_AUTH_ONLY "TOKEN_AUTH_ONLY" OFF)
  102. if(TOKEN_AUTH_ONLY)
  103. message("Compiling with token authentication")
  104. add_definitions(-DTOKEN_AUTH_ONLY=1)
  105. endif()
  106. option(NO_MSG_HANDLER "Don't redirect QDebug outputs to the log window/file" OFF)
  107. if(NO_MSG_HANDLER)
  108. add_definitions(-DNO_MSG_HANDLER=1)
  109. endif()
  110. if(BUILD_UPDATER)
  111. message("Compiling with updater")
  112. else()
  113. message("Compiling without updater")
  114. endif()
  115. # this option builds the shell integration
  116. option(BUILD_SHELL_INTEGRATION "BUILD_SHELL_INTEGRATION" ON)
  117. # this option builds/installs the generic shell integration icons
  118. option(BUILD_SHELL_INTEGRATION_ICONS "BUILD_SHELL_INTEGRATION_ICONS" ON)
  119. # this options builds the dolphin integration plugin
  120. option(BUILD_SHELL_INTEGRATION_DOLPHIN "BUILD_SHELL_INTEGRATION_DOLPHIN" ON)
  121. # this options builds the nautilus (like) integration plugins
  122. option(BUILD_SHELL_INTEGRATION_NAUTILUS "BUILD_SHELL_INTEGRATION_NAUTILUS" ON)
  123. # this option builds the client
  124. option(BUILD_CLIENT "BUILD_CLIENT" ON)
  125. # this option creates only libocsync and libowncloudsync (NOTE: BUILD_CLIENT needs to be on)
  126. option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)
  127. # build the GUI component, when disabled only nextcloudcmd is built
  128. option(BUILD_GUI "BUILD_GUI" ON)
  129. # When this option is enabled, 5xx errors are not added to the blacklist
  130. # Normally you don't want to enable this option because if a particular file
  131. # triggers a bug on the server, you want the file to be blacklisted.
  132. option(OWNCLOUD_5XX_NO_BLACKLIST "OWNCLOUD_5XX_NO_BLACKLIST" OFF)
  133. if(OWNCLOUD_5XX_NO_BLACKLIST)
  134. add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
  135. endif()
  136. if(APPLE)
  137. set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
  138. endif()
  139. if(BUILD_CLIENT)
  140. OPTION(GUI_TESTING "Build with gui introspection features of socket api" OFF)
  141. if(APPLE AND BUILD_UPDATER)
  142. find_package(Sparkle)
  143. endif()
  144. if(UNIX AND NOT APPLE)
  145. find_package(Inotify REQUIRED)
  146. endif()
  147. find_package(Sphinx)
  148. find_package(PdfLatex)
  149. find_package(OpenSSL 1.1 REQUIRED )
  150. find_package(ZLIB REQUIRED)
  151. if(NOT WIN32 AND NOT APPLE)
  152. find_package(PkgConfig REQUIRED)
  153. pkg_check_modules(CLOUDPROVIDERS cloudproviders IMPORTED_TARGET)
  154. if(CLOUDPROVIDERS_FOUND)
  155. pkg_check_modules(DBUS-1 REQUIRED dbus-1 IMPORTED_TARGET)
  156. pkg_check_modules(GIO REQUIRED gio-2.0 IMPORTED_TARGET)
  157. pkg_check_modules(GLIB2 REQUIRED glib-2.0 IMPORTED_TARGET)
  158. endif()
  159. endif()
  160. endif()
  161. if (NOT DEFINED APPLICATION_ICON_NAME)
  162. set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME})
  163. endif()
  164. include(NextcloudCPack.cmake)
  165. add_definitions(-DUNICODE)
  166. add_definitions(-D_UNICODE)
  167. if( WIN32 )
  168. add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
  169. add_definitions( -DNOMINMAX )
  170. # Get APIs from from Vista onwards.
  171. add_definitions(-D_WIN32_WINNT=0x0601)
  172. add_definitions(-DWINVER=0x0601)
  173. add_definitions(-DNTDDI_VERSION=0x0A000004)
  174. if( MSVC )
  175. # Use automatic overload for suitable CRT safe-functions
  176. # See https://docs.microsoft.com/de-de/cpp/c-runtime-library/security-features-in-the-crt?view=vs-2019
  177. add_definitions( -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 )
  178. # Also: Disable compiler warnings because we don't use Windows CRT safe-functions explicitly and don't intend to
  179. # as this is a pure cross-platform source the only alternative would be a ton of ifdefs with calls to the _s version
  180. add_definitions( -D_CRT_SECURE_NO_WARNINGS )
  181. endif( MSVC )
  182. endif( WIN32 )
  183. if (APPLE)
  184. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
  185. endif()
  186. # Handle Translations, pick all client_* files from trans directory.
  187. file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
  188. set(TRANSLATIONS ${TRANS_FILES})
  189. if(BUILD_CLIENT)
  190. add_subdirectory(src)
  191. if(NOT BUILD_LIBRARIES_ONLY)
  192. add_subdirectory(man)
  193. add_subdirectory(doc)
  194. add_subdirectory(doc/dev)
  195. if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/admin)
  196. add_subdirectory(admin)
  197. endif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/admin)
  198. endif(NOT BUILD_LIBRARIES_ONLY)
  199. endif()
  200. if(BUILD_SHELL_INTEGRATION)
  201. add_subdirectory(shell_integration)
  202. endif()
  203. if(BUILD_TESTING)
  204. include(CTest)
  205. enable_testing()
  206. add_subdirectory(test)
  207. endif()
  208. configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  209. configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
  210. if(BUILD_OWNCLOUD_OSX_BUNDLE)
  211. install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
  212. configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
  213. elseif(BUILD_CLIENT)
  214. install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
  215. configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
  216. endif()
  217. feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)