CMakeLists.txt 8.8 KB

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