Skip to content

Commit ba4d8be

Browse files
committed
Try simpler Qt version management in CMakeLists.txt
1 parent 2647f05 commit ba4d8be

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,15 @@ if (BUILD_GUI)
4444
set(CMAKE_AUTOMOC ON) # The later version of this in LSLCMake is somehow not enough.
4545
set(CMAKE_AUTORCC ON)
4646
set(CMAKE_AUTOUIC ON)
47-
find_package(Qt6 COMPONENTS Core Widgets Network DBus)
48-
if(NOT Qt6_FOUND)
49-
# If we require 5.15 then we can use version-agnostic linking, but 5.15 not easily available on Ubuntu.
50-
find_package(Qt5 COMPONENTS Core Widgets Network DBus REQUIRED)
51-
add_executable(${PROJECT_NAME} MACOSX_BUNDLE)
52-
set(LSLAPP_QT_VER Qt5)
53-
else()
54-
qt_add_executable(${PROJECT_NAME} MACOSX_BUNDLE MANUAL_FINALIZATION)
55-
set(LSLAPP_QT_VER Qt)
56-
endif()
47+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
48+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Network DBus)
5749
endif(BUILD_GUI)
5850

5951
## Threads
6052
find_package(Threads REQUIRED)
6153

6254
# Targets
55+
add_executable(${PROJECT_NAME} MACOSX_BUNDLE)
6356

6457
## xdfwriter - stand alone library
6558
add_subdirectory(xdfwriter)
@@ -79,9 +72,10 @@ if (BUILD_GUI)
7972
target_link_libraries(${PROJECT_NAME}
8073
PRIVATE
8174
xdfwriter
82-
${LSLAPP_QT_VER}::Widgets
83-
${LSLAPP_QT_VER}::Network
84-
${LSLAPP_QT_VER}::DBus
75+
Qt${QT_VERSION_MAJOR}::Core
76+
Qt${QT_VERSION_MAJOR}::Widgets
77+
Qt${QT_VERSION_MAJOR}::Network
78+
Qt${QT_VERSION_MAJOR}::DBus
8579
Threads::Threads
8680
LSL::lsl
8781
)

0 commit comments

Comments
 (0)