Merge branch 'master' into tooomm-patch-33

This commit is contained in:
tooomm 2026-09-12 16:35:36 +02:00 committed by GitHub
commit 860ff503b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
233 changed files with 7900 additions and 1711 deletions

View file

@ -4,8 +4,8 @@
# Cockatrice, Oracle, Servatrice, Test
# This file sets all the variables shared between the projects like the installation path, compilation flags etc..
# CMake 3.16 is required if using Qt6
cmake_minimum_required(VERSION 3.10)
# CMake 3.16 is required for Qt6 and target_precompile_headers()
cmake_minimum_required(VERSION 3.16)
# Compile Cockatrice
option(WITH_CLIENT "Build Cockatrice client" ON)
@ -18,10 +18,10 @@ option(TEST "Build tests" OFF)
# Check for translation updates
option(UPDATE_TRANSLATIONS "Update translations on compile" OFF)
# Use compiler cache (ccache)
option(USE_CCACHE "Cache the build results with ccache" ON)
# Use vcpkg regardless of OS
option(USE_VCPKG "Use vcpkg regardless of OS" OFF)
# Use compiler cache (ccache)
option(USE_CCACHE "Cache the build results with ccache" OFF)
# Treat warnings as errors (Debug builds only)
option(WARNING_AS_ERROR "Treat warnings as errors in debug builds" ON)
@ -34,13 +34,24 @@ if(NOT CMAKE_BUILD_TYPE)
)
endif()
if(USE_CCACHE)
# ccache does not support MSVC and must not auto-engage on Windows
# (it is installed unintentionally on the Windows CI runner).
# NOTE: this keys off the target OS, so a mingw/Ninja configuration on Windows
# also opts out of ccache even though the GNUCXX branch below supports it.
if(USE_CCACHE AND NOT WIN32)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
# Support Unix Makefiles and Ninja
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
# PCH-aware caching, matching .ci/compile.sh: without this ccache refuses
# to cache any TU that consumes a precompiled header, so every PCH-backed
# target recompiles from scratch on each build.
execute_process(COMMAND ${CCACHE_PROGRAM} --set-config sloppiness=pch_defines,time_macros)
message(STATUS "Found CCache ${CCACHE_PROGRAM}")
endif()
elseif(USE_CCACHE AND WIN32)
# An explicit opt-in must not disappear silently on Windows.
message(STATUS "ccache disabled: not supported for the MSVC toolchain on Windows")
endif()
if(WIN32 OR USE_VCPKG)
@ -205,6 +216,9 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # GCC compiler
endif()
endforeach()
# Reduce compiler I/O by using pipes between stages instead of temp files
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Clang compiler
# -O2 Balanced optimization
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
@ -221,11 +235,13 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Clang compiler
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra")
endif()
# Reduce compiler I/O by using pipes between stages instead of temp files
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe") # <-- required for clang? see adding pr description again
else() # Undefined compiler
message(WARNING
"Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}"
)
endif()
# GNU systems need to define the Mersenne Exponent for SFMT for the RNG to compile without warning
@ -274,11 +290,6 @@ if(WIN32) # Windows (including 64bit)
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIRS})
else()
message(
WARNING
"Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime."
)
endif()
endif()