From 1eb9a8efbd3bd66cde3a25ed016b5227edc16f5c Mon Sep 17 00:00:00 2001 From: Wachhund Skytower Date: Fri, 24 Apr 2026 08:07:24 +0200 Subject: [PATCH] Fix Windows test linking: use main() instead of wmain() (#12939) wxWidgets defines _UNICODE globally, which causes Catch2's catch_main.cpp to provide wmain() instead of main(). This leads to LNK2001 "unresolved external symbol main" for all test executables when building with BUILD_TESTS=ON on MSVC. Add DO_NOT_USE_WMAIN compile definition to Catch2WithMain target so that Catch2 provides the standard main() entry point. Co-authored-by: Claude Opus 4.6 (1M context) --- tests/catch2/src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/catch2/src/CMakeLists.txt b/tests/catch2/src/CMakeLists.txt index 554346f49a..a0acf2272a 100644 --- a/tests/catch2/src/CMakeLists.txt +++ b/tests/catch2/src/CMakeLists.txt @@ -385,6 +385,10 @@ target_include_directories(Catch2 add_library(Catch2WithMain ${SOURCES_DIR}/internal/catch_main.cpp ) +# Force standard main() entry point instead of wmain() on Windows. +# wxWidgets defines _UNICODE globally, which causes Catch2 to use wmain, +# but test executables expect a standard main() entry point. +target_compile_definitions(Catch2WithMain PRIVATE DO_NOT_USE_WMAIN) if(CATCH_ENABLE_REPRODUCIBLE_BUILD) add_build_reproducibility_settings(Catch2WithMain) endif()