diff --git a/CMakeLists.txt b/CMakeLists.txt index 036113278..165b80d88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ) +if(WIN32 AND NOT MINGW) + include(EnableSegmentHeap) +endif() + option(BUILD_APP "Build Chatterino" ON) option(BUILD_TESTS "Build the tests for Chatterino" OFF) option(BUILD_BENCHMARKS "Build the benchmarks for Chatterino" OFF) diff --git a/cmake/EnableSegmentHeap.cmake b/cmake/EnableSegmentHeap.cmake new file mode 100644 index 000000000..31373a734 --- /dev/null +++ b/cmake/EnableSegmentHeap.cmake @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2026 Contributors to Chatterino +# +# SPDX-License-Identifier: CC0-1.0 + +if(NOT DEFINED ENV{VSINSTALLDIR}) + message(WARNING "Missing VSINSTALLDIR environment variable - not enabling segment heap.") + return() +endif() + +set(segment_heap_path "$ENV{VSINSTALLDIR}Common7/IDE/CommonExtensions/Microsoft/CMake/cmake/Microsoft/SegmentHeap.cmake") +if (NOT EXISTS "${segment_heap_path}") + message(STATUS "Missing '${segment_heap_path}'. Segment heap will be disabled - consider updating Visual Studio.") + return() +endif() + +message(STATUS "Including segment heap script from '${segment_heap_path}'.") +include("${segment_heap_path}")