CMakeLists.txt 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. cmake_minimum_required(VERSION 3.2)
  2. set(CMAKE_CXX_STANDARD 14)
  3. project(client)
  4. set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  5. set(OEM_THEME_DIR "" CACHE STRING "Define directory containing a custom theme")
  6. if ( EXISTS ${OEM_THEME_DIR}/OEM.cmake )
  7. include ( ${OEM_THEME_DIR}/OEM.cmake )
  8. else ()
  9. include ( ${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake )
  10. endif()
  11. # need this logic to not mess with re/uninstallations via macosx.pkgproj
  12. if(${APPLICATION_REV_DOMAIN} STREQUAL "com.owncloud.desktopclient")
  13. set(APPLICATION_REV_DOMAIN_INSTALLER "com.ownCloud.client")
  14. else()
  15. set(APPLICATION_REV_DOMAIN_INSTALLER ${APPLICATION_REV_DOMAIN})
  16. endif()
  17. # For usage in XML files we preprocess
  18. string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}")
  19. string(REPLACE "<" "&lt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
  20. string(REPLACE ">" "&gt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
  21. if (NOT DEFINED LINUX_PACKAGE_SHORTNAME)
  22. set(LINUX_PACKAGE_SHORTNAME "${APPLICATION_SHORTNAME}")
  23. endif()
  24. if (NOT DEFINED PACKAGE)
  25. set(PACKAGE "${LINUX_PACKAGE_SHORTNAME}-client")
  26. endif()
  27. set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
  28. if(NOT CRASHREPORTER_EXECUTABLE)
  29. set(CRASHREPORTER_EXECUTABLE "${APPLICATION_EXECUTABLE}_crash_reporter")
  30. endif()
  31. include(Warnings)
  32. include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
  33. # For config.h
  34. include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
  35. # Allows includes based on src/ like #include "common/utility.h" or #include "csync/csync.h"
  36. include_directories(
  37. ${CMAKE_CURRENT_SOURCE_DIR}/src
  38. ${CMAKE_CURRENT_BINARY_DIR}/src
  39. )
  40. # disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
  41. if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
  42. set( WITH_CRASHREPORTER OFF )
  43. endif()
  44. if(NOT WITH_CRASHREPORTER)
  45. message(STATUS "Build of crashreporter disabled.")
  46. endif()
  47. include(GNUInstallDirs)
  48. include(DefineInstallationPaths)
  49. include(GenerateExportHeader)
  50. include(GetGitRevisionDescription)
  51. get_git_head_revision(GIT_REFSPEC GIT_SHA1)
  52. add_definitions(
  53. -DQT_USE_QSTRINGBUILDER
  54. -DQT_MESSAGELOGCONTEXT #enable function name and line number in debug output
  55. -DQT_DEPRECATED_WARNINGS
  56. )
  57. # if we cannot get it from git, directly try .tag (packages)
  58. # this will work if the tar balls have been properly created
  59. # via git-archive.
  60. if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
  61. file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
  62. string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
  63. if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
  64. message("${sha1_candidate}")
  65. set (GIT_SHA1 "${sha1_candidate}")
  66. endif()
  67. endif()
  68. message(STATUS "GIT_SHA1 ${GIT_SHA1}")
  69. set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
  70. set(DATADIR ${DATA_INSTALL_DIR})
  71. if(WIN32)
  72. set(DATADIR "share")
  73. endif(WIN32)
  74. set(SHAREDIR ${DATADIR})
  75. #####
  76. ## handle BUILD_OWNCLOUD_OSX_BUNDLE
  77. # BUILD_OWNCLOUD_OSX_BUNDLE was not initialized OR set to true on OSX
  78. if(APPLE AND (NOT DEFINED BUILD_OWNCLOUD_OSX_BUNDLE OR BUILD_OWNCLOUD_OSX_BUNDLE))
  79. set(BUILD_OWNCLOUD_OSX_BUNDLE ON)
  80. set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_EXECUTABLE}.app")
  81. set(LIB_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
  82. set(BIN_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
  83. # BUILD_OWNCLOUD_OSX_BUNDLE was disabled on OSX
  84. elseif(APPLE AND NOT BUILD_OWNCLOUD_OSX_BUNDLE)
  85. message(FATAL_ERROR "Building in non-bundle mode on OSX is currently not supported. Comment this error out if you want to work on/test it.")
  86. # any other platform
  87. else()
  88. set(BUILD_OWNCLOUD_OSX_BUNDLE OFF)
  89. endif()
  90. #####
  91. # this option removes Http authentication, keychain, shibboleth etc and is intended for
  92. # external authentication mechanisms
  93. option(TOKEN_AUTH_ONLY "TOKEN_AUTH_ONLY" OFF)
  94. if(TOKEN_AUTH_ONLY)
  95. message("Compiling with token authentication")
  96. add_definitions(-DTOKEN_AUTH_ONLY=1)
  97. endif()
  98. option(NO_MSG_HANDLER "Don't redirect QDebug outputs to the log window/file" OFF)
  99. if(NO_MSG_HANDLER)
  100. add_definitions(-DNO_MSG_HANDLER=1)
  101. endif()
  102. # this option builds the updater
  103. option(BUILD_UPDATER "BUILD_UPDATER" OFF)
  104. if(BUILD_UPDATER)
  105. message("Compiling with updater")
  106. add_definitions(-DBUILD_UPDATER=1)
  107. else()
  108. message("Compiling without updater")
  109. endif()
  110. # this option builds the shell integration
  111. option(BUILD_SHELL_INTEGRATION "BUILD_SHELL_INTEGRATION" ON)
  112. # this option builds/installs the generic shell integration icons
  113. option(BUILD_SHELL_INTEGRATION_ICONS "BUILD_SHELL_INTEGRATION_ICONS" ON)
  114. # this options builds the dolphin integration plugin
  115. option(BUILD_SHELL_INTEGRATION_DOLPHIN "BUILD_SHELL_INTEGRATION_DOLPHIN" ON)
  116. # this options builds the nautilus (like) integration plugins
  117. option(BUILD_SHELL_INTEGRATION_NAUTILUS "BUILD_SHELL_INTEGRATION_NAUTILUS" ON)
  118. # this option builds the client
  119. option(BUILD_CLIENT "BUILD_CLIENT" ON)
  120. # this option creates only libocsync and libowncloudsync (NOTE: BUILD_CLIENT needs to be on)
  121. option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)
  122. # When this option is enabled, 5xx errors are not added to the blacklist
  123. # Normally you don't want to enable this option because if a particular file
  124. # triggers a bug on the server, you want the file to be blacklisted.
  125. option(OWNCLOUD_5XX_NO_BLACKLIST "OWNCLOUD_5XX_NO_BLACKLIST" OFF)
  126. if(OWNCLOUD_5XX_NO_BLACKLIST)
  127. add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
  128. endif()
  129. # When this option is enabled, a rename that is not allowed will be renamed back
  130. # do the original as a restoration step. Withut this option, the restoration will
  131. # re-download the file instead.
  132. # The default is off because we don't want to rename the files back behind the user's back
  133. # Added for IL issue #550
  134. option(OWNCLOUD_RESTORE_RENAME "OWNCLOUD_RESTORE_RENAME" OFF)
  135. if(OWNCLOUD_RESTORE_RENAME)
  136. add_definitions(-DOWNCLOUD_RESTORE_RENAME=1)
  137. endif()
  138. # Disable shibboleth.
  139. # So the client can be built without QtWebKit
  140. option(NO_SHIBBOLETH "Build without Shibboleth support. Allow to build the client without QtWebKit" OFF)
  141. if(NO_SHIBBOLETH)
  142. message("Compiling without shibboleth")
  143. add_definitions(-DNO_SHIBBOLETH=1)
  144. endif()
  145. if(APPLE)
  146. set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
  147. endif()
  148. if(BUILD_CLIENT)
  149. if(APPLE AND BUILD_UPDATER)
  150. find_package(Sparkle)
  151. endif()
  152. if(UNIX)
  153. find_package(INotify REQUIRED)
  154. else()
  155. find_package(INotify)
  156. endif()
  157. find_package(Sphinx)
  158. find_package(PdfLatex)
  159. find_package(OpenSSL 1.1 REQUIRED )
  160. find_package(ZLIB REQUIRED)
  161. find_package(GLib2)
  162. find_package(Gio)
  163. find_package(Libcloudproviders)
  164. endif()
  165. if (NOT DEFINED APPLICATION_ICON_NAME)
  166. set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME})
  167. endif()
  168. include(NextcloudCPack.cmake)
  169. add_definitions(-DUNICODE)
  170. add_definitions(-D_UNICODE)
  171. if( WIN32 )
  172. add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
  173. add_definitions( -DNOMINMAX )
  174. # Get APIs from from Vista onwards.
  175. add_definitions( -D_WIN32_WINNT=0x0601 )
  176. add_definitions( -DWINVER=0x0601 )
  177. if( MSVC )
  178. # Use automatic overload for suitable CRT safe-functions
  179. # See https://docs.microsoft.com/de-de/cpp/c-runtime-library/security-features-in-the-crt?view=vs-2019
  180. add_definitions( -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 )
  181. # Also: Disable compiler warnings because we don't use Windows CRT safe-functions explicitly and don't intend to
  182. # as this is a pure cross-platform source the only alternative would be a ton of ifdefs with calls to the _s version
  183. add_definitions( -D_CRT_SECURE_NO_WARNINGS )
  184. endif( MSVC )
  185. endif( WIN32 )
  186. if (APPLE)
  187. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
  188. endif()
  189. include(SanitizerFlags)
  190. # Handle Translations, pick all client_* files from trans directory.
  191. file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
  192. set(TRANSLATIONS ${TRANS_FILES})
  193. if(BUILD_CLIENT)
  194. add_subdirectory(src)
  195. if(NOT BUILD_LIBRARIES_ONLY)
  196. add_subdirectory(man)
  197. add_subdirectory(doc)
  198. add_subdirectory(doc/dev)
  199. if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/admin)
  200. add_subdirectory(admin)
  201. endif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/admin)
  202. endif(NOT BUILD_LIBRARIES_ONLY)
  203. endif()
  204. if(BUILD_SHELL_INTEGRATION)
  205. add_subdirectory(shell_integration)
  206. endif()
  207. if(UNIT_TESTING)
  208. include(CTest)
  209. enable_testing()
  210. add_subdirectory(test)
  211. endif(UNIT_TESTING)
  212. configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  213. configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
  214. if(BUILD_OWNCLOUD_OSX_BUNDLE)
  215. install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
  216. configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
  217. elseif(BUILD_CLIENT)
  218. install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
  219. configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
  220. endif()