### Configure and Install MSI Installer Files Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/windows/CMakeLists.txt Conditionally configures the WinShellExt.wxs file and installs it if the BUILD_WIN_MSI option is enabled. ```cmake if(BUILD_WIN_MSI) configure_file(WinShellExt.wxs.in ${CMAKE_CURRENT_BINARY_DIR}/WinShellExt.wxs) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/WinShellExt.wxs DESTINATION msi/ ) endif() ``` -------------------------------- ### Install csync Source: https://github.com/nextcloud/desktop/blob/master/src/csync/INSTALL.md Install the compiled csync library and associated files to the specified installation prefix after successful compilation and testing. ```bash make install ``` -------------------------------- ### Install CfApiShellExtensions Target Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/vfs/cfapi/shellext/CMakeLists.txt Installs the CfApiShellExtensions target, placing its runtime and library files into the specified installation bin directory. Optionally installs the PDB file. ```cmake install(TARGETS CfApiShellExtensions RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES $ DESTINATION bin OPTIONAL) ``` -------------------------------- ### Install MSI Installer Components Source: https://github.com/nextcloud/desktop/blob/master/admin/win/msi/CMakeLists.txt Installs various files required for the MSI installer into the 'msi/' subdirectory of the installation path. ```cmake install( FILES ${CMAKE_CURRENT_BINARY_DIR}/OEM.wxi ${CMAKE_CURRENT_BINARY_DIR}/collect-transform.xsl ${CMAKE_CURRENT_BINARY_DIR}/make-msi.bat EnsureACL.js Platform.wxi Nextcloud.wxs ${CMAKE_CURRENT_BINARY_DIR}/RegistryCleanup.vbs RegistryCleanupCustomAction.wxs gui/banner.bmp gui/dialog.bmp DESTINATION msi/) ``` -------------------------------- ### Install FileProviderUIExt.appex Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Installs the FileProviderUIExt.appex bundle to the specified plugins directory, preserving source permissions. ```cmake install(DIRECTORY ${OSX_PLUGINS_BINARY_DIR}/FileProviderUIExt.appex DESTINATION ${OSX_PLUGINS_INSTALL_DIR} USE_SOURCE_PERMISSIONS) ``` -------------------------------- ### Install RealmSwift.framework for FileProviderUIExt Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Installs the RealmSwift.framework into the FileProviderUIExt.appex bundle's Frameworks directory. ```cmake install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${XCODE_TARGET_CONFIGURATION}/PackageFrameworks/RealmSwift.framework DESTINATION ${OSX_PLUGINS_INSTALL_DIR}/FileProviderUIExt.appex/Contents/Frameworks USE_SOURCE_PERMISSIONS) ``` -------------------------------- ### Install NCMsiHelper Library and WXS File Source: https://github.com/nextcloud/desktop/blob/master/admin/win/tools/NCMsiHelper/CMakeLists.txt Installs the compiled NCMsiHelper target library to the 'msi/' directory and also installs the NCMsiHelper.wxs file to the same location. ```cmake install(TARGETS ${TARGET_NAME} DESTINATION msi/ ) install(FILES NCMsiHelper.wxs DESTINATION msi/ ) ``` -------------------------------- ### Install and Run mac-crafter Source: https://github.com/nextcloud/desktop/blob/master/admin/osx/mac-crafter/README.md Install and run mac-crafter after cloning the Nextcloud Desktop Client repository. This command checks for and installs required tools and clones the KDE Craft repository if needed. ```bash swift run mac-crafter ``` -------------------------------- ### Install RealmSwift.framework for FileProviderExt Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Installs the RealmSwift.framework into the FileProviderExt.appex bundle's Frameworks directory. ```cmake install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${XCODE_TARGET_CONFIGURATION}/PackageFrameworks/RealmSwift.framework DESTINATION ${OSX_PLUGINS_INSTALL_DIR}/FileProviderExt.appex/Contents/Frameworks USE_SOURCE_PERMISSIONS) ``` -------------------------------- ### Install FileProviderExt.appex Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Installs the FileProviderExt.appex bundle to the specified plugins directory, preserving source permissions. ```cmake install(DIRECTORY ${OSX_PLUGINS_BINARY_DIR}/FileProviderExt.appex DESTINATION ${OSX_PLUGINS_INSTALL_DIR} USE_SOURCE_PERMISSIONS) ``` -------------------------------- ### Unix Icon Installation Logic Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/icons/CMakeLists.txt Installs application icons for Unix-like systems, excluding macOS. It iterates through predefined icon sizes and installs PNG files with application-specific renaming. ```cmake # SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors # SPDX-FileCopyrightText: 2014 ownCloud GmbH # SPDX-License-Identifier: GPL-2.0-or-later if( UNIX AND NOT APPLE ) SET(ICON_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) FOREACH(size 128x128 16x16 256x256 32x32 48x48 64x64 72x72) file(GLOB files "${size}/*.png") FOREACH( file ${files} ) # the GLOB returns a absolute path. Make it relative by replacing the current src dir by nothing STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${size}/" "" shortFile ${file}) STRING(REPLACE "oC" ${APPLICATION_SHORTNAME} brandedName ${shortFile}) install(FILES ${file} DESTINATION ${ICON_DIR}/${size}/apps RENAME ${brandedName}) ENDFOREACH(file) ENDFOREACH(size) endif() ``` -------------------------------- ### Install Nextcloud Executable and Libraries Source: https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt Installs the main 'nextcloud' target to runtime, library, and archive destinations. For Windows, it also optionally installs the Program Database (PDB) file. ```cmake install(TARGETS nextcloud RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib BUNDLE DESTINATION "." ) if (WIN32) install(FILES $ DESTINATION bin OPTIONAL) endif() ``` -------------------------------- ### Set Installation Directories Source: https://github.com/nextcloud/desktop/blob/master/CMakeLists.txt Defines the system configuration directory and the shared data directory for installation. ```cmake set(SYSCONFDIR ${SYSCONF_INSTALL_DIR}) set(SHAREDIR ${CMAKE_INSTALL_FULL_DATADIR}) ``` -------------------------------- ### Install Target Library Source: https://github.com/nextcloud/desktop/blob/master/admin/win/tools/NCNavRemove/dll/CMakeLists.txt Installs the built NCNavRemove DLL to the specified destination path. ```cmake install(TARGETS ${TARGET_NAME} DESTINATION tools/NCNavRemove/dll/ ) ``` -------------------------------- ### Install VFS xattr Library Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/vfs/xattr/CMakeLists.txt Installs the 'nextcloudsync_vfs_xattr' library to the specified plugin directory. This makes the library available for runtime loading. ```cmake install(TARGETS nextcloudsync_vfs_xattr LIBRARY DESTINATION "${vfs_installdir}" RUNTIME DESTINATION "${vfs_installdir}" ) ``` -------------------------------- ### Install VFS Suffix Library Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/vfs/suffix/CMakeLists.txt Installs the nextcloudsync_vfs_suffix library to the specified destination directory. ```cmake install(TARGETS nextcloudsync_vfs_suffix LIBRARY DESTINATION "${vfs_installdir}" RUNTIME DESTINATION "${vfs_installdir}" ) ``` -------------------------------- ### Install NCContextMenu Target Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/windows/NCContextMenu/CMakeLists.txt Installs the NCContextMenu target to the specified runtime and library destinations. ```cmake install(TARGETS NCContextMenu RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Install NCOverlays PDB File Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/windows/NCOverlays/CMakeLists.txt Optionally installs the Program Database (PDB) file for NCOverlays to the 'bin' destination. ```cmake install(FILES $ DESTINATION bin OPTIONAL) ``` -------------------------------- ### Project and Library Setup Source: https://github.com/nextcloud/desktop/blob/master/test/csync/CMakeLists.txt Defines the project name, sets up a torture library with source files and links it with cmocka. It also sets the target libraries for tests. ```cmake # SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors # SPDX-FileCopyrightText: 2017 ownCloud GmbH # SPDX-License-Identifier: LGPL-2.1-or-later project(tests) set(TORTURE_LIBRARY torture) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMOCKA_INCLUDE_DIR} ${CHECK_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/src/csync ) # create test library add_library(${TORTURE_LIBRARY} STATIC torture.c cmdline.c) target_link_libraries(${TORTURE_LIBRARY} ${CMOCKA_LIBRARIES}) set(TEST_TARGET_LIBRARIES ${TORTURE_LIBRARY} Qt::Core Nextcloud::csync) ``` -------------------------------- ### Install Sync Exclude List Source: https://github.com/nextcloud/desktop/blob/master/CMakeLists.txt Installs the sync-exclude.lst file to the appropriate destination based on build options for macOS bundles or client installations. ```cmake if(BUILD_OWNCLOUD_OSX_BUNDLE) install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/) configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY) elseif(BUILD_CLIENT) install(FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} ) configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY) endif() ``` -------------------------------- ### Install NCContextMenu PDB File Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/windows/NCContextMenu/CMakeLists.txt Optionally installs the Program Database (PDB) file for NCContextMenu to the 'bin' destination. ```cmake install(FILES $ DESTINATION bin OPTIONAL) ``` -------------------------------- ### Install NCOverlays Target Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/windows/NCOverlays/CMakeLists.txt Installs the NCOverlays target to the specified runtime and library destinations. ```cmake install(TARGETS NCOverlays RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Display Help for TransifexStringCatalogSanitizer Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/TransifexStringCatalogSanitizer/README.md Run this command to view the integrated help and get up-to-date reference for the sanitizer's options. ```sh swift run TransifexStringCatalogSanitizer --help ``` -------------------------------- ### Configure MSI Installer Input Files Source: https://github.com/nextcloud/desktop/blob/master/admin/win/msi/CMakeLists.txt Uses CMake's configure_file command to process input files for the MSI installer, generating configuration-specific versions. ```cmake configure_file(RegistryCleanup.vbs.in ${CMAKE_CURRENT_BINARY_DIR}/RegistryCleanup.vbs) configure_file(OEM.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/OEM.wxi) configure_file(collect-transform.xsl.in ${CMAKE_CURRENT_BINARY_DIR}/collect-transform.xsl) configure_file(make-msi.bat.in ${CMAKE_CURRENT_BINARY_DIR}/make-msi.bat) ``` -------------------------------- ### Get Help for mac-crafter Source: https://github.com/nextcloud/desktop/blob/master/admin/osx/mac-crafter/README.md View the full reference for mac-crafter subcommands or get specific help for a subcommand. ```bash mac-crafter --help ``` -------------------------------- ### Qt Translation Setup (CMake) Source: https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt Finds the Qt Linguist Tools and adds translation files to the client_I18N target if found. This is essential for internationalization. ```cmake find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} COMPONENTS LinguistTools) if(Qt${QT_MAJOR_VERSION}LinguistTools_FOUND) qt_add_translation(client_I18N ${TRANSLATIONS}) endif() ``` -------------------------------- ### Format Code with SwiftFormat Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/NextcloudFileProviderKit/README.md Run SwiftFormat to ensure code changes comply with the project's style guide. Execute this command in the root of the package repository clone. ```bash swift package plugin --allow-writing-to-package-directory swiftformat --verbose --cache ignore ``` -------------------------------- ### Get Help for a Specific Subcommand Source: https://github.com/nextcloud/desktop/blob/master/admin/osx/mac-crafter/README.md Get specific help for a particular mac-crafter subcommand. ```bash mac-crafter --help ``` -------------------------------- ### Install macOS File Provider Extensions Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Configures and installs the File Provider and File Provider UI extensions (.appex) for macOS. This includes processing their respective entitlement files. ```cmake if (BUILD_FILE_PROVIDER_MODULE) configure_file(FileProviderExt.entitlements.cmake ${CMAKE_CURRENT_BINARY_DIR}/FileProviderExt.entitlements) configure_file(FileProviderUIExt.entitlements.cmake ${CMAKE_CURRENT_BINARY_DIR}/FileProviderUIExt.entitlements) endif() ``` -------------------------------- ### Install VFS xattr PDB on Windows Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/vfs/xattr/CMakeLists.txt Conditionally installs the Program Database (PDB) file for the 'nextcloudsync_vfs_xattr' library on Windows. This is optional and placed in the 'bin' directory. ```cmake if (WIN32) install(FILES $ DESTINATION bin OPTIONAL) endif() ``` -------------------------------- ### Install PDB File on Windows Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/CMakeLists.txt Optionally installs the Program Database (PDB) file for the 'nextcloudsync' target on Windows systems. This is useful for debugging. ```cmake if (WIN32) install(FILES $ DESTINATION bin OPTIONAL) endif() ``` -------------------------------- ### Run Tests for csync Source: https://github.com/nextcloud/desktop/blob/master/src/csync/INSTALL.md Execute the test suite to verify the build and functionality of csync before proceeding with the installation. ```bash make test ``` -------------------------------- ### Install macOS FinderSync Extension Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Installs the compiled FinderSync extension (.appex) to the appropriate location within the macOS bundle. It also ensures a Library folder exists within the extension bundle as expected by Launch Services. ```cmake set(OSX_PLUGINS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${XCODE_TARGET_CONFIGURATION}) set(OSX_PLUGINS_INSTALL_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns) configure_file(FinderSyncExt.entitlements.cmake ${CMAKE_CURRENT_BINARY_DIR}/FinderSyncExt.entitlements) install(DIRECTORY ${OSX_PLUGINS_BINARY_DIR}/FinderSyncExt.appex DESTINATION ${OSX_PLUGINS_INSTALL_DIR} USE_SOURCE_PERMISSIONS) # HACK: Launch Services expects there to be a Library folder within the FinderSyncExt.appex. install(DIRECTORY DESTINATION ${OSX_PLUGINS_INSTALL_DIR}/FinderSyncExt.appex/Contents/Library) ``` -------------------------------- ### QObject Class Declaration Example Source: https://github.com/nextcloud/desktop/wiki/Coding-Style Demonstrates the standard declaration for a class inheriting from QObject, including Q_PROPERTY, signals, slots, and member variables. ```cpp class Foo : public QObject { Q_OBJECT Q_PROPERTY(....) public: enum Bar { }; Q_ENUM(Bar) static void staticMethods(); explicit Foo(QObject *parent = nullptr); bool publicMethod() const; signals: void mySignal(); protected slots: void protectedSlot(); protected: void protectedMethod(); private slots: void privateSlot(); private: void privateMethod(); bool _member; }; ``` -------------------------------- ### Install nextcloudsync Target Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/CMakeLists.txt Installs the 'nextcloudsync' target to the appropriate runtime, library, and archive directories. This is done conditionally based on whether a macOS bundle is being built. ```cmake if(NOT BUILD_OWNCLOUD_OSX_BUNDLE) install(TARGETS nextcloudsync RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) else() install(TARGETS nextcloudsync DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/MacOS) endif() ``` -------------------------------- ### Configure and Install Systemd User Service for Linux Source: https://github.com/nextcloud/desktop/blob/master/CMakeLists.txt Configures the systemd service file for Linux and conditionally installs it if systemd development files are found and the INSTALL_SYSTEMD option is enabled. ```cmake if(LINUX AND BUILD_CLIENT) set(bindir ${CMAKE_INSTALL_FULL_BINDIR}) configure_file(systemd/nextcloud-desktop.service.in "${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.service") pkg_check_modules(SYSTEMD systemd IMPORTED_TARGET) set_package_properties(SYSTEMD PROPERTIES DESCRIPTION "Systemd development files needed to install user service" TYPE OPTIONAL ) pkg_get_variable(SYSTEMD_USER_UNIT_DIR systemd "systemd_user_unit_dir") if (SYSTEMD_USER_UNIT_DIR) message(STATUS "Systemd development files found. Enable installing systemd user service.") option(INSTALL_SYSTEMD "Install systemd user service" ON) if(INSTALL_SYSTEMD) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.service" DESTINATION "${SYSTEMD_USER_UNIT_DIR}") endif() else() message(STATUS "Systemd development files not found. Not installing systemd user service.") endif() endif() ``` -------------------------------- ### Generating Windows Start Menu Icons Source: https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt Generates specific sized PNG icons for the Windows 10 start menu from a dedicated SVG file. This is conditional on the Windows platform. ```cmake if(WIN32) set(STARTMENU_ICON_SVG "${theme_dir}/colored/${APPLICATION_ICON_NAME}-w10startmenu.svg") generate_sized_png_from_svg(${STARTMENU_ICON_SVG} 70) generate_sized_png_from_svg(${STARTMENU_ICON_SVG} 150) endif() ``` -------------------------------- ### Compile Nextcloud Desktop Client Source: https://github.com/nextcloud/desktop/blob/master/README.md Compile the Nextcloud Desktop client using CMake. The NEXTCLOUD_DEV flag enables parallel development with an installed client. ```bash cmake -S -B build -DCMAKE_PREFIX_PATH= -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=. -DNEXTCLOUD_DEV=ON ``` -------------------------------- ### Applying GPL to New Programs Source: https://github.com/nextcloud/desktop/blob/master/LICENSES/GPL-3.0-or-later.txt This snippet shows how to include the necessary notices when developing a new program to ensure it is free software under the GPL. It includes copyright information, license terms, and warranty disclaimers. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Install Icons and Translations for Non-macOS Source: https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt Installs application icons and translation files to their respective directories based on the operating system. For non-Windows systems, it installs colored icons and translation files. For Windows, it installs visual elements and manifest files. ```cmake if(NOT BUILD_OWNCLOUD_OSX_BUNDLE) if(NOT WIN32) file(GLOB _icons "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-icon.png") foreach(_file ${_icons}) string(REPLACE "${theme_dir}/colored/" "" _res ${_file}) string(REPLACE "-${APPLICATION_ICON_NAME}-icon.png" "" _res ${_res}) install(FILES ${_file} RENAME ${APPLICATION_ICON_NAME}.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${_res}x${_res}/apps) endforeach(_file) install(FILES ${client_I18N} DESTINATION ${CMAKE_INSTALL_DATADIR}/${APPLICATION_EXECUTABLE}/i18n) else() file(GLOB_RECURSE VISUAL_ELEMENTS "${theme_dir}/colored/*-${APPLICATION_ICON_NAME}-w10startmenu*") install(FILES ${VISUAL_ELEMENTS} DESTINATION bin/visualelements) install(FILES "${theme_dir}/${APPLICATION_EXECUTABLE}.VisualElementsManifest.xml" DESTINATION bin) install(FILES ${client_I18N} DESTINATION i18n) endif() # we may not add MACOSX_BUNDLE here, if not building one add_executable(nextcloud WIN32 main.cpp ${client_version} ${client_manifest} ${APP_ICON}) set_target_properties(nextcloud PROPERTIES OUTPUT_NAME "${APPLICATION_EXECUTABLE}" ) else() # set(CMAKE_INSTALL_PREFIX ".") # Examples use /Applications. hurmpf. if(MACOS_USE_ICON_COMPOSER) set(MACOSX_BUNDLE_ICON_FILE "AppIcon") # Modern Icon Composer path also publishes CFBundleIconName so Finder # finds the asset in the bundle's Assets.car. set(MACOSX_BUNDLE_ICON_NAME_BLOCK "CFBundleIconName\n AppIcon") else() set(MACOSX_BUNDLE_ICON_FILE "${APPLICATION_ICON_NAME}.icns") set(MACOSX_BUNDLE_ICON_NAME_BLOCK "") endif() # we must add MACOSX_BUNDLE only if building a bundle add_executable(nextcloud WIN32 MACOSX_BUNDLE main.cpp ${APP_ICON}) if (BUILD_OWNCLOUD_OSX_BUNDLE) set_target_properties(nextcloud PROPERTIES OUTPUT_NAME "${APPLICATION_NAME}") else() set_target_properties(nextcloud PROPERTIES OUTPUT_NAME "${APPLICATION_EXECUTABLE}") endif() set (QM_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/Translations) install(FILES ${client_I18N} DESTINATION ${QM_DIR}) get_target_property(_qmake Qt::qmake LOCATION) execute_process(COMMAND ${_qmake} -query QT_INSTALL_TRANSLATIONS OUTPUT_VARIABLE QT_TRANSLATIONS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) file(GLOB qt_I18N ${QT_TRANSLATIONS_DIR}/qt_??.qm ${QT_TRANSLATIONS_DIR}/qt_??_??.qm) install(FILES ${qt_I18N} DESTINATION ${QM_DIR}) file(GLOB qtbase_I18N ${QT_TRANSLATIONS_DIR}/qtbase_??.qm ${QT_TRANSLATIONS_DIR}/qt_??_??.qm) install(FILES ${qtbase_I18N} DESTINATION ${QM_DIR}) file(GLOB qtkeychain_I18N ${QT_TRANSLATIONS_DIR}/qtkeychain*.qm) install(FILES ${qtkeychain_I18N} DESTINATION ${QM_DIR}) endif() ``` -------------------------------- ### Applying LGPL to New Programs Source: https://github.com/nextcloud/desktop/blob/master/LICENSES/LGPL-3.0-or-later.txt Instructions on how to apply the LGPL license to your own software projects. This includes adding copyright notices and disclaimers. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Build Universal App Bundles Source: https://github.com/nextcloud/desktop/blob/master/admin/osx/mac-crafter/README.md Use the make_universal.py script to build a universal app bundle supporting both arm64 and x86_64 architectures. Provide paths for x86_64 build, arm64 build, and the final target path. ```python python admin/osx/make_universal.py ``` -------------------------------- ### Install Headers Conditionally Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/CMakeLists.txt Installs the defined headers to the specified destinations, but only if the build is not for Apple platforms. This ensures platform-specific header availability. ```cmake IF (NOT APPLE) INSTALL( FILES ${owncloudsync_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/nextcloudsync/mirall ) INSTALL( FILES ${creds_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/nextcloudsync/creds ) ENDIF(NOT APPLE) ``` -------------------------------- ### Connect to Qt WebEngine Debugger Source: https://github.com/nextcloud/desktop/wiki/How-to-debug-qt-webengine Open a Chromium-based browser and navigate to the specified local address to connect to the remote debugging port. This will open the Chromium DevTools for the Nextcloud Desktop Client's web views. ```bash chromium http://localhost:8081 ``` -------------------------------- ### Install KeepDownloaded Icon Asset Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/MacOSX/CMakeLists.txt Installs the KeepDownloaded.icns file as the file provider badge icon for 'Always keep downloaded' items. ```cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/KeepDownloaded.icns DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources) ``` -------------------------------- ### Configure Project Files Source: https://github.com/nextcloud/desktop/blob/master/CMakeLists.txt Configures header files from template files for build-time configuration and version information. ```cmake configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) ``` -------------------------------- ### Install VFS Suffix PDB on Windows Source: https://github.com/nextcloud/desktop/blob/master/src/libsync/vfs/suffix/CMakeLists.txt Conditionally installs the Program Database (PDB) file for the VFS suffix library on Windows systems. ```cmake if (WIN32) install(FILES $ DESTINATION bin OPTIONAL) endif() ``` -------------------------------- ### Configure Link Directories Based on Architecture Source: https://github.com/nextcloud/desktop/blob/master/admin/win/tools/NCMsiHelper/CMakeLists.txt Sets the link directories for the WiX SDK libraries, choosing between x86 and x64 based on the CMAKE_SIZEOF_VOID_P value. ```cmake if(CMAKE_SIZEOF_VOID_P MATCHES 4) link_directories(${WIX_SDK_PATH}/lib/x86) else() link_directories(${WIX_SDK_PATH}/lib/x64) endif() ``` -------------------------------- ### Generate MSI Installer Filename Source: https://github.com/nextcloud/desktop/blob/master/admin/win/msi/CMakeLists.txt Constructs the final MSI installer filename using application name, version, optional suffix, and detected architecture. ```cmake string(SUBSTRING ${GIT_SHA1} 0 7 GIT_REVISION) set(VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}.${MIRALL_VERSION_BUILD}") if (NOT DEFINED MIRALL_VERSION_SUFFIX OR MIRALL_VERSION_SUFFIX MATCHES "git") set(VERSION_SUFFIX "") else() set(VERSION_SUFFIX "-${MIRALL_VERSION_SUFFIX}") endif() set(MSI_INSTALLER_FILENAME "${APPLICATION_SHORTNAME}-${VERSION}${VERSION_SUFFIX}-${MSI_BUILD_ARCH}.msi") ``` -------------------------------- ### Sandbox Violation Message Example Source: https://github.com/nextcloud/desktop/blob/master/doc/macOS-Sandbox-Qt.md Example of a sandbox violation message that may appear in Console.app when file operations are denied due to sandbox restrictions. ```text Sandbox: MyApp(12345) deny(1) file-write-create /Users/... ``` -------------------------------- ### Qt D-Bus Integration Logic Source: https://github.com/nextcloud/desktop/blob/master/shell_integration/libcloudproviders/CMakeLists.txt Handles finding Qt D-Bus components and setting up D-Bus bus names and object paths. It conditionally adds activation services and configuration files based on Qt and cloud provider versions. ```cmake if (Qt6_FOUND) find_package(Qt6 COMPONENTS COMPONENTS DBus) else() set(REQUIRED_QT_VERSION "5.15.0") find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS DBus) endif() IF (Qt5DBus_FOUND OR Qt6DBus_FOUND) STRING(TOLOWER "${APPLICATION_VENDOR}" DBUS_VENDOR) STRING(REGEX REPLACE "[^A-z0-9]" "" DBUS_VENDOR "${DBUS_VENDOR}") STRING(REGEX REPLACE "[^A-z0-9]" "" DBUS_APPLICATION_NAME "${APPLICATION_SHORTNAME}") if (NOT DBUS_PREFIX) set(DBUS_PREFIX "com") endif () set(LIBCLOUDPROVIDERS_DBUS_BUS_NAME "${DBUS_PREFIX}.${DBUS_VENDOR}.${DBUS_APPLICATION_NAME}") set(LIBCLOUDPROVIDERS_DBUS_OBJECT_PATH "/${DBUS_PREFIX}/${DBUS_VENDOR}/${DBUS_APPLICATION_NAME}") dbus_add_activation_service(org.freedesktop.CloudProviders.service.in) # The .ini file has been replaced by a declaration in the .desktop file in 0.3.3+ if (${CLOUDPROVIDERS_VERSION} VERSION_LESS "0.3.3") libcloudproviders_add_config(org.freedesktop.CloudProviders.ini.in) endif () ENDIF () ``` -------------------------------- ### Configure and Build csync on Linux/macOS Source: https://github.com/nextcloud/desktop/blob/master/src/csync/INSTALL.md Use CMake to configure the build with a Debug type and then compile the project using make. Ensure you are in the build directory. ```bash cmake -DCMAKE_BUILD_TYPE=Debug .. make ``` -------------------------------- ### QString Paths vs QUrl for Sandbox Access Source: https://github.com/nextcloud/desktop/blob/master/doc/macOS-Sandbox-Qt.md Use QUrl for file paths when dealing with security-scoped bookmarks to preserve access. QString paths can lose this security context. ```cpp // ❌ WRONG - loses security-scoped bookmark QString path = QFileDialog::getSaveFileName(...); ``` ```cpp // ✅ CORRECT - preserves security-scoped bookmark QUrl url = QFileDialog::getSaveFileUrl(...); ``` -------------------------------- ### Install Container Migration Plist Source: https://github.com/nextcloud/desktop/blob/master/admin/osx/CMakeLists.txt Installs the container-migration.plist file into the macOS bundle's Resources directory. This file is typically used for migrating application data. ```cmake install(FILES ${CMAKE_BINARY_DIR}/admin/osx/container-migration.plist DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources) ``` -------------------------------- ### Conventional Commits Example Source: https://github.com/nextcloud/desktop/blob/master/AGENTS.md An example of a commit message following the Conventional Commits format, including a scope, description, issue reference, and assisted-by line. ```git commit feat(files_sharing): allow sharing with contacts Closes #123. Assisted-by: ClaudeCode:claude-sonnet-4-6 ``` -------------------------------- ### Linux Desktop Integration Source: https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt Configures and installs the desktop entry file for Linux applications. This ensures that the application appears correctly in desktop environments and can be launched via application menus. It also handles MIME type registration. ```cmake if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT WIN32) configure_file(${CMAKE_SOURCE_DIR}/mirall.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications ) configure_file(owncloud.xml.in ${APPLICATION_EXECUTABLE}.xml) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages ) find_package(SharedMimeInfo) if(SharedMimeInfo_FOUND) update_xdg_mimetypes( ${CMAKE_INSTALL_DATADIR}/mime/packages ) endif(SharedMimeInfo_FOUND) endif() ``` -------------------------------- ### Conditional Installation for macOS Updater Bundle Source: https://github.com/nextcloud/desktop/blob/master/src/gui/updater/CMakeLists.txt Installs updater-related files into the macOS bundle if specific build options are enabled and Sparkle is found. This ensures necessary components for automatic updates are included. ```cmake if(BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY) if (SPARKLE_FOUND) install(FILES ${CMAKE_SOURCE_DIR}/admin/osx/deny_autoupdate_com.owncloud.desktopclient.plist DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources) install(FILES ${CMAKE_SOURCE_DIR}/admin/osx/sparkle/dsa_pub.pem DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources) endif() endif() ``` -------------------------------- ### macdeployqt for macOS Bundles Source: https://github.com/nextcloud/desktop/blob/master/src/gui/CMakeLists.txt Configures the macdeployqt tool to run as a post-build step for macOS bundles. This ensures that all necessary Qt libraries and resources are correctly deployed within the application bundle, and it also handles the stripping of debug symbols for release builds. ```cmake if(BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY) # macdeployqt (POST_BUILD) replaces the build-tree RPATH with @loader_path/../Frameworks. # Setting BUILD_WITH_INSTALL_RPATH prevents CMake from separately tracking the build-tree # RPATH and then trying to delete it at cmake --install time (which would fail because # macdeployqt has already removed it). set_target_properties(nextcloud PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) get_target_property (QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION) get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY) find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${QT_BIN_DIR}") get_filename_component(MACDEPLOYQT_DIR "${MACDEPLOYQT_EXECUTABLE}" DIRECTORY) execute_process( COMMAND "${QT_QMAKE_EXECUTABLE}" -query QT_INSTALL_LIBS OUTPUT_VARIABLE MACDEPLOYQT_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) set(cmd_NAME ${APPLICATION_EXECUTABLE}cmd) if(CMAKE_BUILD_TYPE MATCHES Debug) set(NO_STRIP "-no-strip") else() set(NO_STRIP "") endif() add_custom_command(TARGET nextcloud POST_BUILD COMMAND "${MACDEPLOYQT_EXECUTABLE}" "$/../.." -qmldir=${CMAKE_SOURCE_DIR}/src/gui -always-overwrite -executable="$/${cmd_NAME}" -libpath=${MACDEPLOYQT_LIB_DIR} -libpath=${BIN_OUTPUT_DIRECTORY} ${NO_STRIP} COMMAND "${CMAKE_COMMAND}" -E rm -rf "${BIN_OUTPUT_DIRECTORY}/${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns/bearer" COMMENT "Running macdeployqt..." ) endif() ```