Update to the latest cmake for Windows (#13604)

* Update to the latest cmake for Windows

* Skip new warnings

* Added compiler flags for old cmake

* Disabled some warnings

* Suppress new warnings

* Fixed some errors

* Disable some warning for lpt

* Fix some warnings

* Disable new warnings

* Fix some warnings

* Disabled Was error for arm

* Fixed some errors

* Fixed some new warnings

* Fixed auto plugin

* Fixed Windows warning

* Fixed Windows

* Disable some warnings

* Some changes

* Small test fixes

* Fixed python build

* Added skip warnings for legacy python API
This commit is contained in:
Ilya Churaev 2022-10-25 18:11:46 +04:00 committed by GitHub
parent dd3a37657c
commit 2a344b66cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 105 additions and 20 deletions

View File

@ -156,7 +156,7 @@ jobs:
cmakeArgs: >
-GNinja
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DCMAKE_COMPILE_WARNING_AS_ERROR=OFF
-DOpenCV_DIR=$(INSTALL_OPENCV)/cmake
-DPYTHON_INCLUDE_DIRS=$(INSTALL_PYTHON)/include/python3.8
-DPYTHON_LIBRARY=$(INSTALL_PYTHON)/lib/libpython3.8.so

View File

@ -74,7 +74,7 @@ jobs:
IB_DIR: C:\Program Files (x86)\IncrediBuild
IB_TESTCONSOLE: $(IB_DIR)\IBTestConsole.exe
PYTHON_DIR: C:\hostedtoolcache\windows\Python\3.7.6\x64
CMAKE_VERSION: 3.21.0
CMAKE_VERSION: 3.24.0
CMAKE_CMD: $(WORK_DIR)\cmake-$(CMAKE_VERSION)-windows-x86_64\cmake-$(CMAKE_VERSION)-windows-x86_64\bin\cmake.exe
OV_CMAKE_TOOLCHAIN_FILE: $(REPO_DIR)\cmake\toolchains\mt.runtime.win32.toolchain.cmake

View File

@ -265,6 +265,9 @@ if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
if (CMAKE_COMPILE_WARNING_AS_ERROR)
if (CMAKE_VERSION VERSION_LESS 3.24)
ie_add_compiler_flags(/WX)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
ie_add_compiler_flags(/Qdiag-warning:47,1740,1786)
endif()
@ -307,6 +310,11 @@ if(WIN32)
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
else()
if (CMAKE_COMPILE_WARNING_AS_ERROR AND CMAKE_VERSION VERSION_LESS 3.24)
# TODO: enable for C sources as well
# ie_add_compiler_flags(-Werror)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
ie_add_compiler_flags(-ffunction-sections -fdata-sections)
ie_add_compiler_flags(-fdiagnostics-show-option)
ie_add_compiler_flags(-Wundef)

View File

@ -4,6 +4,10 @@
set(TARGET_NAME openvino_c)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4267)
endif()
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB HEADERS ${OpenVINO_C_API_SOURCE_DIR}/include/*)

View File

@ -34,6 +34,7 @@ endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# disable warning: This operator was deprecated and will be removed with v0 operation.
add_compile_options(/wd4996)
add_compile_options(/wd4244)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-deprecated-register -Wno-range-loop-analysis)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")

View File

@ -29,6 +29,7 @@ endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# disable warning: This operator was deprecated and will be removed with v0 operation.
add_compile_options(/wd4996)
add_compile_options(/wd4244)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-deprecated-register -Wno-range-loop-analysis)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")

View File

@ -4,6 +4,10 @@
set (TARGET_NAME "inference_engine_lp_transformations")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4267)
endif()
set(PUBLIC_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

View File

@ -4,6 +4,11 @@
set(TARGET_NAME "offline_transformations")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4244)
ie_add_compiler_flags(/wd4267)
endif()
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)

View File

@ -9,6 +9,13 @@ file(GLOB_RECURSE PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)
set(PUBLIC_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4018)
ie_add_compiler_flags(/wd4305)
ie_add_compiler_flags(/wd4267)
endif()
# Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj

View File

@ -30,6 +30,10 @@ set_property(SOURCE ${MIXED_SRC}
$<TARGET_PROPERTY:inference_engine_obj,SOURCE_DIR>/src
$<TARGET_PROPERTY:inference_engine_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4244)
endif()
# Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj
@ -101,6 +105,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif()
target_link_options(ngraph_obj ${link_type} "/IGNORE:4217,4286")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4267)
endif()
endif()
# some sources are located in ngraph, while headers are in inference_engine_transformations

View File

@ -4,6 +4,10 @@
set(TARGET_NAME "ngraph_reference")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4267)
endif()
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)

View File

@ -97,7 +97,7 @@ static void generate_proposal_refine_anchors(const std::vector<float>& deltas,
proposals[p_idx + 2] = x1;
proposals[p_idx + 3] = y1;
proposals[p_idx + 4] = score;
proposals[p_idx + 5] = (min_box_W <= box_w) * (min_box_H <= box_h) * 1.0;
proposals[p_idx + 5] = (min_box_W <= box_w) * (min_box_H <= box_h) * 1.0f;
// update index for next anchor iter
a_idx += 4; // anchors shape is [bottom_H, bottom_W, anchors_num, 4], so add 4 for next anchor iter
@ -261,7 +261,7 @@ static void generate_proposals_single_image(const std::vector<float>& im_info,
const int64_t pre_nms_topn = std::min(num_proposals, attrs.pre_nms_count);
// bbox normalized flag
const float coordinates_offset = attrs.normalized ? 0 : 1.0;
const float coordinates_offset = attrs.normalized ? 0.f : 1.f;
std::vector<sProposalBox> proposals(num_proposals);
std::vector<float> unpacked_boxes(5 * pre_nms_topn);

View File

@ -26,7 +26,7 @@ using complex_type = std::complex<float>;
// Remove element (dimension from shape or value from stride) on the given position
template <typename T>
std::vector<T> remove_from_position(const std::vector<T>& vec, const int64_t pos) {
assert(vec.size() > pos);
assert(vec.size() > static_cast<size_t>(pos));
auto result = vec;
result.erase(std::begin(result) + pos);
return result;

View File

@ -211,7 +211,7 @@ std::vector<T> slice_image(const T* data, const Shape& data_shape, const int64_t
const auto item_size = (data_shape.size() == 3) ? data_shape[2] : 1;
// start and end should within [0, M)
OPENVINO_ASSERT(start >= 0 && (start + item_num) <= data_shape[1],
OPENVINO_ASSERT(start >= 0 && (start + item_num) <= static_cast<int64_t>(data_shape[1]),
"Invaid inputs as it is trying to slice data out of range.");
const auto row_num = item_num * item_size;

View File

@ -4,6 +4,10 @@
set(TARGET_NAME "ov_shape_inference")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4018)
endif()
file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)

View File

@ -207,8 +207,8 @@ void divide_ceil(const DimType& dividend, const typename DimType::value_type& di
if (dividend.get_max_length() == -1) {
quotient = -1;
} else {
auto lb = ceil(1. * dividend.get_min_length() / divisor);
auto ub = ceil(1. * dividend.get_max_length() / divisor);
auto lb = static_cast<int64_t>(ceil(1. * dividend.get_min_length() / divisor));
auto ub = static_cast<int64_t>(ceil(1. * dividend.get_max_length() / divisor));
quotient = DimType(lb, ub);
}
}

View File

@ -42,7 +42,7 @@ void irdft_shape_infer(const ov::op::v9::IRDFT* op,
output_shape.resize(input_rank - 1);
if (axes_shape.rank().is_dynamic() || !axes_are_known) {
for (int64_t i = 0; i < input_rank - 1; ++i) {
for (size_t i = 0; i < input_rank - 1; ++i) {
output_shape[i] = ov::Dimension::dynamic();
}
return;

View File

@ -55,7 +55,7 @@ void rdft_shape_infer(const ov::op::v9::RDFT* op,
const auto input_rank = input_shape.size();
if (axes_shape.rank().is_dynamic() || !axes_are_known) {
for (int64_t i = 0; i < input_rank; ++i) {
for (size_t i = 0; i < input_rank; ++i) {
output_shape[i] = ov::Dimension::dynamic();
}
return;

View File

@ -39,7 +39,7 @@ void validate_input_rank(const ov::op::util::FFTBase* op,
if (rfft_kind == RFFTKind::Forward) {
NODE_VALIDATION_CHECK(op,
input_rank >= static_cast<int64_t>(axes_shape[0].get_length()),
input_rank >= static_cast<size_t>(axes_shape[0].get_length()),
"The input rank must be greater than or equal to the number of RDFT op axes. "
"Got input rank: ",
input_rank,
@ -47,7 +47,7 @@ void validate_input_rank(const ov::op::util::FFTBase* op,
axes_shape[0].get_length());
} else {
NODE_VALIDATION_CHECK(op,
input_rank >= static_cast<int64_t>(axes_shape[0].get_length() + 1),
input_rank >= static_cast<size_t>(axes_shape[0].get_length() + 1),
"The input rank must be greater than number of IRDFT op axes. Got "
"input rank: ",
input_rank,

View File

@ -132,7 +132,7 @@ void shape_infer(const StridedSlice* op,
// only one bit in ellipsis mask is allowed
int num_new_axis_after_ellipses = 0;
int num_input_axis_before_ellipses = 0;
for (size_t i = 0; i < axis; ++i) {
for (int64_t i = 0; i < axis; ++i) {
if (!new_axis_mask.count(i)) {
num_input_axis_before_ellipses++;
}
@ -165,7 +165,7 @@ void shape_infer(const StridedSlice* op,
const int64_t ub0 = end[axis];
// set default value for stride or use given value
int64_t stride = 1;
if (strides.size() > axis) {
if (strides.size() > static_cast<size_t>(axis)) {
stride = strides[axis];
}
NODE_VALIDATION_CHECK(op, stride != 0, "Stride must be non-zero");

View File

@ -86,8 +86,8 @@ Dimension Dimension::operator/(const value_type divisor) const {
return *this;
if (m_dimension.get_max_val() == Interval::s_max && m_dimension.get_min_val() == 0)
return Dimension::dynamic();
const auto& lower_bound = ceil(static_cast<double>(m_dimension.get_min_val()) / divisor);
const auto& upper_bound = floor(static_cast<double>(m_dimension.get_max_val()) / divisor);
const auto& lower_bound = static_cast<int64_t>(ceil(static_cast<double>(m_dimension.get_min_val()) / divisor));
const auto& upper_bound = static_cast<int64_t>(floor(static_cast<double>(m_dimension.get_max_val()) / divisor));
return Dimension(lower_bound, upper_bound);
}

View File

@ -2,6 +2,12 @@
# SPDX-License-Identifier: Apache-2.0
#
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4018)
ie_add_compiler_flags(/wd4244)
endif()
ov_add_frontend(NAME onnx
LINKABLE_FRONTEND
PROTOBUF_LITE

View File

@ -10,6 +10,12 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT ENABLE_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4244)
ie_add_compiler_flags(/wd4267)
endif()
message(STATUS "ONNX frontend test enabled")
add_compile_definitions(

View File

@ -2,6 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
#
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4305)
endif()
ov_add_frontend(NAME paddle
LINKABLE_FRONTEND
PROTOBUF_LITE

View File

@ -2,6 +2,12 @@
# SPDX-License-Identifier: Apache-2.0
#
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4244)
ie_add_compiler_flags(/wd4018)
ie_add_compiler_flags(/wd4267)
endif()
if(NOT CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW)$")
set(linkable_frontend LINKABLE_FRONTEND)
endif()

View File

@ -200,7 +200,7 @@ std::vector<std::shared_ptr<OpPlace>> InputModel::InputModelTFImpl::determine_cu
size_t producer_output_port_idx;
try {
current_operation_decoder->get_input_node(input_port_idx, producer_name, producer_output_port_idx);
} catch (const std::exception& e) {
} catch (const std::exception&) {
FRONT_END_THROW("[ ERROR ] Exception happened when preparing input " +
std::to_string(input_port_idx) + " for op '" +
current_operation_decoder->get_op_name() + "', expected input name: '" +

View File

@ -227,7 +227,7 @@ class CoreImpl : public ie::ICore, public std::enable_shared_from_this<ie::ICore
std::lock_guard<std::mutex> lock(global_mutex);
try {
return dev_mutexes.at(dev_name);
} catch (const std::out_of_range& ex) {
} catch (const std::out_of_range&) {
throw ov::Exception("Cannot get mutex for device: " + dev_name);
}
}

View File

@ -5,6 +5,11 @@ if(NOT ENABLE_AUTO AND NOT ENABLE_MULTI)
return()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4101)
ie_add_compiler_flags(/wd4267)
endif()
set (TARGET_NAME "openvino_auto_plugin")
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cpp)

View File

@ -22,6 +22,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4250)
# '<': signed/unsigned mismatch
ie_add_compiler_flags(/wd4018)
ie_add_compiler_flags(/wd4309)
endif()
if (WIN32)

View File

@ -8,6 +8,10 @@ if(BUILD_SHARED_LIBS)
set (OBJ_LIB $<TARGET_OBJECTS:openvino_intel_cpu_plugin_obj>)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd5051)
endif()
addIeTargetTest(
NAME ${TARGET_NAME}
ROOT ${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -18,6 +18,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4244)
# '<': signed/unsigned mismatch
ie_add_compiler_flags(/wd4018)
ie_add_compiler_flags(/wd4099)
ie_add_compiler_flags(/wd4200)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

View File

@ -1763,7 +1763,7 @@ void layout_optimizer::select_preferred_formats_for_onednn(program_node& node, d
// Conv or deconv gets a preferred format for its data input based on source memory description
// But an input format for fused post-ops should be same with an output format of conv/deconv
size_t prim_input;
size_t prim_input(0);
if (node.is_type<convolution>())
prim_input = node.get_dependency_index(node.as<convolution>().input());
if (node.is_type<deconvolution>())

View File

@ -17,6 +17,12 @@ set (SRC
int_backend.cpp int_executable.cpp evaluates_map.cpp
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4244)
ie_add_compiler_flags(/wd4018)
endif()
add_library(interpreter_backend STATIC EXCLUDE_FROM_ALL ${SRC})
add_library(openvino::interpreter_backend ALIAS interpreter_backend)

View File

@ -68,7 +68,7 @@ bool compare_rt_keys(const T& node1, const T& node2, std::ostream& err_log) {
err_log << "Values for " << key << " key are not equal.\n";
return false;
}
} catch (ov::Exception& e) {
} catch (const ov::Exception&) {
// Handle cases wen equality operator is not defined for some rt attribute
}
}