zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 74b6abe0e83ad130b5d5ed95c8135ec9a9770898
parent f57e0ce3a56ab508cce8946f78c94de91ed9c313
Author: Johannes Lorenz <j.git@lorenz-ho.me>
Date:   Sun, 12 Jan 2025 15:56:37 +0100

CMakeLists: Restrict Werror to some targets

This fixes issues arising with DPF targets, where we cannot control
`Werror` behavior.

Tested that all wanted targets are covered using

```
make 2>&1 | grep -v Werror | grep 'cpp\( \|$\)' | grep -v 'distrho\|rtosc/test'
```

Minor other change: This restricts `find_package(LibGit2)` to where it
is really needed: `CompileTests=ON` and Linux.

Diffstat:
Msrc/CMakeLists.txt | 22+++++++++++-----------
Msrc/Tests/CMakeLists.txt | 13+++++++++++--
2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -20,7 +20,7 @@ find_package(FLTK) find_package(OpenGL) #for FLTK find_package(ECM) list(APPEND CMAKE_MODULE_PATH ${ECM_FIND_MODULE_DIR}) -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) +if(CompileTests AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) find_package(LibGit2) endif() # lash @@ -211,16 +211,6 @@ option (Werror "Treat all warnings as errors" ON) option (IncludeWhatYouUse "Check for useless includes" OFF) mark_as_advanced(IncludeWhatYouUse) -if(Werror) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) - set(CMAKE_COMPILE_WARNING_AS_ERROR ON) - else() - if(NOT WIN32) # For Windows, just allow warnings for now - add_definitions(-Werror) - endif() - endif() -endif() - set(CMAKE_BUILD_TYPE "Release") set (BuildOptions_ExtendedWarnings "") @@ -622,6 +612,16 @@ endif(CompileTests) 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) + else() + if(NOT WIN32) # For Windows, just allow warnings for now + target_compile_options(zynaddsubfx PUBLIC -Werror) + endif() + endif() +endif() + #Warning: the required ordering of these to get proper linking depends upon the # phase of the moon target_link_libraries(zynaddsubfx diff --git a/src/Tests/CMakeLists.txt b/src/Tests/CMakeLists.txt @@ -1,6 +1,6 @@ function(cp_script script_name) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${script_name} - ${CMAKE_CURRENT_BINARY_DIR}/${script_name} COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${script_name} + ${CMAKE_CURRENT_BINARY_DIR}/${script_name} COPYONLY) endfunction() function(quick_test test_name link) @@ -8,6 +8,15 @@ function(quick_test test_name link) add_test(NAME ${test_name} COMMAND ${test_name}) target_link_libraries(${test_name} ${link} ${ARGN}) + if(Werror) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + set_target_properties(${test_name} PROPERTIES COMPILE_WARNINGS_AS_ERRORS ON) + else() + if(NOT WIN32) # For Windows, just allow warnings for now + target_compile_options(${test_name} PUBLIC -Werror) + endif() + endif() + endif() endfunction() #for tests looking for files stored in the source dir