From 105f5f0f20d5308ca081e47825d18d4d8737eaea Mon Sep 17 00:00:00 2001 From: yf711 <109183385+yf711@users.noreply.github.com> Date: Wed, 24 May 2023 13:19:27 -0700 Subject: [PATCH] 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 https://github.com/microsoft/onnxruntime/blob/89ea503024cadd56b18fd8f8109fb15a07815eef/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 | --- cmake/onnxruntime_unittests.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 416a4a2928..5d388e1f3c 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -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")