Root cause: clang-cl on Windows Server 2022 with MSVC STL cannot find std::filesystem without explicit C++ standard flag. The compiler defaults to an older compatibility mode that only exposes std::experimental::filesystem. Solution: Add /std:c++latest compiler flag specifically for clang-cl builds on Windows. This enables proper C++23 standard library support including std::filesystem from MSVC STL. The fix is applied via yaze_common interface target in cmake/utils.cmake, ensuring all targets using yaze_common get the correct flags. This has blocked Windows releases for 2+ weeks. Fixes compilation errors in: - src/util/platform_paths.h - src/util/platform_paths.cc - src/util/file_util.cc - All other files using <filesystem> Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
88 lines
3.1 KiB
CMake
88 lines
3.1 KiB
CMake
# This file contains utility functions for the yaze build system.
|
|
|
|
# ============================================================================
|
|
# yaze_add_compiler_flags
|
|
#
|
|
# Sets standard compiler flags for C++ and C.
|
|
# Also handles platform-specific and compiler-specific flags.
|
|
# ============================================================================
|
|
function(yaze_add_compiler_flags)
|
|
# Set C++ and C standards in parent scope
|
|
set(CMAKE_CXX_STANDARD 23 PARENT_SCOPE)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE)
|
|
set(CMAKE_CXX_EXTENSIONS OFF PARENT_SCOPE)
|
|
set(CMAKE_C_STANDARD 99 PARENT_SCOPE)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON PARENT_SCOPE)
|
|
|
|
if(YAZE_SUPPRESS_WARNINGS)
|
|
if(MSVC)
|
|
add_compile_options(/w)
|
|
else()
|
|
add_compile_options(-w)
|
|
endif()
|
|
message(STATUS "✓ Warnings suppressed (use -v preset suffix for verbose builds)")
|
|
else()
|
|
message(STATUS "○ Verbose warnings enabled")
|
|
endif()
|
|
|
|
# Common interface target for shared settings
|
|
add_library(yaze_common INTERFACE)
|
|
target_compile_features(yaze_common INTERFACE cxx_std_23)
|
|
|
|
# Platform-specific definitions
|
|
if(YAZE_PLATFORM_LINUX)
|
|
target_compile_definitions(yaze_common INTERFACE linux stricmp=strcasecmp)
|
|
elseif(YAZE_PLATFORM_MACOS)
|
|
target_compile_definitions(yaze_common INTERFACE MACOS)
|
|
elseif(YAZE_PLATFORM_WINDOWS)
|
|
target_compile_definitions(yaze_common INTERFACE WINDOWS)
|
|
endif()
|
|
|
|
# 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_definitions(yaze_common INTERFACE
|
|
_CRT_SECURE_NO_WARNINGS
|
|
_CRT_NONSTDC_NO_WARNINGS
|
|
SILENCE_CXX23_DEPRECATIONS
|
|
_SILENCE_CXX23_DEPRECATION_WARNING
|
|
_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
|
|
NOMINMAX
|
|
WIN32_LEAN_AND_MEAN
|
|
strncasecmp=_strnicmp
|
|
strcasecmp=_stricmp
|
|
)
|
|
else()
|
|
target_compile_options(yaze_common INTERFACE
|
|
-Wall -Wextra -Wpedantic
|
|
-Wno-deprecated-declarations
|
|
-Wno-c++23-compat
|
|
)
|
|
target_compile_definitions(yaze_common INTERFACE
|
|
_SILENCE_CXX23_DEPRECATION_WARNING
|
|
_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
|
|
)
|
|
endif()
|
|
endfunction()
|