CMakeLists.txt 9.0 KB

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