2026-01-18 02:59:22 +00:00
|
|
|
# SPDX-FileCopyrightText: (C) 2024 - 2026 Deskflow Developers
|
|
|
|
|
# SPDX-FileCopyrightText: (C) 2012 - 2024 Symless Ltd
|
|
|
|
|
# SPDX-FileCopyrightText: (C) 2009 - 2012 Nick Bolton
|
2025-01-24 00:11:17 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-10-16 04:35:31 +00:00
|
|
|
cmake_minimum_required(VERSION 3.24)
|
2024-09-20 20:45:58 +00:00
|
|
|
|
2024-12-01 23:52:59 +00:00
|
|
|
# Link items by fill path
|
|
|
|
|
cmake_policy(SET CMP0003 NEW)
|
|
|
|
|
|
|
|
|
|
# Fix define escaping
|
|
|
|
|
cmake_policy(SET CMP0005 NEW)
|
|
|
|
|
|
2026-02-11 20:45:35 +00:00
|
|
|
# De-duplicate libraries on linker calls
|
|
|
|
|
if(POLICY CMP0156)
|
|
|
|
|
cmake_policy(SET CMP0156 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-12-01 23:14:36 +00:00
|
|
|
# Set CXX Requirements
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
2024-10-14 02:00:12 +00:00
|
|
|
# Fallback for when git can not be found
|
|
|
|
|
set(DESKFLOW_VERSION_MAJOR 1)
|
2026-02-16 13:02:20 +00:00
|
|
|
set(DESKFLOW_VERSION_MINOR 26)
|
2025-05-28 16:17:02 +00:00
|
|
|
set(DESKFLOW_VERSION_PATCH 0)
|
2024-10-14 02:00:12 +00:00
|
|
|
set(DESKFLOW_VERSION_TWEAK 0)
|
|
|
|
|
|
|
|
|
|
# Get the version from git if it's a git repository
|
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
|
|
|
|
find_package(Git)
|
|
|
|
|
if(GIT_FOUND)
|
2024-11-27 04:42:41 +00:00
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD
|
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
|
OUTPUT_VARIABLE GIT_SHA_SHORT
|
|
|
|
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
)
|
2024-10-14 02:00:12 +00:00
|
|
|
execute_process(
|
2025-12-29 15:51:45 +00:00
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --long --match v* --always
|
2024-10-14 02:00:12 +00:00
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
2025-12-29 15:51:45 +00:00
|
|
|
OUTPUT_VARIABLE GITREV
|
2025-01-02 22:09:39 +00:00
|
|
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
)
|
2025-12-29 15:51:45 +00:00
|
|
|
string(FIND "${GITREV}" "v" isRev)
|
|
|
|
|
if(NOT ${isRev} EQUAL -1)
|
|
|
|
|
string(REGEX MATCH [0-9]+ MAJOR ${GITREV})
|
|
|
|
|
string(REGEX MATCH \\.[0-9]+ MINOR ${GITREV})
|
|
|
|
|
string(REPLACE "." "" MINOR "${MINOR}")
|
|
|
|
|
string(REGEX MATCH [0-9]+\- PATCH ${GITREV})
|
|
|
|
|
string(REPLACE "-" "" PATCH "${PATCH}")
|
|
|
|
|
string(REGEX MATCH \-[0-9]+\- TWEAK ${GITREV})
|
|
|
|
|
string(REPLACE "-" "" TWEAK "${TWEAK}")
|
|
|
|
|
set(DESKFLOW_VERSION_MAJOR ${MAJOR})
|
|
|
|
|
set(DESKFLOW_VERSION_MINOR ${MINOR})
|
|
|
|
|
set(DESKFLOW_VERSION_PATCH ${PATCH})
|
|
|
|
|
set(DESKFLOW_VERSION_TWEAK ${TWEAK})
|
2025-01-02 22:09:39 +00:00
|
|
|
else()
|
2025-12-29 15:51:45 +00:00
|
|
|
set(DESKFLOW_VERSION_TWEAK "9999")
|
2024-10-14 02:00:12 +00:00
|
|
|
endif()
|
2025-12-29 15:51:45 +00:00
|
|
|
unset(GITREV)
|
2024-10-14 02:00:12 +00:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-07-17 15:45:09 +00:00
|
|
|
#generate vcpkg file if needed
|
|
|
|
|
if(WIN32)
|
|
|
|
|
option (VCPKG_QT "Use Qt from VCPKG" OFF)
|
|
|
|
|
if(VCPKG_QT)
|
|
|
|
|
set(QT_LIBS ", \"qttranslations\", \"qtsvg\"")
|
|
|
|
|
endif()
|
|
|
|
|
configure_file(cmake/vcpkg.json.in ${CMAKE_SOURCE_DIR}/vcpkg.json @ONLY)
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-10-14 02:00:12 +00:00
|
|
|
#Define our project
|
|
|
|
|
project(
|
|
|
|
|
deskflow
|
2025-01-10 13:47:53 +00:00
|
|
|
VERSION "${DESKFLOW_VERSION_MAJOR}.${DESKFLOW_VERSION_MINOR}.${DESKFLOW_VERSION_PATCH}.${DESKFLOW_VERSION_TWEAK}"
|
2025-04-04 13:56:39 +00:00
|
|
|
DESCRIPTION "Keyboard and mouse sharing utility"
|
2025-10-15 18:11:13 +00:00
|
|
|
HOMEPAGE_URL "https://deskflow.org"
|
2025-11-08 15:41:29 +00:00
|
|
|
LANGUAGES C CXX
|
|
|
|
|
)
|
2024-10-14 02:00:12 +00:00
|
|
|
|
2025-01-10 16:07:15 +00:00
|
|
|
# Define Additional "PROJECT" vars for packaging and metadata
|
|
|
|
|
set(CMAKE_PROJECT_PROPER_NAME "Deskflow")
|
2025-01-10 17:48:35 +00:00
|
|
|
set(CMAKE_PROJECT_VENDOR "${CMAKE_PROJECT_PROPER_NAME} Devs")
|
2026-01-02 18:06:33 +00:00
|
|
|
set(CMAKE_PROJECT_COPYRIGHT "(C) 2024-2026 ${CMAKE_PROJECT_VENDOR}")
|
2025-01-10 17:48:35 +00:00
|
|
|
set(CMAKE_PROJECT_CONTACT "${CMAKE_PROJECT_PROPER_NAME} <maintainers@deskflow.org>")
|
2025-09-29 23:00:18 +00:00
|
|
|
set(CMAKE_PROJECT_REV_FQDN "org.deskflow.deskflow")
|
2025-01-10 13:37:12 +00:00
|
|
|
|
2025-01-10 13:47:53 +00:00
|
|
|
#Unset the vars used in the project call
|
|
|
|
|
unset(DESKFLOW_VERSION_MAJOR)
|
|
|
|
|
unset(DESKFLOW_VERSION_MINOR)
|
|
|
|
|
unset(DESKFLOW_VERSION_PATCH)
|
|
|
|
|
unset(DESKFLOW_VERSION_TWEAK)
|
|
|
|
|
|
2024-10-14 02:00:12 +00:00
|
|
|
message(STATUS "Building ${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}")
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-12-02 01:21:22 +00:00
|
|
|
# Set lib versions
|
|
|
|
|
set(REQUIRED_OPENSSL_VERSION 3.0)
|
|
|
|
|
set(REQUIRED_LIBEI_VERSION 1.3)
|
2026-02-25 23:42:11 +00:00
|
|
|
set(REQUIRED_LIBPORTAL_VERSION 0.9.1)
|
2024-12-02 02:17:03 +00:00
|
|
|
set(REQUIRED_QT_VERSION 6.7.0)
|
2025-03-11 16:48:39 +00:00
|
|
|
|
2025-04-21 05:25:31 +00:00
|
|
|
if (WIN32)
|
2025-05-03 01:33:44 +00:00
|
|
|
# VSCMD_ARG_TGT_ARCH is set on CI
|
2025-04-21 05:25:31 +00:00
|
|
|
if ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "")
|
2025-05-03 01:33:44 +00:00
|
|
|
# NOT on CI
|
|
|
|
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "[Aa][Rr][Mm]64")
|
|
|
|
|
set(BUILD_ARCHITECTURE arm64)
|
|
|
|
|
else()
|
|
|
|
|
set(BUILD_ARCHITECTURE x64)
|
|
|
|
|
endif()
|
2025-04-21 05:25:31 +00:00
|
|
|
else()
|
|
|
|
|
set (BUILD_ARCHITECTURE $ENV{VSCMD_ARG_TGT_ARCH})
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
set (BUILD_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-03-11 16:48:39 +00:00
|
|
|
if (MSVC)
|
2026-07-13 08:43:31 +00:00
|
|
|
# Require the same MSVC runtime that built the binary. Mitigates access violations
|
|
|
|
|
# from accidental ABI-compatibility breakage across runtime minor versions.
|
|
|
|
|
#
|
|
|
|
|
# Derive the minor from the compiler toolset (cl major 19 maps to CRT major 14 and
|
|
|
|
|
# the minor matches, e.g. 19.44 -> 14.44) rather than the host's installed redist
|
|
|
|
|
# from the registry. The toolset version tracks the runtime it actually produces,
|
|
|
|
|
# including the debug CRT (vcruntime140d.dll); the registry redist can be newer than
|
|
|
|
|
# the loaded DLL and make the runtime guard reject a valid local build.
|
2025-03-11 16:48:39 +00:00
|
|
|
set(REQUIRED_MSVC_RUNTIME_MAJOR 14)
|
2026-07-13 08:43:31 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_VERSION MATCHES "^[0-9]+\\.([0-9]+)")
|
|
|
|
|
set(REQUIRED_MSVC_RUNTIME_MINOR "${CMAKE_MATCH_1}")
|
2025-03-11 16:48:39 +00:00
|
|
|
message(STATUS "MSVC runtime: ${REQUIRED_MSVC_RUNTIME_MAJOR}.${REQUIRED_MSVC_RUNTIME_MINOR}")
|
|
|
|
|
else()
|
2026-07-13 08:43:31 +00:00
|
|
|
message(FATAL_ERROR "Failed to parse MSVC compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
|
2025-03-11 16:48:39 +00:00
|
|
|
endif()
|
|
|
|
|
endif()
|
2024-12-02 01:21:22 +00:00
|
|
|
|
2024-12-04 19:24:04 +00:00
|
|
|
# Control debug item visibility
|
|
|
|
|
# When not set logging is forced to DEBUG and show code locations
|
|
|
|
|
# Also exposes a test menu
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
|
message(STATUS "Disabling debug build")
|
|
|
|
|
add_definitions(-DNDEBUG)
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-12-01 23:36:48 +00:00
|
|
|
# Set Output Folders
|
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
|
|
|
|
|
2025-05-31 15:35:37 +00:00
|
|
|
# disables the use of signals,slots and emit
|
|
|
|
|
# Instead use Q_SIGNAL, Q_SLOT and Q_EMIT
|
|
|
|
|
# prevents issues when used with glib for libportal
|
|
|
|
|
add_definitions(-DQT_NO_KEYWORDS)
|
2025-11-13 16:48:30 +00:00
|
|
|
|
|
|
|
|
#Options for Linux platform support
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
|
option(BUILD_X11_SUPPORT "Build with x11 support" ON)
|
2025-11-19 23:50:51 +00:00
|
|
|
elseif (APPLE)
|
|
|
|
|
option(BUILD_OSX_BUNDLE "Build mac os bundle" ON)
|
2025-11-13 16:48:30 +00:00
|
|
|
endif()
|
|
|
|
|
|
2024-07-02 10:23:56 +00:00
|
|
|
include(cmake/Libraries.cmake)
|
|
|
|
|
configure_libs()
|
2024-06-24 09:36:30 +00:00
|
|
|
|
2026-03-05 18:13:34 +00:00
|
|
|
if(BUILD_OSX_BUNDLE AND APPLE_CODESIGN_DEV)
|
|
|
|
|
include(cmake/MacCodesign.cmake)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-11-08 15:41:29 +00:00
|
|
|
# setup install paths
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
if (WIN32)
|
2025-11-08 17:09:35 +00:00
|
|
|
set(CMAKE_INSTALL_BINDIR .)
|
2025-11-08 17:13:00 +00:00
|
|
|
set(CMAKE_INSTALL_LIBDIR .)
|
2026-02-22 22:16:43 +00:00
|
|
|
set(CMAKE_INSTALL_DOCDIR docs)
|
2025-11-08 15:41:29 +00:00
|
|
|
set(CMAKE_INSTALL_LICENSE_DIR .)
|
2025-11-08 16:00:34 +00:00
|
|
|
set(CMAKE_INSTALL_I18N_DIR translations)
|
2025-11-19 23:50:51 +00:00
|
|
|
elseif(BUILD_OSX_BUNDLE)
|
2025-11-19 12:54:02 +00:00
|
|
|
set(CMAKE_INSTALL_BINDIR ${CMAKE_PROJECT_PROPER_NAME}.app/Contents/MacOS)
|
|
|
|
|
set(CMAKE_INSTALL_LICENSE_DIR ${CMAKE_PROJECT_PROPER_NAME}.app/Contents/Resources)
|
2025-11-19 23:50:51 +00:00
|
|
|
else()
|
|
|
|
|
set(CMAKE_INSTALL_LICENSE_DIR ${CMAKE_INSTALL_DATADIR}/licenses/${CMAKE_PROJECT_NAME})
|
|
|
|
|
set(CMAKE_INSTALL_I18N_DIR ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/translations)
|
2025-11-08 15:41:29 +00:00
|
|
|
endif()
|
|
|
|
|
|
2026-02-22 20:51:20 +00:00
|
|
|
add_subdirectory(docs)
|
2025-12-13 02:33:14 +00:00
|
|
|
|
|
|
|
|
# build translations before source, I18N unit tests fail if they are missing
|
2025-10-15 02:39:45 +00:00
|
|
|
add_subdirectory(translations)
|
2024-07-18 07:04:39 +00:00
|
|
|
|
2025-12-13 02:33:14 +00:00
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
2024-11-18 22:54:04 +00:00
|
|
|
option(BUILD_INSTALLER "Build installer" ON)
|
|
|
|
|
if(BUILD_INSTALLER)
|
|
|
|
|
add_subdirectory(deploy)
|
|
|
|
|
endif()
|
2025-11-08 15:41:29 +00:00
|
|
|
|
2026-02-23 22:20:26 +00:00
|
|
|
install(
|
|
|
|
|
FILES ${PROJECT_SOURCE_DIR}/LICENSE
|
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LICENSE_DIR}
|
|
|
|
|
)
|
|
|
|
|
|
2025-11-08 15:41:29 +00:00
|
|
|
install(
|
|
|
|
|
FILES ${PROJECT_SOURCE_DIR}/LICENSES/LicenseRef-OpenSSL-Exception.txt
|
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LICENSE_DIR}
|
|
|
|
|
RENAME LICENSE_EXCEPTION
|
|
|
|
|
)
|