Skip to content

Commit fad2ce8

Browse files
committed
ENH: Simplify Qt version handling in CMake and consolidate component requirements
Removed repetitive Qt version conditionals across multiple CMake files. Consolidated and streamlined required Qt components for both Qt5 and Qt6, ensuring consistency and reducing redundancy.
1 parent ab78685 commit fad2ce8

File tree

6 files changed

+4
-26
lines changed

6 files changed

+4
-26
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
2121
option(FORCE_BUILD_QT5 "Force Qt5 build instead of Qt6" OFF)
2222

2323
if(FORCE_BUILD_QT5)
24-
find_package(Qt5 NAMES Qt5 REQUIRED COMPONENTS Core)
24+
find_package(Qt5 NAMES Qt5 REQUIRED COMPONENTS Core Widgets Xml)
2525
string(REPLACE "." ";" qt_version_list ${Qt5_VERSION})
2626
else()
27-
find_package(Qt6 NAMES Qt6 REQUIRED COMPONENTS Core)
27+
find_package(Qt6 NAMES Qt6 REQUIRED COMPONENTS Core Widgets Xml Core5Compat)
2828
string(REPLACE "." ";" qt_version_list ${Qt6_VERSION})
2929
endif()
3030
list(GET qt_version_list 0 QT_VERSION_MAJOR)
3131
list(GET qt_version_list 1 QT_VERSION_MINOR)
3232
list(GET qt_version_list 1 QT_VERSION_PATCH)
3333
message(STATUS "QT_VERSION_MAJOR = ${QT_VERSION_MAJOR}")
3434

35-
find_package(Python3 COMPONENTS Development)
35+
find_package(Python3 COMPONENTS Development REQUIRED)
3636

3737
# Set the environment as defined in Readme.md
3838
# Set environment variables for Python

generator/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
cmake_minimum_required(VERSION 3.27)
21
project(PythonQtGenerator LANGUAGES CXX)
32

43
add_subdirectory(parser)
54

65
set(CMAKE_AUTOMOC ON)
76
set(CMAKE_AUTORCC ON)
87

9-
if(FORCE_BUILD_QT5)
10-
find_package(Qt5 NAMES Qt5 REQUIRED COMPONENTS Core Widgets Xml)
11-
else()
12-
find_package(Qt6 NAMES Qt6 REQUIRED COMPONENTS Core Widgets Xml Core5Compat)
13-
endif()
14-
158
file(GLOB SOURCES *.h *.cpp *.qrc simplecpp/*.h simplecpp/*.cpp )
169
# Explicitly exclude qtscript_masterinclude.h
1710
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_LIST_DIR}/qtscript_masterinclude.h")

generator/parser/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ add_subdirectory(rpp)
44
set(CMAKE_AUTOMOC ON)
55
set(CMAKE_AUTORCC ON)
66

7-
if(FORCE_BUILD_QT5)
8-
find_package(Qt5 NAMES Qt5 REQUIRED COMPONENTS Core)
9-
else()
10-
find_package(Qt6 NAMES Qt6 REQUIRED COMPONENTS Core)
11-
endif()
12-
137
file(GLOB SOURCES *.h *.cpp)
148

159
add_library(${PROJECT_NAME} INTERFACE)

generator/parser/rpp/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ project(rpp LANGUAGES CXX)
33
set(CMAKE_AUTOMOC ON)
44
set(CMAKE_AUTORCC ON)
55

6-
if(FORCE_BUILD_QT5)
7-
find_package(Qt5 NAMES Qt5 REQUIRED COMPONENTS Core)
8-
else()
9-
find_package(Qt6 NAMES Qt6 REQUIRED COMPONENTS Core)
10-
endif()
11-
126
file(GLOB SOURCES *.h preprocessor.cpp)
137

148
add_library(${PROJECT_NAME} INTERFACE)

src/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ project(Core LANGUAGES CXX)
22

33
set(CMAKE_AUTOMOC ON)
44

5-
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets REQUIRED)
6-
find_package(Python3 COMPONENTS Development REQUIRED)
7-
85
file(GLOB SOURCES *.h *.cpp)
96

107
if(BUILD_SHARED_LIBS)

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ project(PythonQtTest LANGUAGES CXX)
22

33
set(CMAKE_AUTOMOC ON)
44

5-
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Test REQUIRED)
5+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets Test REQUIRED)
66

77
file(GLOB SOURCES *.h *.cpp)
88

0 commit comments

Comments
 (0)