[intel-npu] Fix build when using specific Werror (#24250)

The commit eb025fad1e breaks the build
when `CXXFLAGS` or `CFLAGS` have a specific `-Werror` flag.

For example, when `CXXFLAGS` have `-Werror=format-security`, the build
fails with this message:

```
c++: warning: =format-security: linker input file unused because linking not done
c++: error: =format-security: linker input file not found: No such file or directory
```

That's because every occurrence of the `-Werror` string is being
replaced in the original `CXXFLAGS` and `CFLAGS` variables. So, if they
contain `-Werror=<something>`, it will become just `=<something>`, which
will be an unrecognized option.

The current commit fixes this by appending `-Wno-error` to `CXXFLAGS`
and `CFLAGS` to properly disable errors on warnings.
This commit is contained in:
Daniel Bermond 2024-04-26 20:10:21 -03:00 committed by GitHub
parent 8c9c6016c1
commit 4655dd6ce3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 2 deletions

View File

@ -22,8 +22,7 @@ if(ENABLE_ZEROAPI_BACKEND)
# Close spectre for ze loader
add_compile_options("/Qspectre-")
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
ov_add_compiler_flags(-Wno-error)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-undef \
-Wno-unused-but-set-variable \