From e802a37a20accff21be0e36888b4367fbbd178f8 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Wed, 28 Oct 2026 12:33:02 -0500 Subject: [PATCH] Fix ninja build on windows The generator expression contained an extra colon, which causes only the C source files to get the desired expression. And because detours & gtest do not enable /guard:ehcont on their own, we have to enable it for them so that everything has it enabled in order to make the linker happy. --- CMakeLists.txt | 2 +- tests/CMakeLists.txt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 619ab26fc..a889a8810 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,7 +268,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" A # Enable EH Continuation Metadata for 64-bit architectures if (CMAKE_SIZEOF_VOID_P EQUAL 8) - target_compile_options(loader_common_options INTERFACE $<$:/guard:ehcont>) + target_compile_options(loader_common_options INTERFACE $<$:/guard:ehcont>) target_link_options(loader_common_options INTERFACE "LINKER:/guard:ehcont") endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 59092129f..c0c9d349f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -68,6 +68,14 @@ if (WIN32) endif() endif() +# Make sure our deps also enable /guard:ehcont as on windows ninja wont build without it +if ((CMAKE_C_COMPILER_ID MATCHES "MSVC" OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")) AND CMAKE_SIZEOF_VOID_P EQUAL 8) + target_compile_options(gtest PUBLIC "/guard:ehcont") + target_link_options(gtest PUBLIC "LINKER:/guard:ehcont") + target_compile_options(detours PUBLIC "/guard:ehcont") + target_link_options(detours PUBLIC "LINKER:/guard:ehcont") +endif() + option(ENABLE_LIVE_VERIFICATION_TESTS "Enable tests which expect to run on live drivers. Meant for manual verification only" OFF) set(TEST_EXECUTION_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/executing_tests")