@@ -54,7 +54,19 @@ if(WIN32)
5454 set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" )
5555endif ()
5656
57- set (CLICE_CXX_FLAGS "-fno-rtti;-fno-exceptions;-Wno-deprecated-declarations;-Wno-undefined-inline;" )
57+ if (MSVC )
58+ # Remove any RTTI or exception enabling flags from CMAKE_CXX_FLAGS
59+ string (REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
60+ string (REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
61+
62+ # Fix MSVC Non-standard preprocessor caused error C1189
63+ # While compiling Command.cpp, MSVC won't expand Options macro correctly
64+ # Output: D:\Desktop\code\clice\build\.packages\l\llvm\20.1.5\cc2aa9f1d09a4b71b6fa3bf0011f6387\include\clang/Driver/Options.inc(3590): error C2365: “clang::driver::options::OPT_”: redefinition; previous definition was 'enumerator'
65+ set (CLICE_CXX_FLAGS "/GR-;/EHsc-;/Zc:preprocessor;" )
66+ else ()
67+ set (CLICE_CXX_FLAGS "-fno-rtti;-fno-exceptions;-Wno-deprecated-declarations;-Wno-undefined-inline;" )
68+ endif ()
69+
5870set (CLICE_LINKER_FLAGS "" )
5971
6072if (CLICE_USE_LIBCXX)
@@ -68,9 +80,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
6880 list (APPEND CLICE_CXX_FLAGS "-g;-O0;-fsanitize=address" )
6981 list (APPEND CLICE_LINKER_FLAGS "-fsanitize=address" )
7082elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" )
71- message (STATUS "RelWithDebInfo build: Enabling -fsanitize=thread" )
72- list (APPEND CLICE_CXX_FLAGS "-fsanitize=thread" )
73- list (APPEND CLICE_LINKER_FLAGS "-fsanitize=thread" )
83+ if (NOT MSVC )
84+ # MSVC only supports ASAN
85+ message (STATUS "RelWithDebInfo build: Enabling -fsanitize=thread" )
86+ list (APPEND CLICE_CXX_FLAGS "-fsanitize=thread" )
87+ list (APPEND CLICE_LINKER_FLAGS "-fsanitize=thread" )
88+ endif ()
7489else ()
7590 message (STATUS "Release/Default build: Enabling -O3" )
7691 list (APPEND CLICE_CXX_FLAGS "-O3" )
0 commit comments