-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
118 lines (90 loc) · 3.79 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.5)
project(kColorPicker LANGUAGES CXX VERSION 0.3.1)
set(QT_MIN_VERSION 5.15.2)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
option(BUILD_TESTS "Build Unit Tests" OFF)
option(BUILD_EXAMPLE "Build Example Application" ON)
option(BUILD_WITH_QT6 "Build with Qt6" OFF)
if(BUILD_WITH_QT6)
set(QT_MAJOR_VERSION 6)
else()
set(QT_MAJOR_VERSION 5)
endif()
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED Widgets)
include(GNUInstallDirs)
include(FeatureSummary)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(src)
if (BUILD_EXAMPLE)
add_subdirectory(example)
endif (BUILD_EXAMPLE)
if (BUILD_TESTS)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED Test)
enable_testing()
add_subdirectory(tests)
endif (BUILD_TESTS)
include(CMakePackageConfigHelpers)
add_library(kColorPicker
${KCOLORPICKER_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/include/kColorPicker/KColorPicker.h
${CMAKE_CURRENT_SOURCE_DIR}/icons/kColorPicker_icons.qrc
)
target_include_directories(kColorPicker
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/kColorPicker-Qt${QT_MAJOR_VERSION}>
)
target_link_libraries(kColorPicker PUBLIC Qt${QT_MAJOR_VERSION}::Widgets)
target_compile_definitions(kColorPicker PRIVATE KIMAGEANNOTATOR_LIB)
set_target_properties(kColorPicker
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin
VERSION ${PROJECT_VERSION}
SOVERSION 0
)
install(TARGETS kColorPicker
EXPORT kColorPicker-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/kColorPicker
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/kColorPicker-Qt${QT_MAJOR_VERSION}
)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/kColorPickerConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}
)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}Config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}Config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}
)
export(EXPORT kColorPicker-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}-targets.cmake
NAMESPACE kColorPicker::
)
install(EXPORT kColorPicker-targets
FILE kColorPicker-targets.cmake
NAMESPACE kColorPicker::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kColorPicker-Qt${QT_MAJOR_VERSION}
)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()