From b9505ac861e3b166a515704bfc868a2d505de262 Mon Sep 17 00:00:00 2001 From: Kumataro Date: Fri, 3 Jan 2025 19:22:57 +0900 Subject: [PATCH] core: validate OPENCV_ALGO_HINT_DEFAULT option --- CMakeLists.txt | 7 +++++++ .../config_reference/config_reference.markdown | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e60406fbe2..74beaee5f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -767,6 +767,13 @@ elseif(WIN32) endif() endif() +if(DEFINED OPENCV_ALGO_HINT_DEFAULT) + if(NOT OPENCV_ALGO_HINT_DEFAULT STREQUAL "ALGO_HINT_ACCURATE" AND + NOT OPENCV_ALGO_HINT_DEFAULT STREQUAL "ALGO_HINT_APPROX") + message(FATAL_ERROR "OPENCV_ALGO_HINT_DEFAULT should be one of ALGO_HINT_ACCURATE or ALGO_HINT_APPROX.") + endif() +endif() + include(cmake/OpenCVPCHSupport.cmake) include(cmake/OpenCVModule.cmake) diff --git a/doc/tutorials/introduction/config_reference/config_reference.markdown b/doc/tutorials/introduction/config_reference/config_reference.markdown index 3c3c1d5c99..e6ffbb833c 100644 --- a/doc/tutorials/introduction/config_reference/config_reference.markdown +++ b/doc/tutorials/introduction/config_reference/config_reference.markdown @@ -217,7 +217,7 @@ Following options can be used to produce special builds with instrumentation or | `ENABLE_BUILD_HARDENING` | GCC, Clang, MSVC | Enable compiler options which reduce possibility of code exploitation. | | `ENABLE_LTO` | GCC, Clang, MSVC | Enable Link Time Optimization (LTO). | | `ENABLE_THIN_LTO` | Clang | Enable thin LTO which incorporates intermediate bitcode to binaries allowing consumers optimize their applications later. | -| `OPENCV_ALGO_HINT_DEFAULT` | Any | Set default OpenCV implementation hint value: `ALGO_HINT_ACCURATE` or `ALGO_HINT_APROX`. Dangerous! The option changes behaviour globally and may affect accuracy of many algorithms. | +| `OPENCV_ALGO_HINT_DEFAULT` | Any | Set default OpenCV implementation hint value: `ALGO_HINT_ACCURATE` or `ALGO_HINT_APPROX`. Dangerous! The option changes behaviour globally and may affect accuracy of many algorithms. | @see [GCC instrumentation](https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html) @see [Build hardening](https://en.wikipedia.org/wiki/Hardening_(computing))