From e8bd70f273cae93395d733a0cb07c428a3a3df58 Mon Sep 17 00:00:00 2001 From: Xiping Yan Date: Thu, 7 Jul 2022 02:02:04 +0000 Subject: [PATCH] Add build flag for GCC. (#12017) Some compiler flags restrict the compiler from making arbitrary decisions while handling undefined C/C++ behaviors. Therefore they can be used to fix some issues caused by undefined behavior. Signed-off-by: Yan, Xiping Co-authored-by: Chen Peter --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14b45fab3c7..f570d4246c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,10 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build type" FORCE) endif() +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options(-fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv) +endif() + find_package(IEDevScripts REQUIRED PATHS "${OpenVINO_SOURCE_DIR}/cmake/developer_package" NO_CMAKE_FIND_ROOT_PATH