Fix flatbuffers build with gcc versions >= 8.0 (#8954)
authorVladimir Plazun/AI Tools Lab /SRR/Engineer/Samsung Electronics <v.plazun@samsung.com>
Mon, 18 Nov 2019 08:59:06 +0000 (11:59 +0300)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 18 Nov 2019 08:59:06 +0000 (17:59 +0900)
gcc 8.0+ adds `class-memaccess` diagnostic, making flatbuffers build fail when Werror is enabled
This disables class-memaccess diagnostic for gcc versions greater than 8.0

Signed-off-by: Vladimir Plazun <v.plazun@samsung.com>
infra/cmake/packages/FlatBuffersConfig.cmake

index 51167fc..b70b824 100644 (file)
@@ -34,9 +34,15 @@ function(_FlatBuffers_build)
   # NOTE Do NOT retry Flatbuffers build once it fails
   file(WRITE "${STAMP_PATH}")
 
+  set(ADDITIONAL_CXX_FLAGS "")
+  if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
+    set(ADDITIONAL_CXX_FLAGS "-Wno-error=class-memaccess")
+  endif()
+
   execute_process(COMMAND ${CMAKE_COMMAND}
                             -DCMAKE_INSTALL_PREFIX=${FLATBUFFERS_INSTALL}
                             -DCMAKE_BUILD_TYPE=Release
+                            -DCMAKE_CXX_FLAGS=${ADDITIONAL_CXX_FLAGS}
                             ${FlatBuffersSource_DIR}
                   OUTPUT_FILE ${LOG_PATH}
                   ERROR_FILE ${LOG_PATH}