From f81964e395cb7634d5c5997ddf1a48d9c0a8c822 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Wed, 12 Mar 2025 02:01:17 +0100 Subject: [PATCH] fix(cmake): project not compiling under qt6 due to missing opengl widgets dependency --- editor/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 78091e7..617be11 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -14,6 +14,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) + + set(TS_FILES editor_en_US.ts) set(PROJECT_SOURCES @@ -65,6 +67,16 @@ endif() target_include_directories(editor PUBLIC "../core/src" "../include") target_link_libraries(editor PRIVATE openblocks Qt${QT_VERSION_MAJOR}::Widgets) +# Qt6 does not include QOpenGLWidgets as part of Widgets base anymore, so +# we have to include it manually +if (${QT_VERSION} GREATER_EQUAL 6) + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS OpenGL OpenGLWidgets) + find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGL OpenGLWidgets) + + target_include_directories(editor PUBLIC Qt6::OpenGL Qt6::OpenGLWidgets) + target_link_libraries(editor PRIVATE Qt6::OpenGL Qt6::OpenGLWidgets) +endif() + # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though.