Skip to content

Commit

Permalink
M [>0;136;0c [>0;136;0cranch 'origin/CMAKE_COMPILE_WARNING_AS_ERROR' …
Browse files Browse the repository at this point in the history
…into CMAKE_COMPILE_WARNING_AS_ERROR
  • Loading branch information
ilya-lavrenov committed Sep 14, 2023
2 parents cf875d2 + bbf6802 commit a8752dd
Show file tree
Hide file tree
Showing 400 changed files with 13,685 additions and 9,386 deletions.
2 changes: 1 addition & 1 deletion cmake/developer_package/add_ie_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function(addIeTarget)
endif()
if (ARG_ADD_CLANG_FORMAT)
# code style
add_clang_format_target(${ARG_NAME}_clang FOR_TARGETS ${ARG_NAME})
ov_add_clang_format_target(${ARG_NAME}_clang FOR_TARGETS ${ARG_NAME})
endif()
if (ARG_DEVELOPER_PACKAGE)
# developer package
Expand Down
5 changes: 5 additions & 0 deletions cmake/developer_package/api_validator/api_validator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ endfunction()
#
# ie_add_api_validator_post_build_step(TARGET <name>)
#
macro(ov_add_api_validator_post_build_step)
_ov_add_api_validator_post_build_step(${ARGV})
endmacro()

macro(ie_add_api_validator_post_build_step)
message(WARNING "ie_add_api_validator_post_build_step is deprecated, use ov_add_api_validator_post_build_step instead")
_ov_add_api_validator_post_build_step(${ARGV})
endmacro()
11 changes: 8 additions & 3 deletions cmake/developer_package/clang_format/clang_format.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ if(ENABLE_CLANG_FORMAT AND NOT TARGET clang_format_check_all)
endif()

#
# add_clang_format_target(FOR_TARGETS <target1 target2 ...> | FOR_SOURCES <source1 source2 ...>
# [EXCLUDE_PATTERNS <pattern1 pattern2 ...>])
# ov_add_clang_format_target(FOR_TARGETS <target1 target2 ...> | FOR_SOURCES <source1 source2 ...>
# [EXCLUDE_PATTERNS <pattern1 pattern2 ...>])
#
function(add_clang_format_target TARGET_NAME)
function(ov_add_clang_format_target TARGET_NAME)
if(NOT ENABLE_CLANG_FORMAT)
return()
endif()
Expand Down Expand Up @@ -130,3 +130,8 @@ function(add_clang_format_target TARGET_NAME)
add_dependencies(clang_format_check_all ${TARGET_NAME})
add_dependencies(clang_format_fix_all ${TARGET_NAME}_fix)
endfunction()

function(add_clang_format_target)
message(WARNING "add_clang_format_target is deprecated, use ov_add_clang_format_target instead")
ov_add_clang_format_target(${ARGV})
endfunction()
85 changes: 43 additions & 42 deletions cmake/developer_package/compile_flags/os_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,26 @@ endfunction()
# Enables Link Time Optimization compilation
#
macro(ie_enable_lto)
message(WARNING "ie_add_compiler_flags is deprecated, set INTERPROCEDURAL_OPTIMIZATION_RELEASE target property instead")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
endmacro()

#
# ie_add_compiler_flags(<flag1 [flag2 flag3 ...>])
# ov_add_compiler_flags(<flag1 [flag2 flag3 ...>])
#
# Adds compiler flags to C / C++ sources
#
macro(ie_add_compiler_flags)
macro(ov_add_compiler_flags)
foreach(flag ${ARGN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
endforeach()
endmacro()

function(ov_add_compiler_flags)
ie_add_compiler_flags(${ARGN})
endfunction()
macro(ie_add_compiler_flags)
message(WARNING "ie_add_compiler_flags is deprecated, use ov_add_compiler_flags instead")
ov_add_compiler_flags(${ARGN})
endmacro()

#
# ov_force_include(<target> <PUBLIC | PRIVATE | INTERFACE> <header file>)
Expand Down Expand Up @@ -267,11 +269,11 @@ function(ov_abi_free_target target)
endfunction()

#
# ie_python_minimal_api(<target>)
# ov_python_minimal_api(<target>)
#
# Set options to use only Python Limited API
#
function(ie_python_minimal_api target)
function(ov_python_minimal_api target)
# pybind11 uses a lot of API which is not a part of minimal python API subset
# Ref 1: https://docs.python.org/3.11/c-api/stable.html
# Ref 2: https://github.com/pybind/pybind11/issues/1755
Expand Down Expand Up @@ -301,7 +303,7 @@ if(NOT DEFINED CMAKE_CXX_STANDARD)
endif()

if(ENABLE_COVERAGE)
ie_add_compiler_flags(--coverage)
ov_add_compiler_flags(--coverage)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()

Expand All @@ -313,9 +315,9 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

if(CMAKE_CL_64)
# Default char Type Is unsigned
# ie_add_compiler_flags(/J)
# ov_add_compiler_flags(/J)
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
ie_add_compiler_flags(-fsigned-char)
ov_add_compiler_flags(-fsigned-char)
endif()

file(RELATIVE_PATH OV_RELATIVE_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
Expand All @@ -335,22 +337,22 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Common options / warnings enabled
#

ie_add_compiler_flags(/D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS)
ov_add_compiler_flags(/D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS)
# no asynchronous structured exception handling
ie_add_compiler_flags(/EHsc)
ov_add_compiler_flags(/EHsc)
# Allows the compiler to package individual functions in the form of packaged functions (COMDATs).
ie_add_compiler_flags(/Gy)
ov_add_compiler_flags(/Gy)
# This option helps ensure the fewest possible hard-to-find code defects. Similar to -Wall on GNU / Clang
ie_add_compiler_flags(/W3)
ov_add_compiler_flags(/W3)

# Increase Number of Sections in .Obj file
ie_add_compiler_flags(/bigobj)
ov_add_compiler_flags(/bigobj)
# Build with multiple processes
ie_add_compiler_flags(/MP)
ov_add_compiler_flags(/MP)

if(AARCH64 AND NOT MSVC_VERSION LESS 1930)
# otherwise, _ARM64_EXTENDED_INTRINSICS is defined, which defines 'mvn' macro
ie_add_compiler_flags(/D_ARM64_DISTINCT_NEON_TYPES)
ov_add_compiler_flags(/D_ARM64_DISTINCT_NEON_TYPES)
endif()

# Handle Large Addresses
Expand All @@ -362,7 +364,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

if(CMAKE_COMPILE_WARNING_AS_ERROR)
if(CMAKE_VERSION VERSION_LESS 3.24)
ie_add_compiler_flags(/WX)
ov_add_compiler_flags(/WX)
endif()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /WX")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /WX")
Expand All @@ -374,9 +376,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
#

# C4251 needs to have dll-interface to be used by clients of class
ie_add_compiler_flags(/wd4251)
ov_add_compiler_flags(/wd4251)
# C4275 non dll-interface class used as base for dll-interface class
ie_add_compiler_flags(/wd4275)
ov_add_compiler_flags(/wd4275)

# Enable __FILE__ trim, use path with forward and backward slash as directory separator
add_compile_options(
Expand All @@ -400,48 +402,48 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND WIN32)
#

if(CMAKE_COMPILE_WARNING_AS_ERROR AND CMAKE_VERSION VERSION_LESS 3.24)
ie_add_compiler_flags(/Qdiag-warning:47,1740,1786)
ov_add_compiler_flags(/Qdiag-warning:47,1740,1786)
endif()

#
# Disable noisy warnings
#

# 161: unrecognized pragma
ie_add_compiler_flags(/Qdiag-disable:161)
ov_add_compiler_flags(/Qdiag-disable:161)
# 177: variable was declared but never referenced
ie_add_compiler_flags(/Qdiag-disable:177)
ov_add_compiler_flags(/Qdiag-disable:177)
# 556: not matched type of assigned function pointer
ie_add_compiler_flags(/Qdiag-disable:556)
ov_add_compiler_flags(/Qdiag-disable:556)
# 1744: field of class type without a DLL interface used in a class with a DLL interface
ie_add_compiler_flags(/Qdiag-disable:1744)
ov_add_compiler_flags(/Qdiag-disable:1744)
# 1879: unimplemented pragma ignored
ie_add_compiler_flags(/Qdiag-disable:1879)
ov_add_compiler_flags(/Qdiag-disable:1879)
# 2586: decorated name length exceeded, name was truncated
ie_add_compiler_flags(/Qdiag-disable:2586)
ov_add_compiler_flags(/Qdiag-disable:2586)
# 2651: attribute does not apply to any entity
ie_add_compiler_flags(/Qdiag-disable:2651)
ov_add_compiler_flags(/Qdiag-disable:2651)
# 3180: unrecognized OpenMP pragma
ie_add_compiler_flags(/Qdiag-disable:3180)
ov_add_compiler_flags(/Qdiag-disable:3180)
# 11075: To get full report use -Qopt-report:4 -Qopt-report-phase ipo
ie_add_compiler_flags(/Qdiag-disable:11075)
ov_add_compiler_flags(/Qdiag-disable:11075)
# 15335: was not vectorized: vectorization possible but seems inefficient.
# Use vector always directive or /Qvec-threshold0 to override
ie_add_compiler_flags(/Qdiag-disable:15335)
ov_add_compiler_flags(/Qdiag-disable:15335)
else()
#
# Common enabled warnings
#

# allow linker eliminating the unused code and data from the final executable
ie_add_compiler_flags(-ffunction-sections -fdata-sections)
ov_add_compiler_flags(-ffunction-sections -fdata-sections)
# emits text showing the command-line option controlling a diagnostic
ie_add_compiler_flags(-fdiagnostics-show-option)
ov_add_compiler_flags(-fdiagnostics-show-option)

# This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid
ie_add_compiler_flags(-Wall)
ov_add_compiler_flags(-Wall)
# Warn if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero.
ie_add_compiler_flags(-Wundef)
ov_add_compiler_flags(-Wundef)

# To guarantee OpenVINO can be used with gcc versions 7 through 12
# - https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html
Expand All @@ -468,7 +470,7 @@ else()
#

if(CMAKE_COMPILE_WARNING_AS_ERROR AND CMAKE_VERSION VERSION_LESS 3.24)
ie_add_compiler_flags(-Werror)
ov_add_compiler_flags(-Werror)
endif()

#
Expand All @@ -477,7 +479,7 @@ else()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# 177: function "XXX" was declared but never referenced
ie_add_compiler_flags(-diag-disable=remark,177,2196)
ov_add_compiler_flags(-diag-disable=remark,177,2196)
endif()

#
Expand All @@ -493,8 +495,8 @@ else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ERROR_ON_MISSING_LIBRARIES=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
ie_add_compiler_flags(-sDISABLE_EXCEPTION_CATCHING=0)
# ie_add_compiler_flags(-sUSE_PTHREADS=1)
ov_add_compiler_flags(-sDISABLE_EXCEPTION_CATCHING=0)
# ov_add_compiler_flags(-sUSE_PTHREADS=1)
else()
set(exclude_libs "-Wl,--exclude-libs,ALL")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections ${exclude_libs}")
Expand All @@ -507,7 +509,6 @@ else()
endif()

add_compile_definitions(

# Defines to trim check of __FILE__ macro in case if not done by compiler.
OV_NATIVE_PARENT_PROJECT_ROOT_DIR="${OV_NATIVE_PARENT_PROJECT_ROOT_DIR}")

Expand All @@ -519,11 +520,11 @@ endif()
check_cxx_compiler_flag("-Wunused-but-set-variable" UNUSED_BUT_SET_VARIABLE_SUPPORTED)

#
# link_system_libraries(target <PUBLIC | PRIVATE | INTERFACE> <lib1 [lib2 lib3 ...]>)
# ov_link_system_libraries(target <PUBLIC | PRIVATE | INTERFACE> <lib1 [lib2 lib3 ...]>)
#
# Links provided libraries and include their INTERFACE_INCLUDE_DIRECTORIES as SYSTEM
#
function(link_system_libraries TARGET_NAME)
function(ov_link_system_libraries TARGET_NAME)
set(MODE PRIVATE)

foreach(arg IN LISTS ARGN)
Expand Down
22 changes: 11 additions & 11 deletions cmake/developer_package/faster_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

include(CMakeParseArguments)

function(ie_faster_build TARGET_NAME)
function(ov_build_target_faster TARGET_NAME)
if(NOT ENABLE_FASTER_BUILD)
return()
endif()

cmake_parse_arguments(IE_FASTER_BUILD "UNITY" "" "PCH" ${ARGN})
cmake_parse_arguments(FASTER_BUILD "UNITY" "" "PCH" ${ARGN})

if(IE_FASTER_BUILD_UNITY)
set_target_properties(${TARGET_NAME}
PROPERTIES
UNITY_BUILD ON
)
if(FASTER_BUILD_UNITY)
set_target_properties(${TARGET_NAME} PROPERTIES UNITY_BUILD ON)
endif()

if(IE_FASTER_BUILD_PCH)
target_precompile_headers(${TARGET_NAME}
${IE_FASTER_BUILD_PCH}
)
if(FASTER_BUILD_PCH)
target_precompile_headers(${TARGET_NAME} ${FASTER_BUILD_PCH})
endif()
endfunction()

function(ie_faster_build)
message(WARNING "ie_faster_build is deprecated, use ov_build_target_faster instead")
ov_build_target_faster(${ARGV})
endfunction()
2 changes: 1 addition & 1 deletion cmake/developer_package/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else()
ie_option(USE_BUILD_TYPE_SUBFOLDER "Create dedicated sub-folder per build type for output binaries" ON)
endif()

if(DEFINED ENV{CI_BUILD_NUMBER} AND NOT (WIN32 OR (CMAKE_CROSSCOMPILING AND AARCH64)))
if(DEFINED ENV{CI_BUILD_NUMBER} AND NOT (WIN32 OR CMAKE_CROSSCOMPILING))
set(CMAKE_COMPILE_WARNING_AS_ERROR_DEFAULT ON)
else()
set(CMAKE_COMPILE_WARNING_AS_ERROR_DEFAULT OFF)
Expand Down
13 changes: 9 additions & 4 deletions cmake/developer_package/frontends/frontends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ macro(ov_add_frontend)
"-Dget_api_version=get_api_version_${OV_FRONTEND_NAME}")
endif()

# remove -Wmissing-declarations warning, because of frontends implementation specific
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
target_compile_options(${TARGET_NAME} PRIVATE -Wno-missing-declarations)
endif()

target_include_directories(${TARGET_NAME}
PUBLIC
$<BUILD_INTERFACE:${${TARGET_NAME}_INCLUDE_DIR}>
Expand Down Expand Up @@ -219,7 +224,7 @@ macro(ov_add_frontend)
set(protobuf_target_name "protobuf::${protobuf_target_name}")
endif()

link_system_libraries(${TARGET_NAME} PRIVATE ${protobuf_target_name})
ov_link_system_libraries(${TARGET_NAME} PRIVATE ${protobuf_target_name})

# protobuf generated code emits -Wsuggest-override error
if(SUGGEST_OVERRIDE_SUPPORTED)
Expand All @@ -242,8 +247,8 @@ macro(ov_add_frontend)
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${flatbuffers_INCLUDE_DIRECTORIES})
endif()

add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}
EXCLUDE_PATTERNS ${PROTO_SRCS} ${PROTO_HDRS} ${proto_files} ${flatbuffers_schema_files})
ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}
EXCLUDE_PATTERNS ${PROTO_SRCS} ${PROTO_HDRS} ${proto_files} ${flatbuffers_schema_files})

