CMakeLists.txt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. cmake_minimum_required(VERSION 2.6)
  2. cmake_policy(VERSION 2.8.0)
  3. project(client)
  4. set(OEM_THEME_DIR "" CACHE STRING "Define directory containing a custom theme")
  5. if ( EXISTS ${OEM_THEME_DIR}/OEM.cmake )
  6. include ( ${OEM_THEME_DIR}/OEM.cmake )
  7. else ()
  8. include ( ${CMAKE_SOURCE_DIR}/OWNCLOUD.cmake )
  9. endif()
  10. # need this logic to not mess with re/uninstallations via macosx.pkgproj
  11. if(${APPLICATION_REV_DOMAIN} STREQUAL "com.owncloud.desktopclient")
  12. set(APPLICATION_REV_DOMAIN_INSTALLER "com.ownCloud.client")
  13. else()
  14. set(APPLICATION_REV_DOMAIN_INSTALLER ${APPLICATION_REV_DOMAIN})
  15. endif()
  16. if (NOT DEFINED APPLICATION_SHORTNAME)
  17. set ( APPLICATION_SHORTNAME ${APPLICATION_NAME} )
  18. endif()
  19. set(PACKAGE "${APPLICATION_SHORTNAME}-client")
  20. set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
  21. if(NOT CRASHREPORTER_EXECUTABLE)
  22. set(CRASHREPORTER_EXECUTABLE "${APPLICATION_EXECUTABLE}_crash_reporter")
  23. endif()
  24. include(Warnings)
  25. include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
  26. include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/src/mirall/")
  27. # disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
  28. if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
  29. set( WITH_CRASHREPORTER OFF )
  30. endif()
  31. if(NOT WITH_CRASHREPORTER)
  32. message(STATUS "Build of crashreporter disabled.")
  33. endif()
  34. #####
  35. ## handle DBUS for Fdo notifications
  36. if( UNIX AND NOT APPLE )
  37. add_definitions( -DUSE_FDO_NOTIFICATIONS)
  38. set(WITH_DBUS ON)
  39. endif()
  40. ####
  41. include(GNUInstallDirs)
  42. include(DefineInstallationPaths)
  43. include(QtVersionAbstraction)
  44. setup_qt()
  45. include(GetGitRevisionDescription)
  46. get_git_head_revision(GIT_REFSPEC GIT_SHA1)
  47. # if we cannot get it from git, directly try .tag (packages)
  48. # this will work if the tar balls have been properly created
  49. # via git-archive.
  50. if (${GIT_SHA1} STREQUAL "GITDIR-NOTFOUND")
  51. file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
  52. string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
  53. if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
  54. message("${sha1_candidate}")
  55. set (GIT_SHA1 "${sha1_candidate}")
  56. endif()
  57. endif()
  58. message(STATUS "GIT_SHA1 ${GIT_SHA1}")
  59. set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
  60. set(DATADIR ${DATA_INSTALL_DIR})
  61. if(WIN32)
  62. set(DATADIR "share")
  63. endif(WIN32)
  64. set(SHAREDIR ${DATADIR})
  65. #####
  66. ## handle BUILD_OWNCLOUD_OSX_BUNDLE
  67. # BUILD_OWNCLOUD_OSX_BUNDLE was not initialized OR set to true on OSX
  68. if(APPLE AND (NOT DEFINED BUILD_OWNCLOUD_OSX_BUNDLE OR BUILD_OWNCLOUD_OSX_BUNDLE))
  69. set(BUILD_OWNCLOUD_OSX_BUNDLE ON)
  70. set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_EXECUTABLE}.app")
  71. set(LIB_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
  72. set(BIN_INSTALL_DIR "${APPLICATION_EXECUTABLE}.app/Contents/MacOS")
  73. # BUILD_OWNCLOUD_OSX_BUNDLE was disabled on OSX
  74. elseif(APPLE AND NOT BUILD_OWNCLOUD_OSX_BUNDLE)
  75. 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.")
  76. # any other platform
  77. else()
  78. set(BUILD_OWNCLOUD_OSX_BUNDLE OFF)
  79. endif()
  80. #####
  81. # this option removes Http authentication, keychain, shibboleth etc and is intended for
  82. # external authentication mechanisms
  83. option(TOKEN_AUTH_ONLY "TOKEN_AUTH_ONLY" OFF)
  84. if(TOKEN_AUTH_ONLY)
  85. message("Compiling with token authentication")
  86. add_definitions(-DTOKEN_AUTH_ONLY=1)
  87. endif()
  88. option(NO_MSG_HANDLER "Don't redirect QDebug outputs to the log window/file" OFF)
  89. if(NO_MSG_HANDLER)
  90. add_definitions(-DNO_MSG_HANDLER=1)
  91. endif()
  92. # this option creates only libocsync and libowncloudsync
  93. option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)
  94. # When this option is enabled, 5xx errors are not added to the blacklist
  95. # Normally you don't want to enable this option because if a particular file
  96. # triggers a bug on the server, you want the file to be blacklisted.
  97. option(OWNCLOUD_5XX_NO_BLACKLIST "OWNCLOUD_5XX_NO_BLACKLIST" OFF)
  98. if(OWNCLOUD_5XX_NO_BLACKLIST)
  99. add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
  100. endif()
  101. if(APPLE)
  102. set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
  103. endif()
  104. #### find libs
  105. #find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED )
  106. #if( UNIX AND NOT APPLE ) # Fdo notifications
  107. # find_package(Qt4 4.7.0 COMPONENTS QtDBus REQUIRED )
  108. #endif()
  109. if(HAVE_QT5)
  110. if (${Qt5Core_VERSION_MAJOR} EQUAL "5")
  111. if (${Qt5Core_VERSION_MINOR} EQUAL "4" OR ${Qt5Core_VERSION_MINOR} GREATER 4)
  112. else()
  113. message(STATUS "If possible compile me with Qt 5.4 or higher.")
  114. endif()
  115. endif()
  116. else()
  117. message(STATUS "If possible compile me with Qt 5.4 or higher.")
  118. endif()
  119. find_package(OpenSSL 1.0.0 REQUIRED)
  120. if(NOT TOKEN_AUTH_ONLY)
  121. if (Qt5Core_DIR)
  122. find_package(Qt5Keychain REQUIRED)
  123. else()
  124. find_package(QtKeychain REQUIRED)
  125. endif()
  126. endif()
  127. if(APPLE)
  128. find_package(Sparkle)
  129. endif(APPLE)
  130. if(UNIX)
  131. find_package(INotify REQUIRED)
  132. else()
  133. find_package(INotify)
  134. endif()
  135. find_package(Sphinx)
  136. find_package(PdfLatex)
  137. find_package(SQLite3 3.8.0 REQUIRED)
  138. # On some OS, we want to use our own, not the system sqlite
  139. if (USE_OUR_OWN_SQLITE3)
  140. include_directories(BEFORE ${SQLITE3_INCLUDE_DIR})
  141. endif()
  142. find_package(ZLIB)
  143. configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  144. configure_file(test/test_journal.db "${CMAKE_BINARY_DIR}/test/test_journal.db" COPYONLY)
  145. include(OwnCloudCPack.cmake)
  146. add_definitions(-DUNICODE)
  147. add_definitions(-D_UNICODE)
  148. if( WIN32 )
  149. add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
  150. endif( WIN32 )
  151. # Handle Translations, pick all client_* files from trans directory.
  152. file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
  153. set(TRANSLATIONS ${TRANS_FILES})
  154. add_subdirectory(csync)
  155. add_subdirectory(src)
  156. if(NOT BUILD_LIBRARIES_ONLY)
  157. add_subdirectory(shell_integration)
  158. add_subdirectory(doc)
  159. add_subdirectory(doc/dev)
  160. add_subdirectory(admin)
  161. endif(NOT BUILD_LIBRARIES_ONLY)
  162. if(UNIT_TESTING)
  163. include(CTest)
  164. enable_testing()
  165. add_subdirectory(test)
  166. endif(UNIT_TESTING)
  167. if(BUILD_OWNCLOUD_OSX_BUNDLE)
  168. install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
  169. configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
  170. else()
  171. install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
  172. configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
  173. endif()