Avoid trt deprecated api warnings shown as errors during ORT-TRT build (#16035)

### Description
Avoid trt deprecated api warnings shown as errors when building
onnxruntime_test_all
This issue is only visible when installing trt via binaries, rather than
deb/rpm pkg (CI pipelines)


The change is similar to existing set_property for
onnxruntime_providers_tensorrt

89ea503024/cmake/onnxruntime_providers.cmake (L421)

### Motivation and Context

onnxruntime/test/unittest_main/[test_main.cc](https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/test/unittest_main/test_main.cc#L32)
includes nvinfer.h, which includes deprecated trt apis and and generates
warnings.
When building onnxruntime_test_all, it will show warnings as errors and
block the build.

### Doubts
Although this issue is visible on trt tar binaries but not on trt
deb/rpm pkgs,
Their file size&hash are the same (creation time vary), regarding
headers/libs installing in different ways.
| tarBin | pkg |
| ------------------------------------------------------------ |
------------------------------------------------------------ |
| 997284784 Apr 26 15:15 libnvinfer_builder_resource.so.8.6.1 |
997284784 Apr 26 22:21 libnvinfer_builder_resource.so.8.6.1 |
| 235369632 Apr 26 15:14 libnvinfer.so.8.6.1 | 235369632 Apr 26 22:21
libnvinfer.so.8.6.1 |
This commit is contained in:
yf711 2023-05-24 13:19:27 -07:00 committed by GitHub
parent 84f1af7ff5
commit 105f5f0f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -815,6 +815,10 @@ else()
target_compile_options(onnxruntime_test_all PRIVATE "-Wno-parentheses")
endif()
if (UNIX AND onnxruntime_USE_TENSORRT)
set_property(TARGET onnxruntime_test_all APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
endif()
if (MSVC AND onnxruntime_ENABLE_STATIC_ANALYSIS)
# attention_op_test.cc: Function uses '49152' bytes of stack: exceeds /analyze:stacksize '16384'..
target_compile_options(onnxruntime_test_all PRIVATE "/analyze:stacksize 131072")