From 0b8cab368ba8a8603681a379fbbd9c7b6df4ab50 Mon Sep 17 00:00:00 2001 From: xi-guo Date: Thu, 27 Feb 2025 14:24:18 +0800 Subject: [PATCH] fix: qnx7.0 build --- CMakeLists.txt | 7 ++++++- modules/ts/CMakeLists.txt | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1739e066bd..6b607b943f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -720,6 +720,7 @@ if(UNIX OR MINGW) endif() include(CheckFunctionExists) include(CheckIncludeFile) + include(CheckLibraryExists) include(CheckSymbolExists) if(NOT APPLE) @@ -731,7 +732,11 @@ if(UNIX OR MINGW) elseif(EMSCRIPTEN) # no need to link to system libs with emscripten elseif(QNXNTO) - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m regex) + set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m) + CHECK_LIBRARY_EXISTS(regex regexec "" HAVE_REGEX_LIBRARY) + if(HAVE_REGEX_LIBRARY) + set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} regex) + endif() elseif(MINGW) set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} pthread) else() diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index 63edae1e67..5f984bd908 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -49,5 +49,9 @@ if(OPENCV_DISABLE_THREAD_SUPPORT) endif() if(CMAKE_SYSTEM_NAME STREQUAL "QNX") - ocv_target_link_libraries(${the_module} PUBLIC regex) -endif() \ No newline at end of file + include(CheckLibraryExists) + CHECK_LIBRARY_EXISTS(regex regexec "" HAVE_REGEX_LIBRARY) + if(HAVE_REGEX_LIBRARY) + ocv_target_link_libraries(${the_module} PUBLIC regex) + endif() +endif()