Skip to content

Commit 4ac0857

Browse files
DarellLdarkpaceholder
authored andcommitted
Fixed building with Qt5 and Qt6 versions installed in the same time
1 parent 931196d commit 4ac0857

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/workflows/cmake_build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,28 @@ jobs:
3232
compiler: gcc
3333
qt_version: "5.15.2"
3434
modules: ""
35+
use_qt6: "OFF"
3536

3637
- toolchain: macos-clang
3738
os: macos-latest
3839
compiler: clang
3940
qt_version: "5.15.2"
4041
modules: ""
42+
use_qt6: "OFF"
4143

4244
- toolchain: windows-msvc
4345
os: windows-latest
4446
compiler: msvc
4547
qt_version: "5.15.2"
4648
modules: ""
49+
use_qt6: "OFF"
4750

4851
- toolchain: windows-msvc
4952
os: windows-latest
5053
compiler: msvc
5154
qt_version: "6.3.0"
5255
modules: "qt5compat"
56+
use_qt6: "ON"
5357

5458
steps:
5559
- name: Checkout Code
@@ -74,7 +78,7 @@ jobs:
7478
arch: x64
7579

7680
- name: Configure (${{ matrix.configuration }})
77-
run: cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DBUILD_DOCS=OFF
81+
run: cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DBUILD_DOCS=OFF -DUSE_QT6=${{ matrix.use_qt6 }}
7882

7983
- name: Build with ${{ matrix.compiler }}
8084
run: cmake --build build --config ${{ matrix.configuration }}

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ option(BUILD_DOCS "Build Documentation" "${QT_NODES_DEVELOPER_DEFAULTS}")
2828
option(BUILD_SHARED_LIBS "Build as shared library" ON)
2929
option(BUILD_DEBUG_POSTFIX_D "Append d suffix to debug libraries" OFF)
3030
option(QT_NODES_FORCE_TEST_COLOR "Force colorized unit test output" OFF)
31+
option(USE_QT6 "Build with Qt6 (Enabled by default)" ON)
3132

3233
enable_testing()
3334

@@ -46,7 +47,12 @@ endif()
4647

4748
add_subdirectory(external)
4849

49-
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
50+
if(USE_QT6)
51+
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets)
52+
else()
53+
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Widgets)
54+
endif()
55+
5056
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Gui OpenGL)
5157
message(STATUS "QT_VERSION: ${QT_VERSION}, QT_DIR: ${QT_DIR}")
5258

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ Current State (v3)
103103
Building
104104
========
105105

106+
Set this option to false if you want to build with Qt5 version instead of Qt6:
107+
108+
::
109+
110+
USE_QT6
111+
112+
mkdir build && cd build && cmake .. -DUSE_QT6=on
113+
or
114+
mkdir build && cd build && cmake .. -DUSE_QT6=off
115+
106116
Linux
107117
-----
108118

0 commit comments

Comments
 (0)