# enable LTO
set_target_properties(${TARGET_NAME} PROPERTIES
Expand All @@ -263,7 +268,7 @@ macro(ov_add_frontend)
add_dependencies(ov_frontends ${TARGET_NAME})

# must be called after all target_link_libraries
ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME})
ov_add_api_validator_post_build_step(TARGET ${TARGET_NAME})

# since frontends are user-facing component which can be linked against,
# then we need to mark it to be CXX ABI free
Expand Down
2 changes: 1 addition & 1 deletion cmake/developer_package/plugins/plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function(ov_add_plugin)
endforeach()

if (OV_PLUGIN_ADD_CLANG_FORMAT)
add_clang_format_target(${OV_PLUGIN_NAME}_clang FOR_SOURCES ${OV_PLUGIN_SOURCES})
ov_add_clang_format_target(${OV_PLUGIN_NAME}_clang FOR_SOURCES ${OV_PLUGIN_SOURCES})
else()
add_cpplint_target(${OV_PLUGIN_NAME}_cpplint FOR_TARGETS ${OV_PLUGIN_NAME} CUSTOM_FILTERS ${custom_filter})
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/extra_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ endif()\n")

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# 'argument': conversion from 'size_t' to 'int', possible loss of data
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4244)
ov_add_compiler_flags(/wd4267)
ov_add_compiler_flags(/wd4244)
endif()

# add each extra module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ if(ENABLE_SAMPLES)
set_and_check(gflags_DIR "@gflags_BINARY_DIR@")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Disable warning as error for private components
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
endif()
# Disable warning as error for private components
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)

#
# Content
Expand Down
Loading

0 comments on commit a8752dd

Please sign in to comment.