Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Enable warnings as errors (#26557)

Alexandru Enache5f86ffbe2f7d
diff --git a/src/plugins/intel_npu/CMakeLists.txt b/src/plugins/intel_npu/CMakeLists.txt
index efd39bf730a..f22e81fd29a 100644
--- a/src/plugins/intel_npu/CMakeLists.txt
+++ b/src/plugins/intel_npu/CMakeLists.txt
@@ -26,6 +26,46 @@ endif()
add_subdirectory(thirdparty EXCLUDE_FROM_ALL)
+#
+# Warnings as errors
+#
+
+macro(remove_compiler_flags FLAGS)
+ string(REPLACE " " ";" _tokened_list "${FLAGS}")
+ foreach(flag IN LISTS _tokened_list)
+ string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ string(REPLACE "${flag}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+ string(REPLACE "${flag}" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+ endforeach()
+endmacro()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
+ remove_compiler_flags(/wd4996)
+ if(CMAKE_VERSION VERSION_LESS 3.24)
+ 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")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /WX")
+endif()
+
+if(CMAKE_COMPILE_WARNING_AS_ERROR)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
+ remove_compiler_flags(-Wno-error=deprecated-declarations)
+ ov_add_compiler_flags(-Werror)
+
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ if(WIN32)
+ remove_compiler_flags(/Qdiag-disable:1478,1786)
+ else()
+ remove_compiler_flags(-diag-disable=1478,1786)
+ endif()
+ endif()
+endif()
+
add_subdirectory(src)
if(ENABLE_TESTS)
diff --git a/src/plugins/intel_npu/tests/functional/main.cpp b/src/plugins/intel_npu/tests/functional/main.cpp
index 10ad66b5b7f..07e33d65d4e 100644
--- a/src/plugins/intel_npu/tests/functional/main.cpp
+++ b/src/plugins/intel_npu/tests/functional/main.cpp
@@ -3,6 +3,9 @@
//
#include <signal.h>
+#ifdef WIN32
+#include <process.h>
+#endif
#include <functional_test_utils/summary/op_summary.hpp>
#include <iostream>
#include <sstream>
@@ -38,7 +41,12 @@ int main(int argc, char** argv, char** envp) {
}
oss << std::endl;
- oss << "Process id: " << getpid() << std::endl;
+# ifdef WIN32
+ oss << "Process id: " << _getpid() << std::endl;
+# else
+ oss << "Process id: " << getpid() << std::endl;
+# endif
+
std::cout << oss.str();
oss.str("");
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp
index c6a1ca70527..d43011ac362 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp
@@ -135,7 +135,6 @@ const std::vector<ov::AnyMap> IncorrectMutablePropertiesWrongValueTypes = {
};
const std::vector<ov::AnyMap> IncorrectInexistingProperties = {
- {{ov::affinity.name(), ov::Affinity::HYBRID_AWARE}},
{{ov::intel_cpu::denormals_optimization.name(), true}},
{{ov::intel_gpu::hint::host_task_priority.name(), ov::hint::Priority::LOW}},
{{ov::intel_gpu::hint::queue_throttle.name(), ov::intel_gpu::hint::ThrottleLevel::HIGH}}};