Skip to content

Commit f318b5b

Browse files
committed
Improve GTK+ library selection logic.
The new logic will select GTK+3 by default if WITH_GTK is selected. If the GTK+3 libraries are not found, then GTK+2 libraries will be selected if found. This can be overridden by using WITH_GTK_2_X to force selection of GTK+2 (if found).
1 parent 1638341 commit f318b5b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

cmake/OpenCVFindLibsGUI.cmake

+4-8
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,14 @@ endif()
4141
# --- GTK ---
4242
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
4343
if(WITH_GTK AND NOT HAVE_QT)
44-
if(WITH_GTK_2_X)
44+
if(NOT WITH_GTK_2_X)
45+
CHECK_MODULE(gtk+-3.0 HAVE_GTK3)
46+
set(HAVE_GTK TRUE)
47+
elseif(NOT HAVE_GTK3)
4548
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
4649
if(HAVE_GTK AND (ALIASOF_gtk+-2.0_VERSION VERSION_LESS MIN_VER_GTK))
4750
message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${ALIASOF_gtk+-2.0_VERSION} found)")
4851
endif()
49-
else()
50-
CHECK_MODULE(gtk+-3.0 HAVE_GTK3)
51-
if(HAVE_GTK3)
52-
set(HAVE_GTK ON)
53-
else()
54-
message(WARNING "Unable to locate GTK3 development libraries")
55-
endif()
5652
endif()
5753
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
5854
if(HAVE_GTK OR HAVE_GTK3 AND NOT HAVE_GTHREAD)

0 commit comments

Comments
 (0)