From 82818e7324fc212f37960c3c1e7e1ab99d4c8cc2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 20 Jan 2022 02:27:57 +0000 Subject: [PATCH] cmake(highgui): update handling of OpenGL libraries --- modules/highgui/CMakeLists.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 416fb5a315..b2ed5f9f4e 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -67,6 +67,9 @@ if(HAVE_QT) set(qt_deps Core Gui Widgets Test Concurrent) if(HAVE_QT_OPENGL) list(APPEND qt_deps OpenGL) + if(OPENGL_LIBRARIES) + list(APPEND HIGHGUI_LIBRARIES "${OPENGL_LIBRARIES}") + endif() endif() foreach(dt_dep ${qt_deps}) @@ -76,8 +79,11 @@ if(HAVE_QT) endforeach() else() ocv_assert(QT_VERSION_MAJOR EQUAL 4) - if (HAVE_QT_OPENGL) + if(HAVE_QT_OPENGL) set(QT_USE_QTOPENGL TRUE) + if(OPENGL_LIBRARIES) + list(APPEND HIGHGUI_LIBRARIES "${OPENGL_LIBRARIES}") + endif() endif() include(${QT_USE_FILE}) @@ -130,6 +136,9 @@ elseif(HAVE_WIN32UI) if(OpenCV_ARCH STREQUAL "ARM64") list(APPEND HIGHGUI_LIBRARIES "comdlg32" "advapi32") endif() + if(HAVE_OPENGL AND OPENGL_LIBRARIES) + list(APPEND HIGHGUI_LIBRARIES "${OPENGL_LIBRARIES}") + endif() elseif(HAVE_GTK OR HAVE_GTK3) list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp) elseif(HAVE_CARBON) @@ -163,10 +172,6 @@ if(APPLE) add_apple_compiler_options(${the_module}) endif() -if(HAVE_WIN32UI AND HAVE_OPENGL AND OPENGL_LIBRARIES) - ocv_target_link_libraries(${the_module} PRIVATE "${OPENGL_LIBRARIES}") -endif() - if(MSVC AND NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG") endif()