From 8563e1655bd9bb1f249e6552cc6274d506ee788b Mon Sep 17 00:00:00 2001 From: Jordan Peck Date: Tue, 12 Mar 2024 21:25:15 +0000 Subject: [PATCH] Update CMakeLists.txt Replace /W compiler flag if it already exists to avoid compiler warning --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f84b551..c4c8d50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,13 @@ endif() if(MSVC) add_compile_definitions(SDL_MAIN_HANDLED) - add_compile_options(/W4 /WX) + add_compile_options(/WX) + # replace existing /W to avoid warning + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + add_compile_options(/W4) + endif() else() add_compile_options(-Wall -Wextra -Wpedantic -Werror) endif() @@ -98,4 +104,4 @@ if(IMNODES_EXAMPLES) else() target_link_libraries(hello X11 Xext GL) endif() -endif() \ No newline at end of file +endif()