forked from hikogui/hikogui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
573 lines (465 loc) · 23.8 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
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# Copyright Jens A. Koch 2021-2022.
# Copyright Take Vos 2019-2022.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.25)
#-------------------------------------------------------------------
# Configure early CMAKE paths
#-------------------------------------------------------------------
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
include(SetupVcpkg)
include(SetupCompiler)
#-------------------------------------------------------------------
# Build Options
#-------------------------------------------------------------------
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(HI_ENABLE_ANALYSIS "Compile using -analyze" OFF)
option(HI_ENABLE_ASAN "Compile using address sanitizer" OFF)
option(HI_ENABLE_PCH "Compile with precompiled headers" ON)
option(HI_ARCHITECTURE "The architecture to build the hikogui library with" "")
#-------------------------------------------------------------------
# Project
#-------------------------------------------------------------------
if(APPLE)
set(LANGUAGES CXX OBJCXX)
else()
set(LANGUAGES CXX)
endif()
# vcpkg.json is the primary source for version data
file(READ ${CMAKE_SOURCE_DIR}/vcpkg.json VCPKG_JSON_STRING)
string(JSON HI_LIB_NAME GET ${VCPKG_JSON_STRING} "name")
string(JSON HI_LIB_VERSION GET ${VCPKG_JSON_STRING} "version")
string(JSON HI_LIB_LICENSE GET ${VCPKG_JSON_STRING} "license")
string(JSON HI_LIB_DESC GET ${VCPKG_JSON_STRING} "description")
string(JSON HI_LIB_HOMEPAGE GET ${VCPKG_JSON_STRING} "homepage")
configure_file("package.json.in" "package.json" @ONLY)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/package.json PACKAGE_JSON_STRING)
string(JSON HI_LIB_DISPLAY_NAME GET ${PACKAGE_JSON_STRING} "display-name")
string(JSON HI_LIB_VENDOR GET ${PACKAGE_JSON_STRING} "vendor")
project(${HI_LIB_NAME} VERSION ${HI_LIB_VERSION} LANGUAGES ${LANGUAGES})
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 0)
set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE 0)
set(CMAKE_CXX_SCAN_FOR_MODULES 0)
#-------------------------------------------------------------------
# Setup CMake Includes
#-------------------------------------------------------------------
include(AddShader)
include(ShowBuildTargetProperties)
include(FetchContent)
include(CPUID)
# disable adding CTest build targets like "NightlyStart" (before ctest include)
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
include(CTest)
#-------------------------------------------------------------------
# Find Dependencies
#-------------------------------------------------------------------
if(BUILD_TESTING)
#
# GoogleTest - non-vcpkg, directly build from externals
#
set(INSTALL_GTEST OFF CACHE INTERNAL "Don't install gtest")
set(BUILD_GMOCK OFF CACHE INTERNAL "Don't build gmock")
FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.13.0)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(gtest PROPERTIES FOLDER extern)
set_target_properties(gtest_main PROPERTIES FOLDER extern)
endif()
#
# Vulkan SDK Headers
#
if(NOT DEFINED ENV{VULKAN_SDK})
message(FATAL_ERROR
"Please set the VULKAN_SDK environment variable to the directory in which the SDK is installed.\n"
"It looks like C:\\VulkanSDK\\1.0.0.0, but with the version number being the version that was installed.\n"
"set VULKAN_SDK=\"C:\\VulkanSDK\\1.0.0.0\"\n")
endif()
find_package(Vulkan REQUIRED)
#
# Vulkan Memory Allocator - installed as part of Vulkan SDK headers
#
if(NOT EXISTS "${Vulkan_INCLUDE_DIRS}/vma")
message(FATAL_ERROR "Please make sure to include VMA (Vulkan Memory Allocator) with the installation of VulkanSDK.\n")
endif()
#-------------------------------------------------------------------
# Setup Build Targets
#-------------------------------------------------------------------
add_library(hikogui)
set(HIKOGUI_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/hikogui")
include(CMakeLists_includes.cmake)
include(CMakeLists_implementations.cmake)
if(HI_ENABLE_PCH)
include(CMakeLists_pch.cmake)
endif()
set_target_properties(hikogui PROPERTIES DEBUG_POSTFIX "d")
#-------------------------------------------------------------------
# Setup Sources
#-------------------------------------------------------------------
# This needs to be below the build target commands (add_*).
# We omit adding source files to the `add_*` commands, but add them
# later using target_sources() in CMakeLists of subdirectories.
add_subdirectory(src/hikogui)
#-------------------------------------------------------------------
# Build Target: hikogui (library)
#-------------------------------------------------------------------
target_compile_features(hikogui PUBLIC cxx_std_20)
set_target_properties(hikogui PROPERTIES VERSION ${HIKOGUI_PROJECT_VERSION_SHORT} SOVERSION ${HIKOGUI_MAJOR_VERSION})
set_target_properties(hikogui PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(APPLE)
target_link_libraries(hikogui PUBLIC "-framework Foundation -framework AppKit")
endif()
if(WIN32)
target_link_libraries(hikogui PUBLIC "ws2_32")
target_link_libraries(hikogui PUBLIC "DXGI")
target_link_libraries(hikogui PUBLIC "bcrypt")
target_link_libraries(hikogui PUBLIC "winmm")
target_link_libraries(hikogui PUBLIC "dwmapi")
endif()
# Add the Vulkan libraries.
target_link_libraries(hikogui PUBLIC ${Vulkan_LIBRARIES})
target_include_directories(hikogui PUBLIC ${Vulkan_INCLUDE_DIRS})
if (WIN32)
# Add vulkan win32 surface support.
target_compile_definitions(hikogui PUBLIC -DVK_USE_PLATFORM_WIN32_KHR)
# vulkan.h will include the windows headers, so we must define all sorts of stuff on the command line.
target_compile_definitions(hikogui PUBLIC -DUNICODE)
target_compile_definitions(hikogui PUBLIC -D_UNICODE)
target_compile_definitions(hikogui PUBLIC -D_CRT_SECURE_NO_WARNINGS)
target_compile_definitions(hikogui PUBLIC -DNOMINMAX)
target_compile_definitions(hikogui PUBLIC -DWIN32_LEAN_AND_MEAN)
target_compile_definitions(hikogui PUBLIC -DWIN32_NO_STATUS)
# Minimum Windows 10.
target_compile_definitions(hikogui PUBLIC -DWINVER=0x0a00)
target_compile_definitions(hikogui PUBLIC -D_WIN32_WINNT=0x0a00)
elseif (APPLE)
# Add vulkan apple's Metal surface support.
target_compile_definitions(hikogui PUBLIC -DVK_USE_PLATFORM_METAL_EXT)
endif()
target_include_directories(hikogui PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:include>"
)
target_include_directories(hikogui PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(hikogui PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
#
# We will support the following CPUs:
# * Intel Ivy Bridge from 2012, still used by Mac Pro sold in 2019.
# * AMD Steamroller from 2014
#
if (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
# Set the execution character encoding to UTF-8
if (MSVC)
target_compile_options(hikogui PUBLIC -utf-8)
else()
target_compile_options(hikogui PUBLIC -fexec-charset=UTF-8)
endif()
# Clang will complain about __builtin_assume even on constexpr functions and operators,
# this warning is absolutely useless.
target_compile_options(hikogui PUBLIC -Wno-assume)
# Clang will complain about calling hidden-friend-template-functions.
target_compile_options(hikogui PUBLIC -Wno-unknown-warning-option -Wno-c++20-extensions -Wno-c++2a-extensions)
# vk_mem_alloc.h seems to turn on nullability completeness checks on clang.
# It seems this check should only be used for interopability with swift
target_compile_options(hikogui PUBLIC -Wno-nullability-completeness)
target_compile_options(hikogui PUBLIC -march=${HI_ARCHITECTURE})
# The Microsoft version of clang does not implement all clang command line arguments.
if (NOT MSVC)
# The hikogui generic tokenizer uses large constexpr tables.
target_compile_options(hikogui PUBLIC -fconstexpr-steps=100000000)
# Tune according to a more modern CPU.
target_compile_options(hikogui PUBLIC -mtune=skylake)
endif()
elseif (MSVC)
if("${HI_ARCHITECTURE}" STREQUAL "x86-64-v4")
target_compile_options(hikogui PUBLIC -arch:AVX512)
elseif("${HI_ARCHITECTURE}" STREQUAL "x86-64-v3")
target_compile_options(hikogui PUBLIC -arch:AVX2)
elseif("${HI_ARCHITECTURE}" STREQUAL "x86-64-v2")
target_compile_options(hikogui PUBLIC -arch:AVX)
endif()
# Turn on a lot of warnings by default.
target_compile_options(hikogui PUBLIC -W4)
# Set the compiler to C++20 standard conforming as much as possible.
target_compile_options(hikogui PUBLIC -permissive-)
# suppress msbuild startup banner
target_compile_options(hikogui PUBLIC -nologo)
# By default MSVC reports a incorrect version in __cplusplus
# This option will make it work correctly.
target_compile_options(hikogui PUBLIC -Zc:__cplusplus)
# Use the C++20 compliant preprocessor, which include __VA_OPT__()
# This causes warning "C5105: macro expansion producing 'defined' has undefined behavior" in winbase.h
# which is supposed to be fixed in a newer version of the SDK.
target_compile_options(hikogui PUBLIC -Zc:preprocessor)
target_compile_options(hikogui PUBLIC -wd5105)
# Set the execution and source character encoding to UTF-8
target_compile_options(hikogui PUBLIC -utf-8)
# The hikogui generic tokenizer uses large constexpr tables.
target_compile_options(hikogui PUBLIC "-constexpr:steps100000000")
# C4068: unknown pragma.
# Ignore unknown pragmas, needed for other compilers.
target_compile_options(hikogui PUBLIC -wd4068)
# C4324: structure was padded due to alignment specifier.
# Of course it is, that is what the alignment specifier is used for??????
target_compile_options(hikogui PUBLIC -wd4324)
# C4100: unreferenced formal parameter.
# This warning is in the way when you want to document a parameter of a virtual function
# with an implementation that does not use the parameter.
target_compile_options(hikogui PUBLIC -wd4100)
# C4127: conditional expression is constant.
# False positive with expressions that include template parameters.
target_compile_options(hikogui PUBLIC -wd4127)
# C6326: Potential comparison of a constant with another constant.
# False positive in constexpr context.
target_compile_options(hikogui PUBLIC -wd6326)
# C6239: (<non-zero constant> && <expression>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?"
# False positive when using logical operators in constexpr context.
target_compile_options(hikogui PUBLIC -wd6239)
# C6262: Function uses 'x' bytes of stack: exceeds /analyze:stacksize 'x'. Consider moving some data to heap.
# False positives when returning data from a function in constexpr context.
target_compile_options(hikogui PUBLIC -wd6262)
# C4505: unreferenced local function has been removed.
# False positive when calling a local function from within a "if constexpr" block.
target_compile_options(hikogui PUBLIC -wd4505)
# C4648: standard attribute 'no_unique_address' is ignored
target_compile_options(hikogui PUBLIC -wd4648)
# C4744: 'x' has different type in 'foo_impl.cpp' and 'bar_impl.cpp':
# 'struct (8 bytes)' and '__declspec(align(8)) struct (8 bytes)' [foobar.vcxproj]
# Bug in linker where atomic variables defined in a header file and used in two _impl.cpp files be
# interpreted as different types. Microsoft knows about the bug for many years.
target_link_options(hikogui PUBLIC "/ignore:4744")
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
# Enable Security Development Lifecycle checks.
# This includes run-time checks, don't include this in the Release type
# Do include it with ReleaseWithDebug.
# -sdl forces deprecated warnings as errors so also not useful during development.
#target_compile_options(hikogui PUBLIC -sdl)
# Just my code enables the VS debugger to step over system, framework, library, and other non-user calls.
target_compile_options(hikogui PUBLIC -JMC)
# The debugger can't watch variables that are part of NRVO (named return value optimization) even in debugging.
target_compile_options(hikogui PUBLIC -Zc:nrvo-)
endif()
if(HI_ENABLE_ASAN)
target_compile_options(hikogui PUBLIC -fsanitize=address)
endif()
if(HI_ENABLE_ANALYSIS)
target_compile_options(hikogui PUBLIC -analyze)
#target_compile_options(hikogui PUBLIC -analyze:ruleset ${CMAKE_CURRENT_SOURCE_DIR}/AllRules.ruleset)
# The Core Guidelines checker, not so useful for real programs.
message(NOTICE "The following environment variables need to be set for the core guidelines checker to work:")
message(NOTICE " esp.extensions=cppcorecheck.dll")
message(NOTICE " esp.annotationbuildlevel=ignore")
message(NOTICE " CAExcludePath=C:\\VulkanSDK;C:\\Program Files;C:\\Users\\Tjienta\\Projects\\hikogui\\out\\build\\vc17-x64-windows-static-ana\\_deps")
message(NOTICE "")
target_compile_options(hikogui PUBLIC -analyze:plugin EspXEngine.dll)
# C26440: Function '...' can be declared 'noexcept' (f.6).
# It requires lambda function to also be declared 'noexcept' that makes the code messy.
target_compile_options(hikogui PUBLIC -wd26440)
# C26446: Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4).
# This rule makes applications slow.
target_compile_options(hikogui PUBLIC -wd26446)
# C26447: The function is declared 'noexcept' but calls function '...' which may throw exceptions (f.6).
# Since c++20 std::terminate will be called on throw.
target_compile_options(hikogui PUBLIC -wd26447)
# C26481: Don't use pointer arithmetic. Use span instead (bounds.1).
# False positive everywhere std::format() is used.
target_compile_options(hikogui PUBLIC -wd26481)
# C26482: Only index into arrays using constant expressions (bounds.2).
# This rule makes it so you can not use a variable to index into an array.
target_compile_options(hikogui PUBLIC -wd26482)
# C26821: For '...', consider using gsl::span instead of std::span to guarantee runtime bounds safety (gsl.view).
# This rule makes applications slow.
target_compile_options(hikogui PUBLIC -wd26821)
# C28020: The expression '0<=_Param_(1)&&_Param_(1)<=256-1' is not true at this call.
# False positives in base_n, where the index is static_cast<uint8_t>().
# The bug (since 2020) in the compiler seem to have been triggered in unrelated code.
# https://developercommunity.visualstudio.com/t/c28020-false-positives/923103
target_compile_options(hikogui PUBLIC -wd28020)
# C26465: Don't use const_cat to cast away const or volatile, const_cast is not required constness... (type.3)
# False positive on string literal,
# bug reported: https://developercommunity.visualstudio.com/t/C26465-false-positive-on-string-literal/10263615
target_compile_options(hikogui PUBLIC -wd26465)
# C26409: Avoid calling new and delete explicitly, use std::make_unique<T> instead (r.11)
# Can't exclude unit-test and google-test uses new and delete in the TEST() macro.
target_compile_options(hikogui PUBLIC -wd26409)
# C26426: Global initializer calls a non-constexpr function (i.22)
# Can't exclude unit-test and google-test does this a lot.
target_compile_options(hikogui PUBLIC -wd26426)
# C26455: Default constructor should not throw. Declare it 'noexcept' (f.6)
# Can't exclude unit-test and google-test uses throwing default constructors in the TEST() macro.
target_compile_options(hikogui PUBLIC -wd26455)
# Turn off every warning fix one at a time:
#target_compile_options(hikogui PUBLIC -wd26472)
#target_compile_options(hikogui PUBLIC -wd26473)
#target_compile_options(hikogui PUBLIC -wd26474)
target_compile_options(hikogui PUBLIC -wd26475)
target_compile_options(hikogui PUBLIC -wd26476)
target_compile_options(hikogui PUBLIC -wd26478)
target_compile_options(hikogui PUBLIC -wd26485)
target_compile_options(hikogui PUBLIC -wd26490)
target_compile_options(hikogui PUBLIC -wd26491)
target_compile_options(hikogui PUBLIC -wd26492)
target_compile_options(hikogui PUBLIC -wd26493)
target_compile_options(hikogui PUBLIC -wd26494)
target_compile_options(hikogui PUBLIC -wd26495)
target_compile_options(hikogui PUBLIC -wd26496)
target_compile_options(hikogui PUBLIC -wd26497)
target_compile_options(hikogui PUBLIC -wd26498)
target_compile_options(hikogui PUBLIC -wd26800)
target_compile_options(hikogui PUBLIC -wd26813)
target_compile_options(hikogui PUBLIC -wd26814)
target_compile_options(hikogui PUBLIC -wd26817)
target_compile_options(hikogui PUBLIC -wd26818)
target_compile_options(hikogui PUBLIC -wd26820)
target_compile_options(hikogui PUBLIC -wd26830)
target_compile_options(hikogui PUBLIC -wd26432)
target_compile_options(hikogui PUBLIC -wd26451)
endif()
endif()
#-------------------------------------------------------------------
# Copy resources needed by executables
#-------------------------------------------------------------------
add_custom_target(hikogui_shaders)
add_shader_target(hikogui_shaders
shaders/utils.glsl
shaders/pipeline_image.vert
shaders/pipeline_image.frag
shaders/pipeline_box.vert
shaders/pipeline_box.frag
shaders/pipeline_SDF.vert
shaders/pipeline_SDF.frag
shaders/pipeline_alpha.vert
shaders/pipeline_alpha.frag
shaders/pipeline_tone_mapper.vert
shaders/pipeline_tone_mapper.frag
)
set(hikogui_resource_files
resources/themes/hikogui_dark.theme.json
resources/themes/hikogui_light.theme.json
resources/fonts/elusiveicons-webfont.ttf
resources/fonts/hikogui_icons.ttf
resources/win32.keybinds.json
)
add_custom_target(hikogui_resources
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/resources ${CMAKE_CURRENT_BINARY_DIR}/resources
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/shaders ${CMAKE_CURRENT_BINARY_DIR}/resources/shaders
DEPENDS ${hikogui_resource_files} hikogui_shaders)
add_dependencies(hikogui hikogui_resources)
#-------------------------------------------------------------------
# Installation Rules: hikogui (library)
#-------------------------------------------------------------------
include(GNUInstallDirs)
install(TARGETS hikogui RESOURCE)
# Copy all header files for the library.
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/
# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
# FILES_MATCHING PATTERN "*.hpp")
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/
# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
# FILES_MATCHING PATTERN "*.h")
# Copy all resource files needing to be added to the resource directory of an application
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/resources/
DESTINATION share/hikogui/resources)
# On Windows, the dynamic libs go in the same dir as the executable and static libs go into "lib".
get_target_property(target_type hikogui TYPE)
if(WIN32 AND target_type STREQUAL DYNAMIC_LIBRARY)
# Install the library and headers.
install(TARGETS hikogui EXPORT hikogui
FILE_SET hikogui_include_files DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} # <- .dll next to exe
)
else()
# Install the library and headers.
install(TARGETS hikogui EXPORT hikogui
FILE_SET hikogui_include_files DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # <- .lib
)
endif()
install(
EXPORT hikogui
DESTINATION share/hikogui
NAMESPACE hikogui::
FILE "hikoguiTargets.cmake"
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/hikoguiConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/hikoguiConfig.cmake"
INSTALL_DESTINATION lib/cmake/hikogui
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/hikoguiConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/hikoguiConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/hikoguiConfigVersion.cmake"
DESTINATION share/hikogui
)
#-------------------------------------------------------------------
# Build Target: hikogui_tests (executable)
#-------------------------------------------------------------------
if(BUILD_TESTING)
include(CMakeLists_tests.cmake)
endif()
#-------------------------------------------------------------------
# Build examples
#-------------------------------------------------------------------
add_custom_target(examples)
add_subdirectory(examples/codec)
add_subdirectory(examples/custom_widgets)
add_subdirectory(examples/hikogui_demo)
add_subdirectory(examples/vulkan/triangle)
add_subdirectory(examples/widgets)
#-------------------------------------------------------------------
# Display Compiler and Linker properties of Build Targets
#-------------------------------------------------------------------
show_build_target_properties(hikogui)
#-------------------------------------------------------------------
# Build Documentation
#-------------------------------------------------------------------
#
# Doxygen
#
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_EXCLUDE_PATTERNS *_tests.cpp *_impl.cpp *.mm)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_LATEX NO)
set(DOXYGEN_QUIET YES)
set(DOXYGEN_WARN_IF_UNDOCUMENTED NO)
set(DOXYGEN_WARN_NO_PARAMDOC NO)
set(DOXYGEN_STRIP_FROM_PATH src)
set(DOXYGEN_STRIP_FROM_INC_PATH src)
# Use SHORT_NAMES to prevent Doxygen from generating filenames with double-quotes.
# ALLOW_UNICODE_NAMES does not escape double-quotes.
set(DOXYGEN_SHORT_NAMES YES)
set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
set(DOXYGEN_ALWAYS_DETAILED_SEC YES)
set(DOXYGEN_DISTRIBUTE_GROUP_DOC YES)
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
#set(DOXYGEN_CLANG_ASSISTED_PARSING YES)
#set(DOXYGEN_CLANG_OPTIONS "-std=c++20")
set(DOXYGEN_TAGFILES "${CMAKE_SOURCE_DIR}/docs/media/style/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/")
set(DOXYGEN_IMAGE_PATH "${CMAKE_SOURCE_DIR}/src/" "${CMAKE_SOURCE_DIR}/docs/")
set(DOXYGEN_EXAMPLE_PATH "${CMAKE_SOURCE_DIR}/examples/")
set(DOXYGEN_LAYOUT_FILE "${CMAKE_SOURCE_DIR}/docs/media/style/DoxygenLayout.xml")
set(DOXYGEN_HTML_COLORSTYLE_HUE 24)
set(DOXYGEN_HTML_COLORSTYLE_SAT 150)
set(DOXYGEN_HTML_COLORSTYLE_GAMMA 80)
set(DOXYGEN_HTML_EXTRA_STYLESHEET "${CMAKE_SOURCE_DIR}/docs/media/style/customdoxygen.css")
# The following 4 settings are to get protected members to behave as private.
set(DOXYGEN_ENABLE_PREPROCESSING YES)
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
set(DOXYGEN_PREDEFINED "protected=private")
doxygen_add_docs(docs src/hikogui docs)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share COMPONENT docs EXCLUDE_FROM_ALL)
else()
message("Please install Doxygen to generate the documentation.")
endif()