From 00e634f1db9ca16300ed04d1a0f8367a2bc1f3d9 Mon Sep 17 00:00:00 2001 From: Bruno Alexandre Rosa <1791393+brunoalr@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:18:39 -0300 Subject: [PATCH 1/3] ci: use ninja in Windows builds --- .ci/compile.sh | 2 +- .github/workflows/desktop-build.yml | 18 +++++++----------- CMakeLists.txt | 8 +++++--- cockatrice/CMakeLists.txt | 2 +- oracle/CMakeLists.txt | 2 +- servatrice/CMakeLists.txt | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.ci/compile.sh b/.ci/compile.sh index 424527f96..946b4c991 100755 --- a/.ci/compile.sh +++ b/.ci/compile.sh @@ -227,7 +227,7 @@ if [[ $RUNNER_OS == macOS ]]; then flags+=(-DCPACK_COMMAND_HDIUTIL="$hdiutil_script") fi -elif [[ $RUNNER_OS == Windows ]]; then +elif [[ $RUNNER_OS == Windows ]] && [[ "$CMAKE_GENERATOR" != *Ninja* ]]; then # Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/ # and https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#multitooltask-mtt buildflags+=(-- -p:UseMultiToolTask=true -p:EnableClServerMode=true) diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml index 02c3f7aec..3f5325bbe 100644 --- a/.github/workflows/desktop-build.yml +++ b/.github/workflows/desktop-build.yml @@ -320,8 +320,7 @@ jobs: qt_version: 6.10.* qt_arch: win64_msvc2022_64 qt_modules: qtimageformats qtmultimedia qtwebsockets - cmake_generator: "Visual Studio 17 2022" - cmake_generator_platform: x64 + cmake_generator: Ninja name: ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} needs: configure @@ -338,12 +337,10 @@ jobs: with: submodules: recursive - - name: Add msbuild to PATH + # Set relevant environment variables for MSVC, used to ensure ninja + MSVC build correctly together + - name: Setup MSVC (Windows) if: matrix.os == 'Windows' - id: add-msbuild - uses: microsoft/setup-msbuild@v2 - with: - msbuild-architecture: x64 + uses: ilammy/msvc-dev-cmd@v1.13.0 - name: Setup ccache if: matrix.use_ccache == 1 && matrix.os == 'macOS' @@ -429,7 +426,6 @@ jobs: MAKE_PACKAGE: '${{matrix.make_package}}' PACKAGE_SUFFIX: '${{matrix.package_suffix}}' CMAKE_GENERATOR: ${{matrix.cmake_generator}} - CMAKE_GENERATOR_PLATFORM: ${{matrix.cmake_generator_platform}} USE_CCACHE: ${{matrix.use_ccache}} VCPKG_DISABLE_METRICS: 1 VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite' @@ -516,9 +512,9 @@ jobs: with: name: ${{steps.build.outputs.name}}-PDBs path: | - build/cockatrice/Release/*.pdb - build/oracle/Release/*.pdb - build/servatrice/Release/*.pdb + build/cockatrice/**/*.pdb + build/oracle/**/*.pdb + build/servatrice/**/*.pdb if-no-files-found: error - name: Upload to release diff --git a/CMakeLists.txt b/CMakeLists.txt index fe808a652..6bbd8054e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,8 +140,8 @@ endif() # Define proper compilation flags if(MSVC) - # Disable Warning C4251, C++20 compatibility, Multi-threaded Builds, Warn Detection, Unwind Semantics, Debug Symbols - set(CMAKE_CXX_FLAGS "/wd4251 /Zc:__cplusplus /std:c++20 /permissive- /W4 /MP /EHsc /Zi") + # Disable Warning C4251, C++20 compatibility, Multi-threaded Builds, Warn Detection, Unwind Semantics, Debug Symbols, Force Synchronous PDB writes + set(CMAKE_CXX_FLAGS "/wd4251 /Zc:__cplusplus /std:c++20 /permissive- /W4 /MP /EHsc /Zi /FS") # Visual Studio: Maximum Optimization, Multi-threaded DLL set(CMAKE_CXX_FLAGS_RELEASE "/Ox /MD") # Visual Studio: No Optimization, Multi-threaded Debug DLL @@ -311,7 +311,9 @@ if(UNIX) endif() elseif(WIN32) set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) - if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "(x64)") + # This a generator-agnostic way to determine if the build is 64-bit or 32-bit. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_SIZEOF_VOID_P.html + if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(TRICE_IS_64_BIT 1) else() set(TRICE_IS_64_BIT 0) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 1ca3c77c2..8da6fc314 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -529,7 +529,7 @@ if(WIN32) set(qtconf_dest_dir .) install( - DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" + DIRECTORY "$/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll" diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 3bb4de5df..eeacaee76 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -234,7 +234,7 @@ if(WIN32) list(APPEND libSearchDirs ${QT_LIBRARY_DIR}) install( - DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" + DIRECTORY "$/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll" diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 6e4191beb..98290803a 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -184,7 +184,7 @@ if(WIN32) set(qtconf_dest_dir .) install( - DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" + DIRECTORY "$/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll" From 9224460bf4bf9d3ffe90cf50a58af31de44a3c49 Mon Sep 17 00:00:00 2001 From: Bruno Alexandre Rosa <1791393+brunoalr@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:37:01 -0300 Subject: [PATCH 2/3] explicit arch --- .github/workflows/desktop-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml index 3f5325bbe..e22b1e0a5 100644 --- a/.github/workflows/desktop-build.yml +++ b/.github/workflows/desktop-build.yml @@ -341,6 +341,8 @@ jobs: - name: Setup MSVC (Windows) if: matrix.os == 'Windows' uses: ilammy/msvc-dev-cmd@v1.13.0 + with: + arch: x64 - name: Setup ccache if: matrix.use_ccache == 1 && matrix.os == 'macOS' From 80e2ccc18b58b892f3a684e740737406add7fb6b Mon Sep 17 00:00:00 2001 From: Bruno Alexandre Rosa <1791393+brunoalr@users.noreply.github.com> Date: Mon, 23 Mar 2026 18:39:56 -0300 Subject: [PATCH 3/3] add WindowsToolchain --- .github/workflows/desktop-build.yml | 7 ------- .gitmodules | 3 +++ CMakeLists.txt | 12 ++++++++++++ cmake/WindowsToolchain | 1 + 4 files changed, 16 insertions(+), 7 deletions(-) create mode 160000 cmake/WindowsToolchain diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml index e22b1e0a5..6843332c6 100644 --- a/.github/workflows/desktop-build.yml +++ b/.github/workflows/desktop-build.yml @@ -337,13 +337,6 @@ jobs: with: submodules: recursive - # Set relevant environment variables for MSVC, used to ensure ninja + MSVC build correctly together - - name: Setup MSVC (Windows) - if: matrix.os == 'Windows' - uses: ilammy/msvc-dev-cmd@v1.13.0 - with: - arch: x64 - - name: Setup ccache if: matrix.use_ccache == 1 && matrix.os == 'macOS' run: brew install ccache diff --git a/.gitmodules b/.gitmodules index 732fec7ca..476fa6da8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "doxygen-awesome-css"] path = doc/doxygen/theme url = https://github.com/jothepro/doxygen-awesome-css.git +[submodule "cmake/WindowsToolchain"] + path = cmake/WindowsToolchain + url = https://github.com/MarkSchofield/WindowsToolchain.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bbd8054e..d9cd15faa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,18 @@ if(WIN32 OR USE_VCPKG) endif() endif() +if(WIN32 + AND USE_VCPKG + AND CMAKE_GENERATOR STREQUAL "Ninja" +) + # vcpkg.cmake must be the primary toolchain; MSVC+Ninja toolchain is chainloaded + # See https://github.com/MarkSchofield/WindowsToolchain#windowstoolchain-and-vcpkg + set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsToolchain/Windows.MSVC.toolchain.cmake" + CACHE FILEPATH "Chainloaded MSVC toolchain file for Ninja generator" + ) +endif() + # A project name is needed for CPack # Version can be overriden by git tags, see cmake/getversion.cmake project("Cockatrice" VERSION 2.11.0) diff --git a/cmake/WindowsToolchain b/cmake/WindowsToolchain new file mode 160000 index 000000000..4dc30a8bf --- /dev/null +++ b/cmake/WindowsToolchain @@ -0,0 +1 @@ +Subproject commit 4dc30a8bf484f41d5a16eec97b9284a52042e2b4