-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
148 lines (121 loc) · 4.63 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
cmake_minimum_required(VERSION 3.10)
project(kdalgorithms
LANGUAGES CXX
)
if(POLICY CMP0077) # Yes, let the parent project set BUILD_TESTING before we include CTest.cmake below
cmake_policy(SET CMP0077 NEW)
endif()
add_library(kdalgorithms INTERFACE)
add_library(KDAB::KDAlgorithms ALIAS kdalgorithms)
target_include_directories(kdalgorithms INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
if(MSVC)
target_compile_options(kdalgorithms INTERFACE /Zc:__cplusplus)
endif()
include(CTest)
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(MAIN_PROJECT ON)
endif()
option(KDALGORITHMS_BUILD_TEST "Build the kdalgorithms unit tests when BUILD_TESTING is enabled." ${MAIN_PROJECT})
if(BUILD_TESTING AND ${KDALGORITHMS_BUILD_TEST})
# This library support C++14 and above.
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
add_compile_options(-Wall)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-deprecated -Wextra -Woverloaded-virtual -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Werror=undef -Wpointer-arith -Wmissing-noreturn -Werror=return-type")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter")
endif()
if(MSVC) # Check if we are using the Visual Studio compiler
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") # Make __cplusplus match the actual C++ version used
endif()
# Needed for the unit tests
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED COMPONENTS Core Test)
set(CMAKE_AUTOMOC TRUE)
enable_testing()
add_executable(tst_kdalgorithms
src/kdalgorithms.h
src/kdalgorithms_bits/read_iterator_wrapper.h
src/kdalgorithms_bits/find_if.h
src/kdalgorithms_bits/filter.h
src/kdalgorithms_bits/generate.h
src/kdalgorithms_bits/insert_wrapper.h
src/kdalgorithms_bits/is_const_method.h
src/kdalgorithms_bits/is_detected.h
src/kdalgorithms_bits/method_tests.h
src/kdalgorithms_bits/operators.h
src/kdalgorithms_bits/reserve_helper.h
src/kdalgorithms_bits/return_type_trait.h
src/kdalgorithms_bits/shared.h
src/kdalgorithms_bits/to_function_object.h
src/kdalgorithms_bits/transform.h
src/kdalgorithms_bits/zip.h
src/kdalgorithms_bits/tuple_utils.h
src/kdalgorithms_bits/invoke.h
src/kdalgorithms_bits/cartesian_product.h
tests/tst_kdalgorithms.cpp
tests/tst_constraints.cpp
tests/copy_observer.h
tests/copy_observer.cpp
)
add_test(NAME tst_kdalgorithms COMMAND tst_kdalgorithms)
target_link_libraries(tst_kdalgorithms Qt${QT_VERSION_MAJOR}::Test)
add_executable(tst_return_type_traits tests/tst_return_type_traits.cpp)
# Make it show up in Qt Creator
add_custom_target(additional_files SOURCES
README.md
run
Documentation/algorithms.md
Documentation/deploying.md
Documentation/inspiration.md
Documentation/ChangeLog.md
)
add_subdirectory(Inspiration)
endif()
install(TARGETS kdalgorithms EXPORT KDAlgorithmsTargets)
install(EXPORT KDAlgorithmsTargets
FILE KDAlgorithmsTargets.cmake
NAMESPACE KDAB::
DESTINATION lib/cmake/KDAlgorithms
)
install(FILES
src/kdalgorithms.h
DESTINATION include/kdalgorithms
)
install(FILES
src/kdalgorithms_bits/read_iterator_wrapper.h
src/kdalgorithms_bits/find_if.h
src/kdalgorithms_bits/filter.h
src/kdalgorithms_bits/generate.h
src/kdalgorithms_bits/insert_wrapper.h
src/kdalgorithms_bits/is_const_method.h
src/kdalgorithms_bits/is_detected.h
src/kdalgorithms_bits/method_tests.h
src/kdalgorithms_bits/operators.h
src/kdalgorithms_bits/reserve_helper.h
src/kdalgorithms_bits/return_type_trait.h
src/kdalgorithms_bits/shared.h
src/kdalgorithms_bits/to_function_object.h
src/kdalgorithms_bits/transform.h
src/kdalgorithms_bits/zip.h
src/kdalgorithms_bits/tuple_utils.h
src/kdalgorithms_bits/invoke.h
src/kdalgorithms_bits/cartesian_product.h
DESTINATION include/kdalgorithms/kdalgorithms_bits
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
KDAlgorithmsConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/KDAlgorithmsConfig.cmake
INSTALL_DESTINATION lib/cmake/KDAlgorithms
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/KDAlgorithmsConfig.cmake
DESTINATION lib/cmake/KDAlgorithms
)