Validate Unix-only compiler flags in CMake build

PiperOrigin-RevId: 260706238
Change-Id: I2206f4d724a93de8714aeef521c544b660101d17
This commit is contained in:
Christian Blichmann 2019-07-30 06:51:15 -07:00 committed by Copybara-Service
parent b7cbc36071
commit 0c64532a8c

View File

@ -22,6 +22,8 @@ set(SAPI_CXX_STANDARD 11)
set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE) set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE)
set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE) set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE)
include(CheckCXXCompilerFlag)
# Sapi CMake modules, order matters # Sapi CMake modules, order matters
list(APPEND CMAKE_MODULE_PATH "${SAPI_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${SAPI_SOURCE_DIR}/cmake")
include(SapiOptions) include(SapiOptions)
@ -52,12 +54,20 @@ target_include_directories(sapi_base INTERFACE
"${SAPI_BINARY_DIR}" "${SAPI_BINARY_DIR}"
"${SAPI_SOURCE_DIR}" "${SAPI_SOURCE_DIR}"
"${Protobuf_INCLUDE_DIR}" "${Protobuf_INCLUDE_DIR}"
# Need to reach into Abseil internal headers from a few targets.
"${CMAKE_BINARY_DIR}/absl-src"
) )
if(UNIX) if(UNIX)
foreach(flag IN ITEMS -Wno-deprecated
-Wno-deprecated-declarations
-Wno-psabi)
check_cxx_compiler_flag(${flag} _sapi_has_flag)
if(_sapi_has_flag)
target_compile_options(sapi_base INTERFACE target_compile_options(sapi_base INTERFACE
-Wno-deprecated ${flag}
-Wno-psabi
) )
endif()
endforeach()
endif() endif()
add_library(sapi_test_main INTERFACE) add_library(sapi_test_main INTERFACE)