From fb9a00c36d030b385f264ddbc55cacf009d3d50e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 28 May 2021 01:41:20 +0000 Subject: [PATCH] highgui: cleanup and fixes --- modules/CMakeLists.txt | 2 -- modules/highgui/cmake/detect_gtk.cmake | 9 +++-- .../misc/plugins/plugin_gtk/CMakeLists.txt | 36 ++++++++++--------- modules/highgui/src/plugin_wrapper.impl.hpp | 3 +- modules/highgui/src/window.cpp | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index f2389d0c1b..6a8004036b 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,5 +1,3 @@ -ocv_cmake_dump_vars("" TOFILE "CMakeVars2.txt") -set(OCV_TEST_VAR 123) add_definitions(-D__OPENCV_BUILD=1) if(NOT OPENCV_MODULES_PATH) diff --git a/modules/highgui/cmake/detect_gtk.cmake b/modules/highgui/cmake/detect_gtk.cmake index 0ffa473d6a..1f91986020 100644 --- a/modules/highgui/cmake/detect_gtk.cmake +++ b/modules/highgui/cmake/detect_gtk.cmake @@ -1,15 +1,16 @@ # --- GTK --- ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT) -if(WITH_GTK AND NOT HAVE_QT) +if(WITH_GTK) if(NOT WITH_GTK_2_X) ocv_check_modules(GTK3 gtk+-3.0) if(HAVE_GTK3) ocv_add_external_target(gtk3 "${GTK3_INCLUDE_DIRS}" "${GTK3_LIBRARIES}" "HAVE_GTK3;HAVE_GTK") set(HAVE_GTK TRUE) + set(HAVE_GTK3 ${HAVE_GTK3} PARENT_SCOPE) set(GTK3_VERSION "${GTK3_VERSION}" PARENT_SCOPE) # informational endif() endif() - if(TRUE) + if((PROJECT_NAME STREQUAL "OpenCV" AND HIGHGUI_ENABLE_PLUGINS) OR NOT HAVE_GTK3) ocv_check_modules(GTK2 gtk+-2.0) if(HAVE_GTK2) set(MIN_VER_GTK "2.18.0") @@ -18,6 +19,7 @@ if(WITH_GTK AND NOT HAVE_QT) else() ocv_add_external_target(gtk2 "${GTK2_INCLUDE_DIRS}" "${GTK2_LIBRARIES}" "HAVE_GTK2;HAVE_GTK") set(HAVE_GTK TRUE) + set(HAVE_GTK2 ${HAVE_GTK2} PARENT_SCOPE) set(GTK2_VERSION "${GTK2_VERSION}" PARENT_SCOPE) # informational endif() endif() @@ -38,7 +40,8 @@ if(WITH_GTK AND NOT HAVE_QT) set(GTKGLEXT_VERSION "${GTKGLEXT_VERSION}" PARENT_SCOPE) # informational endif() endif() +elseif(HAVE_GTK) + ocv_add_external_target(gtk "${GTK_INCLUDE_DIRS}" "${GTK_LIBRARIES}" "${GTK_DEFINES};HAVE_GTK") endif() set(HAVE_GTK ${HAVE_GTK} PARENT_SCOPE) -set(HAVE_GTK3 ${HAVE_GTK3} PARENT_SCOPE) diff --git a/modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt b/modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt index ad869057a6..22462900f1 100644 --- a/modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt +++ b/modules/highgui/misc/plugins/plugin_gtk/CMakeLists.txt @@ -8,6 +8,10 @@ include("${OpenCV_SOURCE_DIR}/cmake/OpenCVPluginStandalone.cmake") set(WITH_GTK ON) include("${OpenCV_SOURCE_DIR}/modules/highgui/cmake/init.cmake") +if(NOT HAVE_GTK) + message(FATAL_ERROR "GTK: NO") +endif() + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations) set(OPENCV_PLUGIN_DEPS core imgproc imgcodecs) @@ -22,23 +26,23 @@ else() endif() ocv_create_plugin(highgui "opencv_highgui_gtk" "${__deps}" "GTK" "src/window_gtk.cpp") -message(STATUS "GTK: ${GTK2_VERSION}") if(HAVE_GTK3) - message(STATUS "GTK+: ver ${GTK3_VERSION}") -elseif(HAVE_GTK) - message(STATUS "GTK+: ver ${GTK2_VERSION}") + message(STATUS "GTK3+: ver ${GTK3_VERSION}") +elseif(HAVE_GTK3) + message(STATUS "GTK2+: ver ${GTK2_VERSION}") +elseif(DEFINED GTK_VERSION) + message(STATUS "GTK+: ver ${GTK_VERSION}") else() - message(FATAL_ERROR "GTK+: NO") + message(STATUS "GTK+: YES") endif() -if(HAVE_GTK) - if(HAVE_GTHREAD) - message(STATUS "GThread : YES (ver ${GTHREAD_VERSION})") - else() - message(STATUS "GThread : NO") - endif() - if(HAVE_GTKGLEXT) - message(STATUS "GtkGlExt: YES (ver ${GTKGLEXT_VERSION})") - else() - message(STATUS "GtkGlExt: NO") - endif() + +if(HAVE_GTHREAD) + message(STATUS "GThread : YES (ver ${GTHREAD_VERSION})") +else() + message(STATUS "GThread : NO") +endif() +if(HAVE_GTKGLEXT) + message(STATUS "GtkGlExt: YES (ver ${GTKGLEXT_VERSION})") +else() + message(STATUS "GtkGlExt: NO") endif() diff --git a/modules/highgui/src/plugin_wrapper.impl.hpp b/modules/highgui/src/plugin_wrapper.impl.hpp index e68f73cb01..3fa2cfa11a 100644 --- a/modules/highgui/src/plugin_wrapper.impl.hpp +++ b/modules/highgui/src/plugin_wrapper.impl.hpp @@ -40,7 +40,8 @@ protected: CV_LOG_INFO(NULL, "UI: plugin is incompatible (can't be initialized): " << lib_->getName()); return; } - if (!checkCompatibility(plugin_api_->api_header, ABI_VERSION, API_VERSION, false)) + // NB: force strict minor version check (ABI is not preserved for now) + if (!checkCompatibility(plugin_api_->api_header, ABI_VERSION, API_VERSION, true)) { plugin_api_ = NULL; return; diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index 782480805b..7a4532e1b8 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -198,7 +198,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu //change between fullscreen or not. case CV_WND_PROP_FULLSCREEN: - if (!name || (prop_value!=CV_WINDOW_NORMAL && prop_value!=CV_WINDOW_FULLSCREEN))//bad argument + if (prop_value != CV_WINDOW_NORMAL && prop_value != CV_WINDOW_FULLSCREEN) // bad argument break; #if defined (HAVE_QT)