aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2024-01-02 12:40:59 +0100
committerGitHub <noreply@github.com>2024-01-02 12:40:59 +0100
commitfd7067652cae480190bf13b2ee5475efdf09ac7d (patch)
tree1126345131bc56ac50e92f19d401b04fe2183662
parent766eca4306f327b213c10acd245666d893035f4d (diff)
parent8eedf9330a8f188290456cc3fd2c6f94fbd280ed (diff)
downloadninja-fd7067652cae480190bf13b2ee5475efdf09ac7d.tar.gz
Merge pull request #2360 from Simonhancrew/master
[FIX] compile: gcc version > 11.3, treat -Wmaybe-uninitialized as error
-rw-r--r--CMakeLists.txt10
1 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9529d1..8a5ef00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,6 +252,16 @@ if(BUILD_TESTING)
if (NOT TARGET GTest::gtest)
message(STATUS "Defining GTest::gtest alias to work-around bug in older release.")
add_library(GTest::gtest ALIAS gtest)
+
+ # NOTE: gtest uninit some variables, gcc >= 1.11.3 may cause error on compile.
+ # Remove this comment and six lines below, once ninja deps gtest-1.11.0 or above.
+ if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "1.11.3")
+ check_cxx_compiler_flag(-Wno-maybe-uninitialized flag_no_maybe_uninit)
+ if (flag_no_maybe_uninit)
+ target_compile_options(gtest PRIVATE -Wno-maybe-uninitialized)
+ endif()
+ endif()
+
endif()
endif()