From 6be6556244242569702bf21358caab9cca550e3a Mon Sep 17 00:00:00 2001 From: msclock Date: Thu, 4 Apr 2024 15:41:38 +0800 Subject: [PATCH] perf: conform to cmake builin CMAKE_COMPILE_WARNING_AS_ERROR (#85) Signed-off-by: msclock --- cmake/build/CompilerFlags.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/build/CompilerFlags.cmake b/cmake/build/CompilerFlags.cmake index f495d71..0920c18 100644 --- a/cmake/build/CompilerFlags.cmake +++ b/cmake/build/CompilerFlags.cmake @@ -85,7 +85,9 @@ set(COMPILER_FLAGS_WARNINGS_CUDA # context ) -option(COMPILER_FLAGS_WARNINGS_AS_ERRORS "Treat Warnings As Errors" OFF) +if(CMAKE_VERSION VERSION_LESS 3.24) + option(CMAKE_COMPILE_WARNING_AS_ERROR "Treat Warnings As Errors" OFF) +endif() message( STATUS @@ -94,7 +96,7 @@ message( COMPILER_FLAGS_WARNINGS_MSVC: ${COMPILER_FLAGS_WARNINGS_MSVC} COMPILER_FLAGS_WARNINGS_GNU: ${COMPILER_FLAGS_WARNINGS_GNU} COMPILER_FLAGS_WARNINGS_CUDA: ${COMPILER_FLAGS_WARNINGS_CUDA} - COMPILER_FLAGS_WARNINGS_AS_ERRORS: If treat warnings as errors. Default is OFF. + CMAKE_COMPILE_WARNING_AS_ERROR: If treat warnings as errors. Default is ${CMAKE_COMPILE_WARNING_AS_ERROR}. COMPILER_FLAGS_SKIP_TARGETS_REGEXES: List of regexes to skip targets. Default is empty." ) @@ -117,7 +119,7 @@ endforeach() unset(_warnings_cxx_temp) -if(COMPILER_FLAGS_WARNINGS_AS_ERRORS) +if(CMAKE_COMPILE_WARNING_AS_ERROR) if(MSVC) check_and_append_flag(FLAGS "/WX" TARGETS compiler_warnings_cxx) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES