Skip to content

Commit 19aee58

Browse files
committed
fix: resolve Windows CI segfaults from CRT mismatch and FreeType-HarfBuzz interaction
Three fixes for MSVC/clang-cl test crashes: 1. Set CMP0091 to NEW before project() so CMAKE_MSVC_RUNTIME_LIBRARY (static CRT /MT) takes effect for the top-level build. 2. Set CMAKE_POLICY_DEFAULT_CMP0091 NEW before each FetchContent subproject (FreeType, HarfBuzz) whose cmake_minimum_required resets the policy, preventing CRT mismatch between /MT and /MD that causes heap corruption. 3. Set FT_DISABLE_HARFBUZZ ON before building FreeType to prevent its find_package(HarfBuzz) from finding a partial match when HarfBuzz is also enabled, which would enable FT_CONFIG_OPTION_USE_HARFBUZZ inside FreeType and cause unresolved symbol crashes in test binaries.
1 parent 1955edb commit 19aee58

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
cmake_minimum_required(VERSION 3.21)
22

3+
if(POLICY CMP0091)
4+
cmake_policy(SET CMP0091 NEW)
5+
endif()
6+
37
project(VEFontCache LANGUAGES C CXX)
48

59
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
@@ -22,6 +26,7 @@ set(VRHI_VERSION "v0.1.4" CACHE STRING "VRHI release version to fetch")
2226
include(FetchContent)
2327

2428
if(VEFC_ENABLE_FREETYPE)
29+
set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "" FORCE)
2530
FetchContent_Declare(
2631
freetype
2732
GIT_REPOSITORY https://github.com/freetype/freetype.git
@@ -30,17 +35,21 @@ if(VEFC_ENABLE_FREETYPE)
3035
if(POLICY CMP0077)
3136
cmake_policy(SET CMP0077 NEW)
3237
endif()
38+
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
3339
FetchContent_MakeAvailable(freetype)
40+
unset(CMAKE_POLICY_DEFAULT_CMP0091)
3441
endif()
3542

3643
if(VEFC_ENABLE_HARFBUZZ)
44+
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
3745
FetchContent_Declare(
3846
harfbuzz
3947
GIT_REPOSITORY https://github.com/harfbuzz/harfbuzz.git
4048
GIT_TAG 11.2.1
4149
)
4250
set(HB_BUILD_SUBSET OFF CACHE BOOL "" FORCE)
4351
FetchContent_MakeAvailable(harfbuzz)
52+
unset(CMAKE_POLICY_DEFAULT_CMP0091)
4453
endif()
4554

4655
if(VEFC_BUILD_DEMO OR VEFC_BUILD_VRHI)

0 commit comments

Comments
 (0)