From bb151db135c701d057b6d4221a2586acfee506ca Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Mon, 20 Apr 2026 22:17:12 -0700 Subject: [PATCH 1/2] Add MakeSpriteFont to CMake build --- .github/workflows/main.yml | 8 +++++++- CMakeLists.txt | 4 ++++ CMakePresets.json | 14 ++++++++++++++ MakeSpriteFont/CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 MakeSpriteFont/CMakeLists.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 472bd044..c174cb99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,9 +70,15 @@ jobs: - toolver: '14' build_type: x86-Release-Clang arch: amd64_x86 + - toolver: '14' + build_type: x64-Debug-VS + arch: amd64 + - toolver: '14' + build_type: x86-Debug-VS + arch: amd64_x86 steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: 'Install Ninja' run: choco install ninja diff --git a/CMakeLists.txt b/CMakeLists.txt index 36342db3..2ac61e64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,6 +446,10 @@ if(TOOL_EXES) message(STATUS "Building tools: ${TOOL_EXES}") endif() +if (BUILD_TOOLS AND (CMAKE_GENERATOR MATCHES "Visual Studio")) + add_subdirectory(MakeSpriteFont) +endif() + # Model uses dynamic_cast, so we need /GR (Enable RTTI) if(MSVC) foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) diff --git a/CMakePresets.json b/CMakePresets.json index 63978a32..1f921e47 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -14,6 +14,15 @@ "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}" }, + { + "name": "vsbase", + "displayName": "Visual Studio Basic Config", + "description": "Basic build using Visual Studio generator", + "generator": "Visual Studio 17 2022", + "hidden": true, + "binaryDir": "${sourceDir}/out/build/${presetName}", + "installDir": "${sourceDir}/out/install/${presetName}" + }, { "name": "x64", "architecture": { @@ -249,6 +258,11 @@ { "name": "x86-Debug" , "description": "MSVC for x86 (Debug) for Windows 8", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, { "name": "x86-Release" , "description": "MSVC for x86 (Release) for Windows 8", "inherits": [ "base", "x86", "Release", "MSVC" ] }, + { "name": "x64-Debug-VS" , "description": "MSVC for x64 (Debug) w/ MakeSpriteFont", "inherits": [ "vsbase", "x64", "Debug", "MSVC" ] }, + { "name": "x64-Release-VS" , "description": "MSVC for x64 (Release) w/ MakeSpriteFont", "inherits": [ "vsbase", "x64", "Release", "MSVC" ] }, + { "name": "x86-Debug-VS" , "description": "MSVC for x86 (Debug) w/ MakeSpriteFont", "inherits": [ "vsbase", "x86", "Debug", "MSVC" ] }, + { "name": "x86-Release-VS" , "description": "MSVC for x86 (Release) w/ MakeSpriteFont", "inherits": [ "vsbase", "x86", "Release", "MSVC" ] }, + { "name": "x64-Debug-Win10" , "description": "MSVC for x64 (Debug) for Windows 10", "inherits": [ "base", "x64", "Debug", "MSVC", "Win10" ] }, { "name": "x64-Release-Win10" , "description": "MSVC for x64 (Release) for Windows 10", "inherits": [ "base", "x64", "Release", "MSVC", "Win10" ] }, { "name": "x86-Debug-Win10" , "description": "MSVC for x86 (Debug) for Windows 10", "inherits": [ "base", "x86", "Debug", "MSVC", "Win10" ] }, diff --git a/MakeSpriteFont/CMakeLists.txt b/MakeSpriteFont/CMakeLists.txt new file mode 100644 index 00000000..68a64d26 --- /dev/null +++ b/MakeSpriteFont/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +cmake_minimum_required (VERSION 3.21) + +project (MakeSpriteFont + DESCRIPTION "DirectX Tool Kit SpriteFont tool" + HOMEPAGE_URL "https://github.com/microsoft/DirectXTK" + LANGUAGES CSharp) + +add_executable(${PROJECT_NAME} + BitmapImporter.cs + BitmapUtils.cs + CharacterRegion.cs + CommandLineOptions.cs + CommandLineParser.cs + Glyph.cs + GlyphCropper.cs + GlyphPacker.cs + IFontImporter.cs + Program.cs + Properties/AssemblyInfo.cs + SpriteFontWriter.cs + TrueTypeImporter.cs) + + set_property(TARGET ${PROJECT_NAME} + PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.7.2" + PROPERTY WIN32_EXECUTABLE TRUE) + + set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES + "Microsoft.CSharp" + "System" + "System.Drawing") + +set(CMAKE_CSharp_FLAGS "/platform:AnyCPU") From c686d7e4017153f6202d9616c737ea63e5be167a Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Mon, 20 Apr 2026 22:27:12 -0700 Subject: [PATCH 2/2] Code review --- .github/workflows/main.yml | 4 ++-- CMakeLists.txt | 7 +++---- CMakePresets.json | 8 +++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c174cb99..bcf2059f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,10 +71,10 @@ jobs: build_type: x86-Release-Clang arch: amd64_x86 - toolver: '14' - build_type: x64-Debug-VS + build_type: x64-VS arch: amd64 - toolver: '14' - build_type: x86-Debug-VS + build_type: x86-VS arch: amd64_x86 steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ac61e64..962db6d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -442,12 +442,11 @@ if(directxmath_FOUND) endforeach() endif() -if(TOOL_EXES) - message(STATUS "Building tools: ${TOOL_EXES}") -endif() - if (BUILD_TOOLS AND (CMAKE_GENERATOR MATCHES "Visual Studio")) + message(STATUS "Building tools: MakeSpriteFont;${TOOL_EXES}") add_subdirectory(MakeSpriteFont) +elseif(TOOL_EXES) + message(STATUS "Building tools: ${TOOL_EXES}") endif() # Model uses dynamic_cast, so we need /GR (Enable RTTI) diff --git a/CMakePresets.json b/CMakePresets.json index 1f921e47..a0f0ea01 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -258,11 +258,6 @@ { "name": "x86-Debug" , "description": "MSVC for x86 (Debug) for Windows 8", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, { "name": "x86-Release" , "description": "MSVC for x86 (Release) for Windows 8", "inherits": [ "base", "x86", "Release", "MSVC" ] }, - { "name": "x64-Debug-VS" , "description": "MSVC for x64 (Debug) w/ MakeSpriteFont", "inherits": [ "vsbase", "x64", "Debug", "MSVC" ] }, - { "name": "x64-Release-VS" , "description": "MSVC for x64 (Release) w/ MakeSpriteFont", "inherits": [ "vsbase", "x64", "Release", "MSVC" ] }, - { "name": "x86-Debug-VS" , "description": "MSVC for x86 (Debug) w/ MakeSpriteFont", "inherits": [ "vsbase", "x86", "Debug", "MSVC" ] }, - { "name": "x86-Release-VS" , "description": "MSVC for x86 (Release) w/ MakeSpriteFont", "inherits": [ "vsbase", "x86", "Release", "MSVC" ] }, - { "name": "x64-Debug-Win10" , "description": "MSVC for x64 (Debug) for Windows 10", "inherits": [ "base", "x64", "Debug", "MSVC", "Win10" ] }, { "name": "x64-Release-Win10" , "description": "MSVC for x64 (Release) for Windows 10", "inherits": [ "base", "x64", "Release", "MSVC", "Win10" ] }, { "name": "x86-Debug-Win10" , "description": "MSVC for x86 (Debug) for Windows 10", "inherits": [ "base", "x86", "Debug", "MSVC", "Win10" ] }, @@ -273,6 +268,9 @@ { "name": "arm64ec-Debug" , "description": "MSVC for ARM64EC (Debug) for Windows 10", "inherits": [ "base", "ARM64EC", "Debug", "MSVC", "Win10" ] }, { "name": "arm64ec-Release" , "description": "MSVC for ARM64EC (Release) for Windows 10", "inherits": [ "base", "ARM64EC", "Release", "MSVC", "Win10" ] }, + { "name": "x64-VS" , "description": "MSVC for x64 w/ Visual Studio generator", "inherits": [ "vsbase", "x64", "MSVC" ] }, + { "name": "x86-VS" , "description": "MSVC for x86 w/ Visual Studio generator", "inherits": [ "vsbase", "x86", "MSVC" ] }, + { "name": "x64-Debug-UWP" , "description": "MSVC for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "MSVC", "UWP" ] }, { "name": "x64-Release-UWP" , "description": "MSVC for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "MSVC", "UWP" ] }, { "name": "x86-Debug-UWP" , "description": "MSVC for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "MSVC", "UWP" ] },