cppast icon indicating copy to clipboard operation
cppast copied to clipboard

Warning flags cause errors when building with Clang using the MSVC frontend

Open Muppetsg2 opened this issue 4 months ago • 0 comments

The title pretty much says it all. When I tried to build cppast using the clang compiler with the msvc frontend, I got an error about incorrectly defined compiler flags. I did some reading, and if anyone is still having problems, I recommend changing lines 118 to 126 of the src/CMakeLists.txt file to:

target_compile_options(cppast PRIVATE
    # MSVC/clang with MSVC frontend warnings
    $<$<OR:$<CXX_COMPILER_ID:MSVC>,$<AND:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_FRONTEND_VARIANT:MSVC>>>:
    /W3>
    # GCC/clang with GNU frontend warnings
    $<$<OR:$<CXX_COMPILER_ID:GNU>,$<AND:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_FRONTEND_VARIANT:GNU>>>:
    -pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion>
    # disable noexcept type warning on GCC
    $<$<CXX_COMPILER_ID:GNU>:
    -Wno-noexcept-type>
)

Muppetsg2 avatar Sep 01 '25 23:09 Muppetsg2