aboutsummaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2020-08-18 11:03:20 +0200
committerTor Egge <Tor.Egge@broadpark.no>2020-08-18 11:08:01 +0200
commitc969b7e7a601cf9507ab0684d7eed22bb2f706df (patch)
tree4413241c1b4cf35e51795ea927b649dca58f1ec6 /functions.cmake
parentef6227ebc92c625081f703a806e0b0c2c02a5a1c (diff)
Consolidate suppress warnings for protobuf sources.
Diffstat (limited to 'functions.cmake')
-rw-r--r--functions.cmake20
1 files changed, 20 insertions, 0 deletions
diff --git a/functions.cmake b/functions.cmake
index 864fc010faa..95828430768 100644
--- a/functions.cmake
+++ b/functions.cmake
@@ -710,3 +710,23 @@ endfunction()
function(vespa_install_empty_tmp_dir TARGET)
install(DIRECTORY DESTINATION ${TARGET} DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE SETGID)
endfunction()
+
+function(vespa_suppress_warnings_for_protobuf_sources)
+ cmake_parse_arguments(
+ ARG
+ ""
+ ""
+ "SOURCES"
+ ${ARGN}
+ )
+ # protoc-generated files emit compiler warnings that we normally treat as errors.
+ # Instead of rolling our own compiler plugin we'll pragmatically disable the noise.
+ if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+ if(Protobuf_VERSION VERSION_LESS "3.7.0")
+ set(VESPA_DISABLE_UNUSED_WARNING "-Wno-unused-parameter")
+ else()
+ unset(VESPA_DISABLE_UNUSED_WARNING)
+ endif()
+ set_source_files_properties(${ARG_SOURCES} PROPERTIES COMPILE_FLAGS "-Wno-array-bounds -Wno-suggest-override -Wno-inline ${VESPA_DISABLE_UNUSED_WARNING}")
+ endif()
+endfunction()