-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotes.txt
417 lines (291 loc) · 12.1 KB
/
Notes.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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
pacman -S mingw64/mingw-w64-x86_64-lld
wish: auto call ext target upon any change
wish: solve wish skip external configure
wish: cmake LIBV_SYSTEM_HEADERS: include directories that are libv specific should be marked with SYSTEM
place.it:
New C++ Defines for executables:
WISH_BUILD_PACKAGE
WISH_ENABLE_RESOURCE_MAPPING
WISH_PATH_TO_CURRENT_SOURCE
WISH_PATH_TO_SOURCE
New build type "package"
only use for package_* targets to create the packages
sets up the change_current_path
sets up the resource mapping
document wish_resource_mapping
example wish_resource_mapping
runtime stuffy
folder change from binary to source
when to active the resource mapping macro
# ? ! error if resource file is missing at configure time
cmake -B build/dev .
cmake -B build/dev . \
-DWISH_BUILD_VERSION_MAJOR="0" \
-DWISH_BUILD_VERSION_MINOR="0" \
-DWISH_BUILD_VERSION_PATCH="0" \
-DWISH_BUILD_VERSION_NAME="version-name" \
-DWISH_BUILD_VARIANT="development" \
-DWISH_BUILD_NUMBER="0" \
-DWISH_BUILD_DATETIME="2000-01-01T00:00:00Z" \
-DWISH_BUILD_UUID="00000000-0000-0000-0000-000000000000"
cmake --build build/dev --target sandbox_versions
cmake --build build/dev --target package_sandbox_versions
cmake --install build/dev --prefix . --component sandbox_versions
# -------------------------------------------------------------------------------------------------
Packaging / Resource
Packaging and Resource mapping is two separate concepts
and there might be a third Resource "import/preprocess"
Resource mapping (Always happens):
- Defining resource files and their
build (aka dev) location and
runtime location
- Injecting these mapping into to source both at
build (aka dev) time and
runtime time
Packaging (Only happens during packaging)
Grabbing resource files and placing them into a folder
From the code always use the desired locations and rely on mapping
Mapping in release runtime is a noop
Release runtime ?!= ?== Release build type
Resource "import/preprocess"
Alternative approach:
runtime map, special flag to export, use exported map to package
actual packaging:
CPACK https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html
# =================================================================================================
include ext targets via cmake when they have support for it
TODO P3: wish: add support for skipping library build/links via directly amending the sources of a dependency (only for DEV build)
TODO P3: wish: Implement a single file or line bootstrap (FetchContent)
TODO P4: wish: Use a shared ext folder (set via an option, default to project/ext) (external folders must be unique based on every used external argument)
TODO P4: wish: Last chance for conan (wish is created even if conan can be used)
TODO P4: wish: inheritance for wish_create_executable and create_library
TODO P5: wish: flag or build options to turn on/off sanitizes
TODO P5: wish: Recommend or easily produce somehow the configure flags:
-G"Ninja" -DCMAKE_BUILD_TYPE=DEV -DSKIP_EXTERNAL_CONFIGURES=TRUE -DFORCE_COLORED_OUTPUT=TRUE
color diag is solved with CMake 3.24
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6990?utm_source=product&utm_medium=link&utm_campaign=CL&utm_content=2022.2
read into it and remove the relavant wish features
TODO: Error message for: Requested Wish version is not a valid version identifier, please check github/releases or tags for more info
file(DOWNLOAD <my-url> ${CMAKE_CURRENT_BINARY_DIR}/<filename>
STATUS DOWNLOAD_STATUS
)
# Separate the returned status code, and error message.
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
# Check if download was successful.
if(${STATUS_CODE} EQUAL 0)
message(STATUS "Wish: Download completed successfully!")
else()
# Exit CMake if the download failed, printing the error message.
message(FATAL_ERROR "Error occurred during download: ${ERROR_MESSAGE}")
endif()
--- Install ---
include(GNUInstallDirs)
install(TARGETS Example) # Since 3.14 defaults are fine
set(CMAKE_INSTALL_RPATH $ORIGIN)
install(TARGETS Example
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${project_name}_Runtime
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${project_name}_Runtime
NAMELINK_COMPONENT Development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${project_name}_Development
)
--- Articles ------------------------------------------------------------------------------------
CppNow 2022: CMake 2022 C++ Modules and More - Bill Hoffman: https://www.youtube.com/watch?v=hkefPcWySzI
CppNow 2021: CMake: One Tool To Build Them All - Bill Hoffman: https://www.youtube.com/watch?v=wULu83jQmIQ
CppCon 2019: Deep CMake for Library Authors - Craig Scott https://www.youtube.com/watch?v=m0DwB4OvDXk
C++Now 2017: Effective CMake - Daniel Pfeifer: https://www.youtube.com/watch?v=bsXLMQ6WgIk
--- Ideas ---------------------------------------------------------------------------------------
Additional cmake.wish ideas:
wish_config(
TARGET __PARENT_TARGET_____TARGET__
FOLDER __PARENT_FOLDER__/__TARGET__
ALIAS __PARENT_ALIAS__::__TARGET__
SOURCE src/__FOLDER__/*.cpp
HEADER src/__FOLDER__/*.hpp
RESULT_PATH_BINARY_APP bin/__FOLDER__/
RESULT_PATH_BINARY_EXAMPLE bin/__FOLDER__/
RESULT_PATH_BINARY_SANDBOX bin/__FOLDER__/
RESULT_PATH_BINARY_TEST bin/__FOLDER__/
RESULT_PATH_HEADER include/__FOLDER__/
RESULT_PATH_LIBRARY_DYNAMIC lib/__FOLDER__/
RESULT_PATH_LIBRARY_STATIC lib/__FOLDER__/
)
string(LENGTH ${CMAKE_SOURCE_DIR}_ WISH_SHORT_PATH_CUTOFF)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
wish_create_base(
TARGET libv
WARNING GNU VERSION_GREATER 7.0 -Wduplicated-branches
WARNING GNU VERSION_GREATER 7.0 -Wrestrict
WARNING GNU VERSION_GREATER 7.0 -Wshadow-compatible-local
WARNING GNU VERSION_GREATER 8.0 -Wcast-align=strict
WARNING GNU VERSION_GREATER 8.0 -Wmultistatement-macros
OPTION DEBUG -Og
OPTION DEBUG -ggdb3
OPTION RELEASE -O3
OPTION RELEASE -static
OPTION DEV -O3
OPTION -m64
OPTION -std=c++2a
OPTION -fconcepts
DEFINE -Dconcept="concept bool"
DEFINE -D "WISH_REQUIRES\\(...\\)=\"requires __VA_ARGS__\""
IDE_DEFINE WISH_REQUIRES(...)
DEFINE -DWISH_GIT_BRANCH="${WISH_GIT_BRANCH}"
DEFINE -DWISH_GIT_COMMIT_HASH="${WISH_GIT_COMMIT_HASH}"
DEFINE -DWISH_SHORT_PATH_CUTOFF=${WISH_SHORT_PATH_CUTOFF}
DEFINE -DWISH_SHORT_PATH_PREFIX="${CMAKE_SOURCE_DIR}/"
)
wish_create_library(
PARENT libv
TARGET vm4imp
LINK PUBLIC libv::log libv::vm4 ext::assimp
)
// -------------------------------------------------------------------------------------------------
Additional cmake.wish ideas 2:
wish_config(
TARGET __PARENT_TARGET_____TARGET__
FOLDER __PARENT_FOLDER__/__TARGET__
ALIAS __PARENT_ALIAS__::__TARGET__
SOURCE src/__FOLDER__/*.cpp
HEADER src/__FOLDER__/*.hpp
RESULT_PATH_BINARY_APP bin/__FOLDER__/
RESULT_PATH_BINARY_EXAMPLE bin/__FOLDER__/
RESULT_PATH_BINARY_SANDBOX bin/__FOLDER__/
RESULT_PATH_BINARY_TEST bin/__FOLDER__/
RESULT_PATH_HEADER include/__FOLDER__/
RESULT_PATH_LIBRARY_DYNAMIC lib/__FOLDER__/
RESULT_PATH_LIBRARY_STATIC lib/__FOLDER__/
)
string(LENGTH ${CMAKE_SOURCE_DIR}_ WISH_SHORT_PATH_CUTOFF)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
wish_create_base(
TARGET libv
WARNING GNU VERSION_GREATER 7.0 -Wduplicated-branches
WARNING GNU VERSION_GREATER 7.0 -Wrestrict
WARNING GNU VERSION_GREATER 7.0 -Wshadow-compatible-local
WARNING GNU VERSION_GREATER 8.0 -Wcast-align=strict
WARNING GNU VERSION_GREATER 8.0 -Wmultistatement-macros
MODE DEBUG
OPTION -Og
OPTION -ggdb3
MODE RELEASE
OPTION -O3
OPTION -static
MODE DEV
OPTION -O3
OPTION -m64
OPTION -std=c++2a
OPTION -fconcepts
DEFINE -Dconcept="concept bool"
DEFINE -D "WISH_REQUIRES\\(...\\)=\"requires __VA_ARGS__\""
IDE_DEFINE WISH_REQUIRES(...)
DEFINE -DWISH_GIT_BRANCH="${WISH_GIT_BRANCH}"
DEFINE -DWISH_GIT_COMMIT_HASH="${WISH_GIT_COMMIT_HASH}"
DEFINE -DWISH_SHORT_PATH_CUTOFF=${WISH_SHORT_PATH_CUTOFF}
DEFINE -DWISH_SHORT_PATH_PREFIX="${CMAKE_SOURCE_DIR}/"
)
wish_create_library(
PARENT libv
TARGET vm4imp
LINK PUBLIC libv::log libv::vm4 ext::assimp
)
// --- LUA Ideas -----------------------------------------------------------------------------------
Additional lua.wish ideas:
debug = mode("debug")
release = mode("release")
dev = mode("dev")
config.target = "{PARENT_TARGET}_{TARGET}"
config.folder = "{PARENT_FOLDER}/{TARGET}"
config.alias = "{PARENT_ALIAS}::{TARGET}"
config.source = "src/{FOLDER}/**.cpp"
config.header = "src/{FOLDER}/**.hpp"
config.result_path_binary_app = "bin/{FOLDER}/"
config.result_path_binary_example = "bin/{FOLDER}/"
config.result_path_binary_sandbox = "bin/{FOLDER}/"
config.result_path_binary_test = "bin/{FOLDER}/"
config.result_path_header = "include/{FOLDER}/"
config.result_path_library_dynamic = "lib/{FOLDER}/"
config.result_path_library_static = "lib/{FOLDER}/"
set.CMAKE_THREAD_PREFER_PTHREAD = "TRUE"
set.THREADS_PREFER_PTHREAD_FLAG = "TRUE"
find.package_require("Threads")
find.package_require("OpenGL")
ext_assimp = create_external("assimp", "https://github.com/assimp/assimp.git", "v5.0.0", {
BUILD_SHARED_LIBS = OFF,
CMAKE_EXPORT_COMPILE_COMMANDS = ON,
ASSIMP_BUILD_ASSIMP_TOOLS = OFF,
ASSIMP_BUILD_TESTS = OFF,
ASSIMP_BUILD_ZLIB = ON,
ASSIMP_NO_EXPORT = ON,
ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT = OFF,
ASSIMP_BUILD_FBX_IMPORTER = ON,
})
ext_assimp.link_public("assimp", "IrrXML", "zlibstatic")
libv = create_base("libv")
libv.warning("GNU VERSION_GREATER 7.0", "-Wduplicated-branches")
libv.warning("GNU VERSION_GREATER 7.0", "-Wrestrict")
libv.warning("GNU VERSION_GREATER 7.0", "-Wshadow-compatible-local")
libv.warning("GNU VERSION_GREATER 8.0", "-Wcast-align=strict")
libv.warning("GNU VERSION_GREATER 8.0", "-Wmultistatement-macros")
libv.option(debug, "-Og")
libv.option(debug, "--ggdb3")
libv.option(release, "-O3")
libv.option(release, "-static")
libv.option(dev, "-O3")
libv.option("-m64")
libv.option("-std=c++2a")
libv.option("-fconcepts")
libv.define("concept=\"concept bool\"")
libv.define("\"WISH_REQUIRES\\\\(...\\\\)=\\\"requires __VA_ARGS__\\\"\"")
libv.ide_define("WISH_REQUIRES(...)")
libv.define_wish_git_branch()
libv.define_wish_git_commit()
libv.define_wish_short_path_cutoff()
libv.define_wish_short_path_prefix()
libv_vm4imp = create_library(libv, "vm4imp");
libv_vm4imp.link_public(libv_log libv_vm4 ext_assimp);
// -------------------------------------------------------------------------------------------------
Additional lua.wish ideas 2:
debug = mode("debug")
release = mode("release")
dev = mode("dev")
set.CMAKE_THREAD_PREFER_PTHREAD = "TRUE"
set.THREADS_PREFER_PTHREAD_FLAG = "TRUE"
find.package_require("Threads")
find.package_require("OpenGL")
ext_assimp = create_external("assimp", "https://github.com/assimp/assimp.git", "v5.0.0", {
BUILD_SHARED_LIBS = OFF,
CMAKE_EXPORT_COMPILE_COMMANDS = ON,
ASSIMP_BUILD_ASSIMP_TOOLS = OFF,
ASSIMP_BUILD_TESTS = OFF,
ASSIMP_BUILD_ZLIB = ON,
ASSIMP_NO_EXPORT = ON,
ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT = OFF,
ASSIMP_BUILD_FBX_IMPORTER = ON,
})
ext_assimp.link_public("assimp", "IrrXML", "zlibstatic")
libv = create_base("libv")
libv.warning_all()
libv.option(debug, "-Og")
libv.option(debug, "--ggdb3")
libv.option(release, "-O3")
libv.option(release, "-static")
libv.option(dev, "-O3")
libv.option("-m64")
libv.option("-std=c++2a")
libv.option("-fconcepts")
libv.define("concept=\"concept bool\"")
libv.define("\"WISH_REQUIRES\\\\(...\\\\)=\\\"requires __VA_ARGS__\\\"\"")
libv.ide_define("WISH_REQUIRES(...)")
libv.define_wish_git_branch()
libv.define_wish_git_commit()
libv.define_wish_short_path_cutoff()
libv.define_wish_short_path_prefix()
libv_vm4imp = create_library(libv, "vm4imp");
libv_vm4imp.link_public(libv_log libv_vm4 ext_assimp);