Skip to content

Commit 3aa37ce

Browse files
author
Ahmad Samir
committed
Change the buildsystem to support building with Qt6
1 parent 15e1637 commit 3aa37ce

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ set(CMAKE_AUTORCC ON)
1313
option(BUILD_TESTS "Build Unit Tests" OFF)
1414
option(BUILD_EXAMPLE "Build Example Application" ON)
1515

16-
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Widgets)
16+
option(BUILD_WITH_QT6 "Build with Qt6" OFF)
17+
if(BUILD_WITH_QT6)
18+
set(QT_MAJOR_VERSION 6)
19+
set(CMAKE_CXX_STANDARD 17)
20+
else()
21+
set(QT_MAJOR_VERSION 5)
22+
endif()
23+
24+
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED Widgets)
1725

1826
include(GNUInstallDirs)
1927
include(FeatureSummary)
@@ -27,7 +35,7 @@ if (BUILD_EXAMPLE)
2735
endif (BUILD_EXAMPLE)
2836

2937
if (BUILD_TESTS)
30-
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Test)
38+
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED Test)
3139
enable_testing()
3240
add_subdirectory(tests)
3341
endif (BUILD_TESTS)
@@ -49,7 +57,7 @@ target_include_directories(kColorPicker
4957
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
5058
)
5159

52-
target_link_libraries(kColorPicker PUBLIC Qt5::Widgets)
60+
target_link_libraries(kColorPicker PUBLIC Qt${QT_MAJOR_VERSION}::Widgets)
5361

5462
target_compile_definitions(kColorPicker PRIVATE KIMAGEANNOTATOR_LIB)
5563

cmake/kColorPickerConfig.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ include(CMakeFindDependencyMacro)
22

33
@PACKAGE_INIT@
44

5-
find_dependency(Qt5 @QT_MIN_VERSION@ COMPONENTS Widgets)
5+
find_dependency(Qt@QT_MAJOR_VERSION@ @QT_MIN_VERSION@ COMPONENTS Widgets)
66

77
if(NOT TARGET kColorPicker::kColorPicker)
88
include("${CMAKE_CURRENT_LIST_DIR}/kColorPicker-targets.cmake")
9-
endif()
9+
endif()

tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ set(UNITTEST_SRC
44

55
add_library(KCOLORPICKER_STATIC STATIC ${KCOLORPICKER_SRCS})
66

7-
target_link_libraries(KCOLORPICKER_STATIC Qt5::Widgets kColorPicker)
7+
target_link_libraries(KCOLORPICKER_STATIC Qt${QT_MAJOR_VERSION}::Widgets kColorPicker)
88

99
foreach (UnitTest ${UNITTEST_SRC})
1010
get_filename_component(UnitTestName ${UnitTest} NAME_WE)
1111
add_executable(${UnitTestName} ${UnitTest})
12-
target_link_libraries(${UnitTestName} KCOLORPICKER_STATIC Qt5::Test)
12+
target_link_libraries(${UnitTestName} KCOLORPICKER_STATIC Qt${QT_MAJOR_VERSION}::Test)
1313
add_test(${UnitTestName} ${UnitTestName})
14-
endforeach (UnitTest)
14+
endforeach (UnitTest)

0 commit comments

Comments
 (0)