From 934bf7bf054a4c111914789398e3dc94467e3486 Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Thu, 26 Dec 2024 22:33:20 -0500 Subject: [PATCH] [build] CMake: Make NO_WERROR also work on MSVC (#7594) --- cmake/modules/CompileWarnings.cmake | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cmake/modules/CompileWarnings.cmake b/cmake/modules/CompileWarnings.cmake index b56c175a9b..fd4f9294ba 100644 --- a/cmake/modules/CompileWarnings.cmake +++ b/cmake/modules/CompileWarnings.cmake @@ -14,18 +14,20 @@ macro(wpilib_target_warnings target) target_compile_options(${target} PRIVATE ${WARNING_FLAGS}) else() - target_compile_options( - ${target} - PRIVATE - /wd4146 - /wd4244 - /wd4251 - /wd4267 - /wd4324 - /WX - /D_CRT_SECURE_NO_WARNINGS - ${WPILIB_TARGET_WARNINGS} + set(WARNING_FLAGS + /wd4146 + /wd4244 + /wd4251 + /wd4267 + /wd4324 + /D_CRT_SECURE_NO_WARNINGS + ${WPILIB_TARGET_WARNINGS} ) + if(NOT NO_WERROR) + set(WARNING_FLAGS ${WARNING_FLAGS} /WX) + endif() + + target_compile_options(${target} PRIVATE ${WARNING_FLAGS}) endif() # Suppress C++-specific OpenCV warning; C compiler rejects it with an error