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) <noreply@anthropic.com>
This commit is contained in:
Wachhund Skytower
2026-04-24 08:07:24 +02:00
committed by GitHub
parent f9f5425a33
commit 1eb9a8efbd

View File

@@ -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()