fix(windows): properly detect clang-cl and add /std:c++latest for std::filesystem
Root cause analysis: - clang-cl on GitHub Actions Windows Server 2022 cannot find std::filesystem - The compiler defaults to pre-C++17 compatibility, exposing only std::experimental::filesystem - Build logs show: -std=c++23 (Unix-style flag) instead of /std:c++latest (MSVC-style flag) Key insight: CMAKE_CXX_COMPILER_FRONTEND_VARIANT is needed to distinguish: - "MSVC": clang-cl (Clang with MSVC command-line interface) - "GNU": regular Clang on Windows Solution: 1. Use CMAKE_CXX_COMPILER_FRONTEND_VARIANT to properly detect clang-cl 2. Add /std:c++latest flag specifically to yaze_util target (where filesystem is used) 3. Apply as PUBLIC compile option so it propagates to dependent targets This targets the exact source of the problem - clang-cl needs MSVC-style /std:c++latest flag to access modern MSVC STL features including std::filesystem. Tested approach based on CMake 3.16+ feature CMAKE_CXX_COMPILER_FRONTEND_VARIANT. Related commits:19196ca87c,c2bb90a3f1,b556b155a5Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -40,28 +40,12 @@ function(yaze_add_compiler_flags)
|
||||
|
||||
# Compiler-specific settings
|
||||
if(MSVC)
|
||||
# Check if we're using clang-cl (Clang with MSVC-compatible command line)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# clang-cl requires explicit /std:c++latest to access C++23 features including <filesystem>
|
||||
# Without this, clang-cl only sees std::experimental::filesystem from older MSVC STL
|
||||
target_compile_options(yaze_common INTERFACE
|
||||
/EHsc
|
||||
/W4 /permissive-
|
||||
/bigobj
|
||||
/utf-8
|
||||
/std:c++latest
|
||||
)
|
||||
message(STATUS "Windows clang-cl: Added /std:c++latest for C++23 and std::filesystem support")
|
||||
else()
|
||||
# Regular MSVC compiler
|
||||
target_compile_options(yaze_common INTERFACE
|
||||
/EHsc
|
||||
/W4 /permissive-
|
||||
/bigobj
|
||||
/utf-8
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_options(yaze_common INTERFACE
|
||||
/EHsc
|
||||
/W4 /permissive-
|
||||
/bigobj
|
||||
/utf-8
|
||||
)
|
||||
target_compile_definitions(yaze_common INTERFACE
|
||||
_CRT_SECURE_NO_WARNINGS
|
||||
_CRT_NONSTDC_NO_WARNINGS
|
||||
|
||||
Reference in New Issue
Block a user