CMakeLists.txt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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}/OWNCLOUD.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. if (NOT DEFINED APPLICATION_SHORTNAME)
  21. set ( APPLICATION_SHORTNAME ${APPLICATION_NAME} )
  22. endif()
  23. # For usage in XML files we preprocess
  24. string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}")
  25. string(REPLACE "<" "&lt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
  26. string(REPLACE ">" "&gt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
  27. set(PACKAGE "${APPLICATION_SHORTNAME}-client")
  28. set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
  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. include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
  35. # disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
  36. if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
  37. set( WITH_CRASHREPORTER OFF )
  38. endif()
  39. if(NOT WITH_CRASHREPORTER)
  40. message(STATUS "Build of crashreporter disabled.")
  41. endif()
  42. #####
  43. ## handle DBUS for Fdo notifications
  44. if( UNIX AND NOT APPLE )
  45. add_definitions( -DUSE_FDO_NOTIFICATIONS)
  46. set(WITH_DBUS ON)
  47. endif()
  48. ####
  49. include(GNUInstallDirs)
  50. include(DefineInstallationPaths)
  51. include(GenerateExportHeader)
  52. include(GetGitRevisionDescription)
  53. get_git_head_revision(GIT_REFSPEC GIT_SHA1)
  54. # if we cannot get it from git, directly try .tag (packages)
  55. # this will work if the tar balls have been properly created
  56. # via git-archive.
  57. if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
  58. file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
  59. string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
  60. if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
  61. message("${sha1_candidate}")
  62. set (GIT_SHA1 "${sha1_candidate}")
  63. endif()
  64. endif()
  65. message(STATUS "GIT_SHA1 ${GIT_SHA1}")
  66. set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
  67. set(DATADIR ${DATA_INSTALL_DIR})
  68. if(WIN32)
  69. set(DATADIR "share")
  70. endif(WIN32)
  71. set(SHAREDIR ${DATADIR})
  72. #####
  73. ## handle BUILD_OWNCLOUD_OSX_BUNDLE
  74. # BUILD_OWNCLOUD_OSX_BUNDLE was not initialized OR set to true on OSX
  75. if(APPLE AND (NOT DEFINED BUILD_OWNCLOUD_OSX_BUNDLE OR BUILD_OWNCLOUD_OSX_BUNDLE))
  76. set(BUILD_OWNCLOUD_OSX_BUNDLE ON)
  77. set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_EXECUTABLE}.app")
  78. set(LIB_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
  79. set(BIN_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
  80. # BUILD_OWNCLOUD_OSX_BUNDLE was disabled on OSX
  81. elseif(APPLE AND NOT BUILD_OWNCLOUD_OSX_BUNDLE)
  82. 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.")
  83. # any other platform
  84. else()
  85. set(BUILD_OWNCLOUD_OSX_BUNDLE OFF)
  86. endif()
  87. #####
  88. # this option removes Http authentication, keychain, shibboleth etc and is intended for
  89. # external authentication mechanisms
  90. option(TOKEN_AUTH_ONLY "TOKEN_AUTH_ONLY" OFF)
  91. if(TOKEN_AUTH_ONLY)
  92. message("Compiling with token authentication")
  93. add_definitions(-DTOKEN_AUTH_ONLY=1)
  94. endif()
  95. option(NO_MSG_HANDLER "Don't redirect QDebug outputs to the log window/file" OFF)
  96. if(NO_MSG_HANDLER)
  97. add_definitions(-DNO_MSG_HANDLER=1)
  98. endif()
  99. # this option creates only libocsync and libowncloudsync
  100. option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)
  101. # When this option is enabled, 5xx errors are not added to the blacklist
  102. # Normally you don't want to enable this option because if a particular file
  103. # triggers a bug on the server, you want the file to be blacklisted.
  104. option(OWNCLOUD_5XX_NO_BLACKLIST "OWNCLOUD_5XX_NO_BLACKLIST" OFF)
  105. if(OWNCLOUD_5XX_NO_BLACKLIST)
  106. add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
  107. endif()
  108. # When this option is enabled, a rename that is not allowed will be renamed back
  109. # do the original as a restoration step. Withut this option, the restoration will
  110. # re-download the file instead.
  111. # The default is off because we don't want to rename the files back behind the user's back
  112. # Added for IL issue #550
  113. option(OWNCLOUD_RESTORE_RENAME "OWNCLOUD_RESTORE_RENAME" OFF)
  114. if(OWNCLOUD_RESTORE_RENAME)
  115. add_definitions(-DOWNCLOUD_RESTORE_RENAME=1)
  116. endif()
  117. # Disable shibboleth.
  118. # So the client can be built without QtWebKit
  119. option(NO_SHIBBOLETH "Build without Shibboleth support. Allow to build the client without QtWebKit" OFF)
  120. if(NO_SHIBBOLETH)
  121. message("Compiling without shibboleth")
  122. add_definitions(-DNO_SHIBBOLETH=1)
  123. endif()
  124. if(APPLE)
  125. set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
  126. endif()
  127. find_package(OpenSSL 1.0.0 REQUIRED)
  128. if(APPLE)
  129. find_package(Sparkle)
  130. endif(APPLE)
  131. if(UNIX)
  132. find_package(INotify REQUIRED)
  133. else()
  134. find_package(INotify)
  135. endif()
  136. find_package(Sphinx)
  137. find_package(PdfLatex)
  138. find_package(SQLite3 3.8.0 REQUIRED)
  139. # On some OS, we want to use our own, not the system sqlite
  140. if (USE_OUR_OWN_SQLITE3)
  141. include_directories(BEFORE ${SQLITE3_INCLUDE_DIR})
  142. if (WIN32)
  143. add_definitions(-DSQLITE_API=__declspec\(dllimport\))
  144. endif()
  145. endif()
  146. find_package(ZLIB)
  147. configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  148. configure_file(test/test_journal.db "${CMAKE_BINARY_DIR}/test/test_journal.db" COPYONLY)
  149. include(OwnCloudCPack.cmake)
  150. add_definitions(-DUNICODE)
  151. add_definitions(-D_UNICODE)
  152. if( WIN32 )
  153. add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
  154. add_definitions( -DNOMINMAX )
  155. endif( WIN32 )
  156. # Handle Translations, pick all client_* files from trans directory.
  157. file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
  158. set(TRANSLATIONS ${TRANS_FILES})
  159. add_subdirectory(csync)
  160. add_subdirectory(src)
  161. if(NOT BUILD_LIBRARIES_ONLY)
  162. add_subdirectory(shell_integration)
  163. add_subdirectory(doc)
  164. add_subdirectory(doc/dev)
  165. add_subdirectory(admin)
  166. endif(NOT BUILD_LIBRARIES_ONLY)
  167. if(UNIT_TESTING)
  168. include(CTest)
  169. enable_testing()
  170. add_subdirectory(test)
  171. endif(UNIT_TESTING)
  172. if(BUILD_OWNCLOUD_OSX_BUNDLE)
  173. install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
  174. configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
  175. else()
  176. install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
  177. configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
  178. endif()