From 8f1f3422bdab70f013d057831f5661b768337d42 Mon Sep 17 00:00:00 2001 From: Kumataro Date: Sun, 6 Sep 2026 11:30:24 +0900 Subject: [PATCH] imgproc: skip downloading unifont when HarfBuzz is disabled - Skip downloading and embedding Unifont data when HAVE_HARFBUZZ is OFF - Note: When HAVE_HARFBUZZ is OFF, Rubik and Unifont binaries will be excluded from the build. --- modules/imgproc/CMakeLists.txt | 78 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/modules/imgproc/CMakeLists.txt b/modules/imgproc/CMakeLists.txt index e1b812a39f..d2a3a5f01b 100644 --- a/modules/imgproc/CMakeLists.txt +++ b/modules/imgproc/CMakeLists.txt @@ -27,46 +27,46 @@ if(HAVE_IPP) endif() endif() -set(UNIFONT_MD5 "fb79cf5b4f4c89414f1233f14c2eb273") -set(UNIFONT_NAME "WenQuanYiMicroHei.ttf.gz") -set(UNIFONT_COMMIT "cc7d85179d69a704bee209aa37ce8a657f2f8b34") -set(UNIFONT_URL "https://raw.githubusercontent.com/vpisarev/opencv_3rdparty/${UNIFONT_COMMIT}/") - -unset(HAVE_UNIFONT) -unset(HAVE_UNIFONT CACHE) - -if (WITH_UNIFONT) - ocv_download(FILENAME ${UNIFONT_NAME} - HASH ${UNIFONT_MD5} - URL - "${OPENCV_UNIFONT_URL}" - "${UNIFONT_URL}" - DESTINATION_DIR "${CMAKE_CURRENT_BINARY_DIR}" - ID UNIFONT - STATUS res - RELATIVE_URL) - - if (res) - message(STATUS "Unicode font has been downloaded successfully.") - set(HAVE_UNIFONT ON CACHE INTERNAL "") - else() - message(STATUS "Unicode font download failed. Turning it off.") - set(HAVE_UNIFONT OFF CACHE INTERNAL "") - endif() -else() - set(HAVE_UNIFONT OFF CACHE INTERNAL "") -endif() - -ocv_blob2hdr("${CMAKE_CURRENT_SOURCE_DIR}/fonts/Rubik.ttf.gz" "${CMAKE_CURRENT_BINARY_DIR}/builtin_font_sans.h" OcvBuiltinFontSans) -ocv_blob2hdr("${CMAKE_CURRENT_SOURCE_DIR}/fonts/Rubik-Italic.ttf.gz" "${CMAKE_CURRENT_BINARY_DIR}/builtin_font_italic.h" OcvBuiltinFontItalic) -if (HAVE_UNIFONT) - ocv_blob2hdr("${CMAKE_CURRENT_BINARY_DIR}/${UNIFONT_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/builtin_font_uni.h" OcvBuiltinFontUni) -endif() -include_directories("${CMAKE_CURRENT_BINARY_DIR}") -ocv_target_link_libraries(${the_module} LINK_PRIVATE ${ZLIB_LIBRARIES}) -ocv_install_3rdparty_licenses(fonts fonts/Rubik_OFL.txt) - if(HAVE_HARFBUZZ) + set(UNIFONT_MD5 "fb79cf5b4f4c89414f1233f14c2eb273") + set(UNIFONT_NAME "WenQuanYiMicroHei.ttf.gz") + set(UNIFONT_COMMIT "cc7d85179d69a704bee209aa37ce8a657f2f8b34") + set(UNIFONT_URL "https://raw.githubusercontent.com/vpisarev/opencv_3rdparty/${UNIFONT_COMMIT}/") + + unset(HAVE_UNIFONT) + unset(HAVE_UNIFONT CACHE) + + if (WITH_UNIFONT) + ocv_download(FILENAME ${UNIFONT_NAME} + HASH ${UNIFONT_MD5} + URL + "${OPENCV_UNIFONT_URL}" + "${UNIFONT_URL}" + DESTINATION_DIR "${CMAKE_CURRENT_BINARY_DIR}" + ID UNIFONT + STATUS res + RELATIVE_URL) + + if (res) + message(STATUS "Unicode font has been downloaded successfully.") + set(HAVE_UNIFONT ON CACHE INTERNAL "") + else() + message(STATUS "Unicode font download failed. Turning it off.") + set(HAVE_UNIFONT OFF CACHE INTERNAL "") + endif() + else() + set(HAVE_UNIFONT OFF CACHE INTERNAL "") + endif() + + ocv_blob2hdr("${CMAKE_CURRENT_SOURCE_DIR}/fonts/Rubik.ttf.gz" "${CMAKE_CURRENT_BINARY_DIR}/builtin_font_sans.h" OcvBuiltinFontSans) + ocv_blob2hdr("${CMAKE_CURRENT_SOURCE_DIR}/fonts/Rubik-Italic.ttf.gz" "${CMAKE_CURRENT_BINARY_DIR}/builtin_font_italic.h" OcvBuiltinFontItalic) + if (HAVE_UNIFONT) + ocv_blob2hdr("${CMAKE_CURRENT_BINARY_DIR}/${UNIFONT_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/builtin_font_uni.h" OcvBuiltinFontUni) + endif() + include_directories("${CMAKE_CURRENT_BINARY_DIR}") + ocv_target_link_libraries(${the_module} LINK_PRIVATE ${ZLIB_LIBRARIES}) + ocv_install_3rdparty_licenses(fonts fonts/Rubik_OFL.txt) + ocv_module_include_directories(opencv_imgproc ${HARFBUZZ_INCLUDE_DIR}) ocv_target_link_libraries(${the_module} LINK_PRIVATE ${HARFBUZZ_LIBRARIES}) if(HARFBUZZ_IS_BUNDLED)