@@ -62,14 +62,23 @@ if(NOT MSVC)
6262 add_compile_options ("$<$<COMPILE_LANGUAGE :CXX >:-frtti >" )
6363endif ()
6464
65- # NATIVE C23 AND C++23 SUPPORT
66- set (CMAKE_C_STANDARD 23)
67- set (CMAKE_C_STANDARD_REQUIRED ON )
68- set (CMAKE_C_EXTENSIONS ON ) # Leave ON to naturally output -std=gnu2x / -std=gnu23
65+ # NATIVE C++23 SUPPORT
6966set (CMAKE_CXX_STANDARD 23)
7067set (CMAKE_CXX_STANDARD_REQUIRED ON )
7168set (CMAKE_POSITION_INDEPENDENT_CODE ON )
7269
70+ # NATIVE C23 SUPPORT
71+ if (MSVC AND CMAKE_C_COMPILER_ID MATCHES "Clang" )
72+ # THE CLANG-CL PROBLEM: MSVC doesn't have a /std:c23 flag, so CMake lacks the mapping
73+ # for Clang-CL. We must bypass CMake's checking here and manually inject it below.
74+ message (STATUS "Culverin: Bypassing native C_STANDARD detection for Clang-CL (Missing CMake mapping)" )
75+ else ()
76+ # The normal human being way for GCC and standard Clang (Linux/Mac/MinGW)
77+ set (CMAKE_C_STANDARD 23)
78+ set (CMAKE_C_STANDARD_REQUIRED ON )
79+ set (CMAKE_C_EXTENSIONS ON )
80+ endif ()
81+
7382add_definitions (-DJPH_DOUBLE_PRECISION )
7483add_definitions (-DJPH_OBJECT_LAYER_BITS=32 )
7584
@@ -84,7 +93,15 @@ if(MSVC)
8493
8594 if (CMAKE_C_COMPILER_ID MATCHES "Clang" )
8695 message (STATUS "Culverin: Detected Clang-CL (MSVC-like)" )
87- add_compile_options (/arch:AVX2 $<$<COMPILE_LANGUAGE :C >:-Wno -c2x -extensions >)
96+
97+ # Inject C23 directly to the LLVM frontend behind MSVC's back
98+ add_compile_options (
99+ "$<$<COMPILE_LANGUAGE :C >:/clang :-std =gnu23 >"
100+ "$<$<COMPILE_LANGUAGE :C >:-Wno -c23 -extensions >"
101+ "$<$<COMPILE_LANGUAGE :C >:-Wno -c2x -extensions >"
102+ )
103+
104+ add_compile_options (/arch:AVX2 )
88105 set (RELEASE_FLAGS "/clang:-O3 /clang:-ffast-math /clang:-fstrict-aliasing /Ob2 /Oi /Ot" )
89106 else ()
90107 message (STATUS "Culverin: Detected Pure MSVC" )
@@ -104,7 +121,6 @@ else()
104121
105122 set (FLAGS_PERF "-O3" "-ffast-math" "-fomit-frame-pointer" )
106123 if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64" )
107- # Removed -march=native so built binaries are portable
108124 list (APPEND FLAGS_PERF "-mavx2" "-mfma" )
109125 endif ()
110126
@@ -115,8 +131,7 @@ else()
115131 "SHELL:-mllvm -unroll-allow-partial"
116132 "SHELL:-mllvm -force-vector-width=8"
117133 )
118- # Suppress warnings for C23 extensions that Clang might emit
119- list (APPEND FLAGS_STRICT "-Wno-c2x-extensions" "-Wno-c23-extensions" )
134+ list (APPEND FLAGS_STRICT "-Wno-c23-extensions" "-Wno-c2x-extensions" )
120135 endif ()
121136
122137 set (FLAGS_STRICT "-Wall" "-Wextra" "-Wno-sign-conversion" "-Wno-shorten-64-to-32" "-Wno-double-promotion" )
@@ -254,7 +269,6 @@ if(APPLE)
254269 message (STATUS "Culverin: Enforcing Strong Symbol Export" )
255270 target_compile_options (${JOLTC_TARGET} PRIVATE "-frtti" )
256271 target_compile_options (_culverin_c PRIVATE "-frtti" )
257- # Removed -export_dynamic (causes ld crash) and -flat_namespace
258272 target_link_options (_culverin_c PRIVATE "-Wl,-all_load" )
259273endif ()
260274
0 commit comments