commit adf4ed47390b1645dc2dfca8bfa1394a7f6d7608
parent aae63c815150bb7cd4535991b42d669404879d24
Author: Johannes Lorenz <j.git@lorenz-ho.me>
Date: Fri, 21 Feb 2025 18:54:40 +0100
Fixup Werror in CMakeLists
Fixup of ffe9ca1375168dd86c974dbe7c0264fce393150e
* Fixup to set Werror property for *all* targets
* Enable `/WX` on Windows
* Check Wno-stringop-truncation availability before using it
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -368,8 +368,12 @@ endif()
add_definitions(
-Wall
- -Wextra
- -Wno-stringop-truncation) # https://stackoverflow.com/questions/50198319
+ -Wextra)
+
+check_cxx_compiler_flag("-Wno-stringop-truncation" COMPILER_SUPPORTS_NO_STRINGOP_TRUNCATION)
+if (COMPILER_SUPPORTS_NO_STRINGOP_TRUNCATION)
+ add_definitions(-Wno-stringop-truncation) # https://stackoverflow.com/questions/50198319
+endif()
# macro similar to "check_cxx_compiler_flag", however,
# it also checks for warnings that are only output if other warnings are active
@@ -614,9 +618,13 @@ add_executable(zynaddsubfx main.cpp)
if(Werror)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
- set_target_properties(zynaddsubfx PROPERTIES COMPILE_WARNINGS_AS_ERRORS ON)
+ foreach(target zynaddsubfx zynaddsubfx_core zynaddsubfx_nio zynaddsubfx_gui_bridge)
+ set_target_properties(${target} PROPERTIES COMPILE_WARNING_AS_ERROR ON)
+ endforeach()
else()
- if(NOT WIN32) # For Windows, just allow warnings for now
+ if(MSVC)
+ target_compile_options(zynaddsubfx PUBLIC /WX)
+ else()
target_compile_options(zynaddsubfx PUBLIC -Werror)
endif()
endif()