2021-08-25 13:20:31 +03:00
cmake_minimum_required(VERSION 3.16)
2022-08-03 16:13:28 +03:00
set(CMAKE_CXX_STANDARD 17)
2021-12-29 19:44:40 +03:00
cmake_policy(SET CMP0071 NEW) # Enable use of QtQuick compiler/generated code
2014-08-01 12:54:04 +04:00
2023-02-15 11:23:50 +03:00
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if (CLANG_TIDY_EXE)
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE} -checks=-*,modernize-use-auto,modernize-use-using,modernize-use-nodiscard,modernize-use-nullptr,modernize-use-override,cppcoreguidelines-pro-type-static-cast-downcast,modernize-use-default-member-init,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-init-variables)
endif()
2014-11-10 00:30:05 +03:00
project(client)
2013-08-07 14:36:45 +04:00
2021-04-14 10:08:17 +03:00
include(FeatureSummary)
2024-01-23 12:02:42 +03:00
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)
2017-02-07 21:31:55 +03:00
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
2021-06-02 18:13:40 +03:00
include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake)
2018-04-20 15:57:21 +03:00
2022-08-03 14:42:09 +03:00
# CfAPI Shell Extensions
set( CFAPI_SHELL_EXTENSIONS_LIB_NAME CfApiShellExtensions )
set( CFAPI_SHELLEXT_APPID_REG "{E314A650-DCA4-416E-974E-18EA37C213EA}")
set( CFAPI_SHELLEXT_APPID_DISPLAY_NAME "${APPLICATION_NAME} CfApi Shell Extensions" )
2022-09-02 12:48:52 +03:00
set( CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_CLASS_ID "1E62D59A-6EA4-476C-B707-4A32E88ED822" )
set( CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_CLASS_ID_REG "{${CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_CLASS_ID}}" )
set( CFAPI_SHELLEXT_CUSTOM_STATE_HANDLER_DISPLAY_NAME "${APPLICATION_NAME} Custom State Handler" )
2022-08-03 14:42:09 +03:00
set( CFAPI_SHELLEXT_THUMBNAIL_HANDLER_CLASS_ID "6FF9B5B6-389F-444A-9FDD-A286C36EA079" )
set( CFAPI_SHELLEXT_THUMBNAIL_HANDLER_CLASS_ID_REG "{${CFAPI_SHELLEXT_THUMBNAIL_HANDLER_CLASS_ID}}" )
set( CFAPI_SHELLEXT_THUMBNAIL_HANDLER_DISPLAY_NAME "${APPLICATION_NAME} Thumbnail Handler" )
2022-08-04 11:50:58 +03:00
# URI Handler Scheme for Local File Editing
set( APPLICATION_URI_HANDLER_SCHEME "nc")
2018-04-20 15:57:21 +03:00
# Default suffix if the theme doesn't define one
2018-05-18 09:29:40 +03:00
if(NOT DEFINED APPLICATION_VIRTUALFILE_SUFFIX)
set(APPLICATION_VIRTUALFILE_SUFFIX "${APPLICATION_SHORTNAME}_virtual" CACHE STRING "Virtual file suffix (not including the .)")
2018-04-20 15:57:21 +03:00
endif()
2014-11-17 20:30:32 +03:00
# need this logic to not mess with re/uninstallations via macosx.pkgproj
if(${APPLICATION_REV_DOMAIN} STREQUAL "com.owncloud.desktopclient")
set(APPLICATION_REV_DOMAIN_INSTALLER "com.ownCloud.client")
else()
set(APPLICATION_REV_DOMAIN_INSTALLER ${APPLICATION_REV_DOMAIN})
endif()
2016-04-13 16:40:18 +03:00
# For usage in XML files we preprocess
string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}")
string(REPLACE "<" "<" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
string(REPLACE ">" ">" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
2017-09-22 11:29:17 +03:00
if (NOT DEFINED LINUX_PACKAGE_SHORTNAME)
set(LINUX_PACKAGE_SHORTNAME "${APPLICATION_SHORTNAME}")
endif()
if (NOT DEFINED PACKAGE)
set(PACKAGE "${LINUX_PACKAGE_SHORTNAME}-client")
endif()
2014-11-10 00:30:05 +03:00
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
2021-05-14 13:39:25 +03:00
include(ECMCoverageOption)
2014-08-30 12:46:09 +04:00
if(NOT CRASHREPORTER_EXECUTABLE)
set(CRASHREPORTER_EXECUTABLE "${APPLICATION_EXECUTABLE}_crash_reporter")
endif()
2014-11-10 00:30:05 +03:00
include(Warnings)
2021-08-20 12:22:00 +03:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
2011-04-06 13:28:38 +04:00
include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
2017-08-16 09:36:52 +03:00
# For config.h
2016-04-11 16:25:49 +03:00
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
2017-08-16 09:36:52 +03:00
# Allows includes based on src/ like #include "common/utility.h" or #include "csync/csync.h"
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/src
)
2012-04-26 18:32:50 +04:00
2015-09-10 10:35:11 +03:00
# disable the crashreporter if libcrashreporter-qt is not available or we're building for ARM
2014-08-28 14:05:00 +04:00
if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
set( WITH_CRASHREPORTER OFF )
endif()
if(NOT WITH_CRASHREPORTER)
message(STATUS "Build of crashreporter disabled.")
endif()
2012-04-14 06:43:04 +04:00
include(GNUInstallDirs)
2013-08-22 11:40:15 +04:00
include(DefineInstallationPaths)
2016-09-14 16:31:05 +03:00
include(GenerateExportHeader)
2013-08-28 22:14:40 +04:00
2012-12-20 23:05:56 +04:00
include(GetGitRevisionDescription)
2015-02-06 14:18:09 +03:00
2012-12-20 23:05:56 +04:00
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
2017-12-14 17:10:33 +03:00
add_definitions(
2021-09-10 16:59:47 +03:00
-DQT_DISABLE_DEPRECATED_BEFORE=0x000000
2017-12-14 17:10:33 +03:00
-DQT_USE_QSTRINGBUILDER
-DQT_MESSAGELOGCONTEXT #enable function name and line number in debug output
)
2012-12-20 23:05:56 +04:00
# if we cannot get it from git, directly try .tag (packages)
# this will work if the tar balls have been properly created
# via git-archive.
2016-12-21 16:14:26 +03:00
if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
2012-12-20 23:05:56 +04:00
file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
message("${sha1_candidate}")
set (GIT_SHA1 "${sha1_candidate}")
endif()
endif()
2014-10-27 13:54:16 +03:00
message(STATUS "GIT_SHA1 ${GIT_SHA1}")
2012-12-20 23:05:56 +04:00
2013-08-22 11:40:15 +04:00
set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
2021-12-02 00:48:33 +03:00
set(SHAREDIR ${CMAKE_INSTALL_FULL_DATADIR})
2019-03-15 15:56:11 +03:00
2021-11-17 13:52:47 +03:00
# Build MacOS app bundle if wished
if(APPLE AND BUILD_OWNCLOUD_OSX_BUNDLE)
message(STATUS "Build MacOS app bundle")
2021-06-04 21:34:58 +03:00
set(OWNCLOUD_OSX_BUNDLE "${APPLICATION_NAME}.app")
set(LIB_INSTALL_DIR "${APPLICATION_NAME}.app/Contents/MacOS")
set(BIN_INSTALL_DIR "${APPLICATION_NAME}.app/Contents/MacOS")
2022-06-06 20:05:12 +03:00
add_definitions(-DBUILD_OWNCLOUD_OSX_BUNDLE)
2012-04-16 12:51:20 +04:00
endif()
2021-12-29 19:44:40 +03:00
2022-01-12 12:17:04 +03:00
option(QUICK_COMPILER "Use QtQuick compiler to improve performance" OFF)
2021-12-29 19:44:40 +03:00
2014-03-12 17:20:38 +04:00
# this option removes Http authentication, keychain, shibboleth etc and is intended for
# external authentication mechanisms
option(TOKEN_AUTH_ONLY "TOKEN_AUTH_ONLY" OFF)
if(TOKEN_AUTH_ONLY)
message("Compiling with token authentication")
add_definitions(-DTOKEN_AUTH_ONLY=1)
endif()
2015-02-19 18:49:39 +03:00
option(NO_MSG_HANDLER "Don't redirect QDebug outputs to the log window/file" OFF)
if(NO_MSG_HANDLER)
add_definitions(-DNO_MSG_HANDLER=1)
endif()
2020-03-09 03:48:07 +03:00
if(BUILD_UPDATER)
message("Compiling with updater")
else()
message("Compiling without updater")
endif()
2017-09-22 11:32:38 +03:00
# this option builds the shell integration
option(BUILD_SHELL_INTEGRATION "BUILD_SHELL_INTEGRATION" ON)
# this option builds/installs the generic shell integration icons
option(BUILD_SHELL_INTEGRATION_ICONS "BUILD_SHELL_INTEGRATION_ICONS" ON)
# this options builds the dolphin integration plugin
option(BUILD_SHELL_INTEGRATION_DOLPHIN "BUILD_SHELL_INTEGRATION_DOLPHIN" ON)
# this options builds the nautilus (like) integration plugins
option(BUILD_SHELL_INTEGRATION_NAUTILUS "BUILD_SHELL_INTEGRATION_NAUTILUS" ON)
# this option builds the client
option(BUILD_CLIENT "BUILD_CLIENT" ON)
# this option creates only libocsync and libowncloudsync (NOTE: BUILD_CLIENT needs to be on)
2014-03-12 17:20:38 +04:00
option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)
2018-11-08 20:15:04 +03:00
# build the GUI component, when disabled only nextcloudcmd is built
option(BUILD_GUI "BUILD_GUI" ON)
2022-11-30 12:34:49 +03:00
# build the tests
option(BUILD_TESTING "BUILD_TESTING" ON)
2023-04-25 18:23:58 +03:00
option(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY" OFF)
if(ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if (CLANG_TIDY_EXE)
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE} -checks=-*,modernize-use-auto,modernize-use-using,modernize-use-nodiscard,modernize-use-nullptr,modernize-use-override,cppcoreguidelines-pro-type-static-cast-downcast,modernize-use-default-member-init,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-init-variables)
endif()
else()
unset(CLANG_TIDY_EXE)
unset(CMAKE_CXX_CLANG_TIDY)
endif()
2015-09-10 10:35:11 +03:00
# When this option is enabled, 5xx errors are not added to the blacklist
# Normally you don't want to enable this option because if a particular file
# triggers a bug on the server, you want the file to be blacklisted.
2014-04-29 13:39:46 +04:00
option(OWNCLOUD_5XX_NO_BLACKLIST "OWNCLOUD_5XX_NO_BLACKLIST" OFF)
if(OWNCLOUD_5XX_NO_BLACKLIST)
add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
endif()
2015-06-22 14:53:05 +03:00
if(APPLE)
2015-09-10 10:35:11 +03:00
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
2015-06-22 14:53:05 +03:00
endif()
2017-09-22 11:32:38 +03:00
if(BUILD_CLIENT)
2017-03-30 14:24:04 +03:00
OPTION(GUI_TESTING "Build with gui introspection features of socket api" OFF)
2020-03-09 03:48:07 +03:00
if(APPLE AND BUILD_UPDATER)
2017-09-22 11:32:38 +03:00
find_package(Sparkle)
2020-03-09 03:48:07 +03:00
endif()
2012-07-20 19:12:29 +04:00
2021-04-01 22:08:46 +03:00
if(UNIX AND NOT APPLE)
2021-04-14 10:08:17 +03:00
find_package(Inotify REQUIRED)
2017-09-22 11:32:38 +03:00
endif()
find_package(Sphinx)
find_package(PdfLatex)
2018-08-04 17:53:06 +03:00
find_package(OpenSSL 1.1 REQUIRED )
2014-10-16 19:16:29 +04:00
2017-10-17 17:53:11 +03:00
find_package(ZLIB REQUIRED)
2023-11-21 00:18:51 +03:00
find_package(SQLite3 3.9.0 REQUIRED)
2021-04-01 20:46:56 +03:00
if(NOT WIN32 AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CLOUDPROVIDERS cloudproviders IMPORTED_TARGET)
if(CLOUDPROVIDERS_FOUND)
2022-01-08 17:52:11 +03:00
pkg_check_modules(DBUS-1 REQUIRED dbus-1 IMPORTED_TARGET)
2021-04-01 20:46:56 +03:00
pkg_check_modules(GIO REQUIRED gio-2.0 IMPORTED_TARGET)
pkg_check_modules(GLIB2 REQUIRED glib-2.0 IMPORTED_TARGET)
endif()
endif()
2017-09-22 11:32:38 +03:00
endif()
2012-07-20 19:12:29 +04:00
2023-12-04 18:29:52 +03:00
if (APPLE)
option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" OFF)
else ()
option(BUILD_WITH_WEBENGINE "BUILD_WITH_WEBENGINE" ON)
endif()
2017-03-27 12:12:28 +03:00
if (NOT DEFINED APPLICATION_ICON_NAME)
set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME})
endif()
2017-10-10 10:56:04 +03:00
include(NextcloudCPack.cmake)
2011-04-06 13:28:38 +04:00
2012-07-30 18:08:42 +04:00
add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)
2014-03-05 18:39:49 +04:00
if( WIN32 )
add_definitions( -D__USE_MINGW_ANSI_STDIO=1 )
2016-09-14 16:31:05 +03:00
add_definitions( -DNOMINMAX )
2017-10-04 14:49:42 +03:00
# Get APIs from from Vista onwards.
2018-08-15 11:46:16 +03:00
add_definitions(-D_WIN32_WINNT=0x0601)
add_definitions(-DWINVER=0x0601)
add_definitions(-DNTDDI_VERSION=0x0A000004)
2019-09-08 15:47:35 +03:00
if( MSVC )
# Use automatic overload for suitable CRT safe-functions
# See https://docs.microsoft.com/de-de/cpp/c-runtime-library/security-features-in-the-crt?view=vs-2019
add_definitions( -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 )
# Also: Disable compiler warnings because we don't use Windows CRT safe-functions explicitly and don't intend to
# as this is a pure cross-platform source the only alternative would be a ton of ifdefs with calls to the _s version
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
endif( MSVC )
2014-03-05 18:39:49 +04:00
endif( WIN32 )
2012-02-16 13:42:44 +04:00
2017-07-04 13:20:59 +03:00
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
2015-02-08 01:28:20 +03:00
# Handle Translations, pick all client_* files from trans directory.
file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
2012-04-30 14:47:54 +04:00
set(TRANSLATIONS ${TRANS_FILES})
2012-03-26 11:48:30 +04:00
2017-09-22 11:32:38 +03:00
if(BUILD_CLIENT)
add_subdirectory(src)
if(NOT BUILD_LIBRARIES_ONLY)
2017-12-03 18:52:58 +03:00
add_subdirectory(man)
2017-09-22 11:32:38 +03:00
add_subdirectory(doc)
add_subdirectory(doc/dev)
2017-10-02 19:36:35 +03:00
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/admin)
2017-09-27 19:37:45 +03:00
add_subdirectory(admin)
2017-10-02 19:36:35 +03:00
endif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/admin)
2017-09-22 11:32:38 +03:00
endif(NOT BUILD_LIBRARIES_ONLY)
endif()
if(BUILD_SHELL_INTEGRATION)
add_subdirectory(shell_integration)
endif()
Add doc cmake targets (HTML, PDF, QtHelp, CHM, man)
make doc will build all of the above, except for CHM,
which needs manual preparation and can be built with
make doc-chm. See doc/scripts/README.rst for details.
We do our best to ensure to detect the required tools
before adding targets, so a build should always succeed.
Exception: On Debian and Ubuntu, the following packages are
required to build the PDF target (in addition to pdflatex
itself, which is autodetected):
* texlive-latex-recommended
* texlive-latex-extra
* texlive-fonts-recommended
If pdflatex is present, but those are not, the doc target
will fail.
Results can be found in $BUILDDIR/doc/$format.
2012-11-25 03:21:27 +04:00
2018-12-06 14:03:59 +03:00
if(BUILD_TESTING)
2021-04-15 01:20:19 +03:00
include(CTest)
2018-12-06 14:03:59 +03:00
enable_testing()
2017-08-16 09:36:52 +03:00
add_subdirectory(test)
2018-12-06 14:03:59 +03:00
endif()
2017-08-16 09:36:52 +03:00
2017-08-14 19:49:44 +03:00
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
2017-08-16 09:36:52 +03:00
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
2012-03-26 11:48:30 +04:00
2012-04-16 12:51:20 +04:00
if(BUILD_OWNCLOUD_OSX_BUNDLE)
2015-01-09 16:37:59 +03:00
install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
2015-07-06 15:59:08 +03:00
configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
2017-09-22 11:32:38 +03:00
elseif(BUILD_CLIENT)
2013-08-22 11:51:35 +04:00
install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
2014-09-03 16:33:58 +04:00
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
2012-04-16 12:51:20 +04:00
endif()
2021-04-14 10:08:17 +03:00
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)