opencv-4.8.1-eliminate-lto-compiler-warnings.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. https://github.com/opencv/opencv/pull/23991
  2. From 4ee0f212cc19f7e77483d34d4cf8378945e3da31 Mon Sep 17 00:00:00 2001
  3. From: =?UTF-8?q?=E4=B8=8D=E9=B1=BC=E5=84=BF?=
  4. <36976072+buyuer@users.noreply.github.com>
  5. Date: Fri, 14 Jul 2023 08:45:14 +0000
  6. Subject: [PATCH] Eliminating compilation warnings when using lto in gcc12 and
  7. later versions
  8. MIME-Version: 1.0
  9. Content-Type: text/plain; charset=UTF-8
  10. Content-Transfer-Encoding: 8bit
  11. use -flto=auto when use gcc12 or later
  12. Signed-off-by: 不鱼儿 <36976072+buyuer@users.noreply.github.com>
  13. ---
  14. cmake/OpenCVCompilerOptions.cmake | 6 +++++-
  15. 1 file changed, 5 insertions(+), 1 deletion(-)
  16. diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
  17. index d4600943fb0d..8bd86681303e 100644
  18. --- a/cmake/OpenCVCompilerOptions.cmake
  19. +++ b/cmake/OpenCVCompilerOptions.cmake
  20. @@ -261,7 +261,11 @@ if(CV_GCC OR CV_CLANG)
  21. endif()
  22. if(ENABLE_LTO)
  23. - add_extra_compiler_option(-flto)
  24. + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
  25. + add_extra_compiler_option(-flto=auto)
  26. + else()
  27. + add_extra_compiler_option(-flto)
  28. + endif()
  29. endif()
  30. if(ENABLE_THIN_LTO)
  31. add_extra_compiler_option(-flto=thin)