diff --git a/cmake/developer_package/compile_flags/sanitizer.cmake b/cmake/developer_package/compile_flags/sanitizer.cmake index ef71780c0f169b..70b2215b664d6d 100644 --- a/cmake/developer_package/compile_flags/sanitizer.cmake +++ b/cmake/developer_package/compile_flags/sanitizer.cmake @@ -40,7 +40,7 @@ if (DEFINED SANITIZER_COMPILER_FLAGS) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=gold") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$" AND NOT WIN32) + elseif(OV_COMPILER_IS_CLANG AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld") endif() diff --git a/cmake/developer_package/compile_flags/sdl.cmake b/cmake/developer_package/compile_flags/sdl.cmake index 10a1e86ad6d48f..7690a9031d864a 100644 --- a/cmake/developer_package/compile_flags/sdl.cmake +++ b/cmake/developer_package/compile_flags/sdl.cmake @@ -23,7 +23,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") if (NOT ENABLE_SANITIZER) set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -s") endif() - elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + elseif(OV_COMPILER_IS_CLANG) set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-all") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") if (NOT ENABLE_SANITIZER) diff --git a/cmake/developer_package/features.cmake b/cmake/developer_package/features.cmake index 487dea8c7e382a..33e3530bac3359 100644 --- a/cmake/developer_package/features.cmake +++ b/cmake/developer_package/features.cmake @@ -58,7 +58,7 @@ ie_option (VERBOSE_BUILD "shows extra information about build" OFF) ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF) -ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "CMAKE_CXX_COMPILER_ID MATCHES ^(Apple)?Clang$; NOT WIN32" OFF) +ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "OV_COMPILER_IS_CLANG; NOT WIN32" OFF) # # Check features diff --git a/cmake/developer_package/target_flags.cmake b/cmake/developer_package/target_flags.cmake index 181c4dd4187e1b..d4fd9837647005 100644 --- a/cmake/developer_package/target_flags.cmake +++ b/cmake/developer_package/target_flags.cmake @@ -55,3 +55,9 @@ endif() if(UNIX AND NOT APPLE) set(LINUX ON) endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + set(OV_COMPILER_IS_CLANG ON) +else() + set(OV_COMPILER_IS_CLANG OFF) +endif() diff --git a/inference-engine/src/mkldnn_plugin/CMakeLists.txt b/inference-engine/src/mkldnn_plugin/CMakeLists.txt index f2bbc52bdc56bb..6e066a4656c384 100644 --- a/inference-engine/src/mkldnn_plugin/CMakeLists.txt +++ b/inference-engine/src/mkldnn_plugin/CMakeLists.txt @@ -34,8 +34,7 @@ ie_mark_target_as_cc(${TARGET_NAME}) if(SELECTIVE_BUILD STREQUAL "ON") # After disabling a block of code, some variables might be unused. - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR - CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) target_compile_options(${TARGET_NAME} PRIVATE -Wno-unused-variable) endif() endif() diff --git a/ngraph/frontend/onnx/onnx_import/CMakeLists.txt b/ngraph/frontend/onnx/onnx_import/CMakeLists.txt index 705f7f4d3b0d35..b8eab155d9784c 100644 --- a/ngraph/frontend/onnx/onnx_import/CMakeLists.txt +++ b/ngraph/frontend/onnx/onnx_import/CMakeLists.txt @@ -63,10 +63,8 @@ if(NGRAPH_USE_PROTOBUF_LITE) target_compile_definitions(onnx_importer PRIVATE NGRAPH_USE_PROTOBUF_LITE) endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") - target_compile_options(onnx_importer PRIVATE -Wno-undef -Wno-reserved-id-macro -Wno-switch-enum - -Wno-invalid-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations - -Wno-unused-private-field -Wno-shadow -Wno-deprecated PUBLIC -Wno-undefined-func-template) +if(OV_COMPILER_IS_CLANG) + target_compile_options(onnx_importer PRIVATE -Wno-undef) endif() install(TARGETS onnx_importer EXPORT ngraphTargets diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index c8a895bda3771a..6fbef735581714 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -618,7 +618,7 @@ if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src) endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") +if (OV_COMPILER_IS_CLANG) target_compile_options(unit-test PRIVATE -Wno-undef -Wno-reserved-id-macro) endif() diff --git a/openvino/conditional_compilation/CMakeLists.txt b/openvino/conditional_compilation/CMakeLists.txt index 1db12d4eefbd0a..daadd1c83207b6 100644 --- a/openvino/conditional_compilation/CMakeLists.txt +++ b/openvino/conditional_compilation/CMakeLists.txt @@ -25,8 +25,7 @@ elseif(SELECTIVE_BUILD STREQUAL "ON") target_compile_definitions(${TARGET_NAME} INTERFACE SELECTIVE_BUILD) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR OV_COMPILER_IS_CLANG) # After disabling a block of code, some variables might be unused. target_compile_options(${TARGET_NAME} INTERFACE -Wno-unused-function diff --git a/thirdparty/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt index 67ea852f1551c7..7826e944dd843c 100644 --- a/thirdparty/onnx/CMakeLists.txt +++ b/thirdparty/onnx/CMakeLists.txt @@ -21,7 +21,7 @@ macro(onnx_set_target_properties) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options(onnx PRIVATE /WX-) - elseif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) target_compile_options(onnx PRIVATE -Wno-all) target_compile_options(onnx_proto PRIVATE -Wno-all -Wno-unused-variable) endif() diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt index d5d8d5b477205f..c4d6fe26bc2af6 100644 --- a/thirdparty/protobuf/CMakeLists.txt +++ b/thirdparty/protobuf/CMakeLists.txt @@ -13,7 +13,7 @@ if(SUGGEST_OVERRIDE_SUPPORTED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override") endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") +if(OV_COMPILER_IS_CLANG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") endif() @@ -58,7 +58,7 @@ else() set(Protobuf_LIBRARIES libprotobuf) endif() -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") +if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) set(_proto_libs ${Protobuf_LIBRARIES}) if(TARGET libprotoc) list(APPEND _proto_libs libprotoc)