Skip to content

Commit 647b2df

Browse files
committed
Improve C++20 support check in CMake for MSVC and enhance messaging
1 parent d6da0de commit 647b2df

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,21 @@ gtest_discover_tests(httplib-test)
3333

3434
# C++20 streaming API tests
3535
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang|MSVC")
36-
# Check for C++20 support
37-
include(CheckCXXCompilerFlag)
36+
# Check for C++20 support using CMake's compile features
37+
# This is more reliable than checking compiler flags
3838
if(MSVC)
39-
check_cxx_compiler_flag("/std:c++20" COMPILER_SUPPORTS_CXX20)
39+
# MSVC 19.29+ (VS 2019 16.10+) supports C++20 coroutines
40+
if(MSVC_VERSION GREATER_EQUAL 1929)
41+
set(COMPILER_SUPPORTS_CXX20 TRUE)
42+
else()
43+
set(COMPILER_SUPPORTS_CXX20 FALSE)
44+
endif()
4045
else()
46+
include(CheckCXXCompilerFlag)
4147
check_cxx_compiler_flag("-std=c++20" COMPILER_SUPPORTS_CXX20)
4248
endif()
4349

50+
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}, MSVC_VERSION: ${MSVC_VERSION}")
4451
message(STATUS "C++20 support: ${COMPILER_SUPPORTS_CXX20}")
4552

4653
if(COMPILER_SUPPORTS_CXX20)

0 commit comments

Comments
 (0)