From 9830fda6a5c4faf61bb802484e9eefdb53886516 Mon Sep 17 00:00:00 2001 From: Dennis Potman Date: Tue, 19 Sep 2023 11:39:24 +0200 Subject: [PATCH] Add linker option to treat linker warnings as errors when WERROR is set Signed-off-by: Dennis Potman --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4103d46144..0c87a4f3b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,9 +93,9 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "-Wconditional-uninitialized" "-Wshadow") add_compile_options(${wflags}) - add_link_options(-undefined error) if(${WERROR}) add_compile_options(-Werror) + add_link_options(-Werror) endif() if("${CMAKE_GENERATOR}" STREQUAL "Ninja") add_compile_options(-Xclang -fcolor-diagnostics) @@ -110,6 +110,7 @@ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") endif() if(${WERROR}) add_compile_options(-Werror) + add_link_options(-Werror) endif() if("${CMAKE_GENERATOR}" STREQUAL "Ninja") add_compile_options(-fdiagnostics-color=always) @@ -119,6 +120,7 @@ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") add_compile_options(/W3) if(${WERROR}) add_compile_options(/WX) + add_link_options(/WX) endif() endif()