From 07100c6e69061738f48481e2d42ad403248b24a6 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Fri, 16 Jan 2015 15:20:54 -0800 Subject: [PATCH] Only use -Wshadow with GCC > 4.6.0. Prior to 4.6.0, -Wshadow would cause GCC to warn when variables shadowed global functions. Since libc defines a number of functions with common names, this is a problem. Also, without this change, we'll keep breaking on older versions of GCC because we won't be testing with them. OpenBSD, specifically is reported to have a problem: https://boringssl-review.googlesource.com/#/c/2900/ (Note the test should really be >= 4.6.0, but CMake doesn't have a VERSION_GREATEROREQUAL.) Change-Id: I1aedda01ab629e138c8781e4319bfaaed0b236b0 Reviewed-on: https://boringssl-review.googlesource.com/2952 Reviewed-by: Adam Langley --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04af7277..d4127fe6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,22 @@ -cmake_minimum_required (VERSION 2.8.8) +cmake_minimum_required (VERSION 2.8.10) project (BoringSSL) if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wshadow -Werror -ggdb") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -Werror -ggdb -std=c++0x") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -ggdb") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -ggdb -std=c++0x") elseif(MSVC) # Disable warnings for implicit integer narrowing. set(CMAKE_C_FLAGS "/wd4267") set(CMAKE_CXX_FLAGS "/wd4267") endif() +if((CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER "4.5.99") OR + "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") +endif() + add_definitions(-DBORINGSSL_IMPLEMENTATION) if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")