Merge pull request #6977 from kambala-decapitator/msvc-check-cxx23

[cmake][msvc] fix checking for C++23 availability
This commit is contained in:
Ivan Savenko
2026-02-26 17:44:02 +02:00
committed by GitHub
2 changed files with 17 additions and 1 deletions
+9 -1
View File
@@ -100,7 +100,15 @@ else()
option(ENABLE_LOBBY "Enable compilation of lobby server" OFF)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++23" COMPILER_SUPPORTS_CXX23)
if(MSVC)
check_cxx_compiler_flag("/std:c++23" COMPILER_SUPPORTS_CXX23)
if(NOT COMPILER_SUPPORTS_CXX23)
check_cxx_compiler_flag("/std:c++23preview" COMPILER_SUPPORTS_CXX23_PREVIEW)
set(COMPILER_SUPPORTS_CXX23 ${COMPILER_SUPPORTS_CXX23_PREVIEW})
endif()
else()
check_cxx_compiler_flag("-std=c++23" COMPILER_SUPPORTS_CXX23)
endif()
if(COMPILER_SUPPORTS_CXX23 # C++23 features needed
AND (MACOS
AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" # skip intel for apple (compile issue)
+8
View File
@@ -552,9 +552,17 @@ if (ENABLE_DISCORD)
find_package(fmt ${findOptions})
find_package(glaze ${findOptions})
if(MSVC AND ENABLE_STRICT_COMPILATION)
# fmt built via CPM has compile warning which becomes an error
set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
endif()
add_subdirectory(lib/discord-presence)
target_link_libraries(vcmiclientcommon PRIVATE discord-rpc)
target_compile_definitions(vcmiclientcommon PRIVATE ENABLE_DISCORD)
if(OLD_CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
endif()
endif()
vcmi_set_output_dir(vcmiclientcommon "")