Skip to content

Commit

Permalink
Fix for cmake 3.21.x (openvinotoolkit#6722)
Browse files Browse the repository at this point in the history
* Fix for cmake 3.21.x

* Removed a lot -Wno-* compile options
  • Loading branch information
ilya-lavrenov authored and rnugmanx committed Aug 26, 2021
1 parent b3d14fd commit 0b45400
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmake/developer_package/compile_flags/sanitizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/developer_package/compile_flags/sdl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/developer_package/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions cmake/developer_package/target_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
3 changes: 1 addition & 2 deletions inference-engine/src/mkldnn_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions ngraph/frontend/onnx/onnx_import/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ngraph/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions openvino/conditional_compilation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/onnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0b45400

Please sign in to comment.