diff options
author | Evan Cox <evanacox00@gmail.com> | 2022-08-11 14:55:04 -0400 |
---|---|---|
committer | Evan Cox <evanacox00@gmail.com> | 2022-08-11 14:55:04 -0400 |
commit | 6f6886156d986d83e33f97578bd3eb66b36fb40a (patch) | |
tree | 18777e01039125298439ee7634e059fac04c9288 /CMake | |
parent | 697acabc5b7e28c51f7ab8d2f43d4ef4fed77f8d (diff) |
add new CMake option `ABSL_USE_SYSTEM_INCLUDES`
When using Abseil as a dependency with CMake, files that include Abseil headers and have incompatible warning settings can emit compiler warnings. CMake allows you to mark include directories as `SYSTEM` includes, which causes compilers to ignore warnings from those headers.
This adds the new option `ABSL_USE_SYSTEM_INCLUDES`, which makes Abseil's include directories be marked with `SYSTEM`.
Diffstat (limited to 'CMake')
-rw-r--r-- | CMake/AbseilHelpers.cmake | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index f81d57cf..96d815dd 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -26,6 +26,12 @@ if(NOT DEFINED ABSL_IDE_FOLDER) set(ABSL_IDE_FOLDER Abseil) endif() +if(ABSL_USE_SYSTEM_INCLUDES) + set(ABSL_INTERNAL_INCLUDE_WARNING_GUARD SYSTEM) +else() + set(ABSL_INTERNAL_INCLUDE_WARNING_GUARD "") +endif() + # absl_cc_library() # # CMake function to imitate Bazel's cc_library rule. @@ -242,7 +248,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") # unconditionally. set_property(TARGET ${_NAME} PROPERTY LINKER_LANGUAGE "CXX") - target_include_directories(${_NAME} + target_include_directories(${_NAME} ${ABSL_INTERNAL_INCLUDE_WARNING_GUARD} PUBLIC "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> @@ -290,7 +296,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") else() # Generating header-only library add_library(${_NAME} INTERFACE) - target_include_directories(${_NAME} + target_include_directories(${_NAME} ${ABSL_INTERNAL_INCLUDE_WARNING_GUARD} INTERFACE "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |