-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt.ded.apple
254 lines (208 loc) · 10.2 KB
/
CMakeLists.txt.ded.apple
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# This file specifies how the project should be built, using CMake.
# If you are unfamiliar with CMake, don't worry about all the details.
# The sections you might want to edit are marked as such, and
# the comments should hopefully make most of it clear.
#
# For many purposes, you may not need to change anything about this file.
cmake_minimum_required(VERSION 3.14)
# Set project name, version and laguages here. (change as needed)
# Version numbers are available by including "exampleConfig.h" in
# the source. See exampleConfig.h.in for some more details.
project(AwwTools VERSION 0.0.1 LANGUAGES CXX)
# Options: Things you can set via commandline options to cmake (e.g. -DENABLE_LTO=[ON|OFF])
option(ENABLE_WARNINGS_SETTINGS "Allow target_set_warnings to add flags and defines.
Set this to OFF if you want to provide your own warning parameters." ON)
option(ENABLE_LTO "Enable link time optimization" ON)
option(ENABLE_DOCTESTS "Include tests in the library. Setting this to OFF will remove all doctest related code.
Tests in tests/*.cpp will still be enabled." ON)
# Include stuff. No change needed.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
option(ALLOW_AWW_APP "Allow the aww app to be built" OFF)
include(ConfigSafeGuards)
include(Colors)
include(CTest)
include(Doctest)
include(LTO)
include(Misc)
include(Warnings)
# Check for LTO support.
find_lto(CXX)
# --------------------------------------------------------------------------------
# Locate files (change as needed).
# --------------------------------------------------------------------------------
set(SOURCES # All .cpp files in src/
src/aww-common.cpp
src/aww-app-manifest.cpp
src/aww-inspiration.cpp
src/aww-inernal-aww-tag.cpp
)
if(WIN32)
list(APPEND SOURCES src/aww-common-windows.cpp)
elseif(APPLE)
list(APPEND SOURCES src/aww-common-apple.cpp)
elseif(UNIX)
list(APPEND SOURCES src/aww-common-linux.cpp)
else()
list(APPEND SOURCES src/aww-common-unknown.cpp)
endif()
set(TESTFILES # All .cpp files in tests/
tests/aww.cpp
)
set(LIBRARY_NAME awwlib) # Default name for the library built from src/*.cpp (change if you wish)
## Third-party
# https://github.com/nlohmann/json
set(JSON_BuildTests OFF CACHE INTERNAL "")
# --------------------------------------------------------------------------------
# Build! (Change as needed)
# --------------------------------------------------------------------------------
# Compile all sources into a library.
add_library(${LIBRARY_NAME} OBJECT ${SOURCES})
# Lib needs its header files, and users of the library must also see these (PUBLIC). (No change needed)
target_include_directories(${LIBRARY_NAME} PUBLIC
${PROJECT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/third-party/clip-1.5
${CMAKE_CURRENT_SOURCE_DIR}/third-party/nlohmann-json-3.11.2/single_include
${CMAKE_CURRENT_SOURCE_DIR}/third-party/spdlog-1.11.0/include
${CMAKE_CURRENT_SOURCE_DIR}/third-party/fmt-9.1.0/include
)
if(ALLOW_AWW_APP)
# mark webview.h as system header to suppress clang warnings
target_include_directories(${LIBRARY_NAME} SYSTEM PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/third-party/webview-dbc7864/src
)
endif()
# we add the sub-directories that we want CMake to scan
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/clip-1.5)
if(ALLOW_AWW_APP)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/webview-dbc7864)
endif()
## nlohmann-json
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/nlohmann-json-3.11.2)
## end of nlohmann-json
## fmt
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/fmt-9.1.0)
## end of fmt
# There's also (probably) doctests within the library, so we need to see this as well.
target_link_libraries(
${LIBRARY_NAME} PUBLIC
doctest
clip
)
if(APPLE)
target_link_libraries(
${LIBRARY_NAME} PUBLIC
"-framework CoreFoundation"
)
endif()
if(ALLOW_AWW_APP)
target_link_libraries(
${LIBRARY_NAME} PUBLIC
webview
)
endif()
if(WIN32)
target_include_directories(${LIBRARY_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/third-party/wintoast-5e441fd/src
)
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/third-party/wintoast-5e441fd
)
target_link_libraries(${LIBRARY_NAME} PUBLIC wintoastlib)
endif()
target_link_libraries(${LIBRARY_NAME} PRIVATE nlohmann_json::nlohmann_json)
# Set the compile options you want (change as needed).
target_set_warnings(${LIBRARY_NAME} ENABLE ALL AS_ERROR ALL DISABLE Annoying)
# target_compile_options(${LIBRARY_NAME} ... ) # For setting manually.
# Add an executable for the file app/aww.cpp.
# If you add more executables, copy these lines accordingly.
add_executable(aww app/aww.cpp) # Name of exec. and location of file.
target_link_libraries(aww PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww optimized) # enable link-time-optimization if available for non-debug configurations
# Aww git open
add_executable(aww-git-open app/aww-git-open.cpp) # Name of exec. and location of file.
target_link_libraries(aww-git-open PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-git-open ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-git-open optimized) # enable link-time-optimization if available for non-debug configurations
## Aww date
add_executable(aww-date app/aww-date.cpp) # Name of exec. and location of file.
target_link_libraries(aww-date PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-date ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-date optimized) # enable link-time-optimization if available for non-debug configurations
## Aww run
add_executable(aww-run app/aww-run.cpp) # Name of exec. and location of file.
target_link_libraries(aww-run PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-run ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-run optimized) # enable link-time-optimization if available for non-debug configurations
## Aww toast
add_executable(aww-toast app/aww-toast.cpp) # Name of exec. and location of file.
target_link_libraries(aww-toast PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-toast ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-toast optimized) # enable link-time-optimization if available for non-debug configurations
## Aww term
add_executable(aww-term app/aww-term.cpp) # Name of exec. and location of file.
target_link_libraries(aww-term PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-term ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-term optimized) # enable link-time-optimization if available for non-debug configurations
## Aww open
add_executable(aww-open app/aww-open.cpp) # Name of exec. and location of file.
target_link_libraries(aww-open PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-open ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-open optimized) # enable link-time-optimization if available for non-debug configurations
## aww-create
add_executable(aww-create app/aww-create.cpp) # Name of exec. and location of file.
target_link_libraries(aww-create PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-create ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-create optimized) # enable link-time-optimization if available for non-debug configurations
## aww-guid
add_executable(aww-guid app/aww-guid.cpp) # Name of exec. and location of file.
target_link_libraries(aww-guid PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-guid ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-guid optimized) # enable link-time-optimization if available for non-debug configurations
## aww-tag
add_executable(aww-tag app/aww-tag.cpp) # Name of exec. and location of file.
target_link_libraries(aww-tag PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-tag ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-tag optimized) # enable link-time-optimization if available for non-debug configurations
if(ALLOW_AWW_APP)
## Aww app
add_executable(aww-app app/aww-app.cpp) # Name of exec. and location of file.
target_link_libraries(aww-app PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(aww-app ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(aww-app optimized) # enable link-time-optimization if available for non-debug configurations
endif()
# Set the properties you require, e.g. what C++ standard to use. Here applied to library and aww (change as needed).
set(PROJECTS
${LIBRARY_NAME}
aww
aww-git-open
aww-date
aww-run
aww-toast
aww-term
aww-open
aww-create
aww-guid
aww-tag
)
if(ALLOW_AWW_APP)
list(APPEND PROJECTS aww-app)
endif()
add_custom_target(copy-runtime-files ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/aww-create-aww
${CMAKE_BINARY_DIR}/bin/aww-create-aww
DEPENDS ${MY_TARGET})
set_target_properties(
${PROJECTS}
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin
)
# Set up tests (see tests/CMakeLists.txt).
add_subdirectory(tests)