-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
601 lines (500 loc) · 23.5 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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# Parasol Core Build File
#
# Release Config: cmake -S . -B release -DCMAKE_BUILD_TYPE=Release
# Debug Config: cmake -S . -B debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=local -DRUN_ANYWHERE=TRUE
# Git Release: cmake -S . -B release-git -DCMAKE_BUILD_TYPE=Release -DINSTALL_EXAMPLES=TRUE -DINSTALL_INCLUDES=FALSE -DDISABLE_SSL=TRUE -DCMAKE_INSTALL_PREFIX=parasol-linux64-$(date +'%Y%m%d') -DRUN_ANYWHERE=TRUE -DBUILD_TESTS=OFF -DBUILD_DEFS=OFF
#
# For GCC based Windows builds, -G"MinGW Makefiles" must be added to the above commands.
#
# A build can target a local folder by adding -DCMAKE_INSTALL_PREFIX=local -DRUN_ANYWHERE=TRUE
#
# Build: cmake --build release -j 8 -- -O
# Install: sudo cmake --install release
# Test: [GCC] make -C release test ARGS=--verbose
# [MSVC] cd visual-studio; ctest -V -C Release
#
# A static build can be enabled with -DPARASOL_STATIC=ON if the intention is to embed Parasol into another project.
# This may be useful if you intend to use a limited feature-set, like the vector graphics API. Static builds
# should be customised with an isolated output folder that is exclusive to the target project. Sharing a static
# build across multiple projects can otherwise lead to confusing outcomes.
cmake_minimum_required(VERSION 3.15)
include (CheckIncludeFiles)
include (CheckTypeSize)
include (CheckFunctionExists)
include (CheckSymbolExists)
include (CheckCSourceCompiles)
include (CheckStructHasMember)
include (CheckLibraryExists)
include (TestBigEndian)
include (ExternalProject)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()
project (Parasol VERSION 2024.2.27 LANGUAGES C CXX)
cmake_policy (SET CMP0082 NEW) # Process install commands in the order that they appear
# To switch on a custom option use -D, e.g. -DPARASOL_VLOG=ON
option (PARASOL_STATIC "Build framework as a set of static libraries instead of the default modular build." OFF)
option (PARASOL_INSTALL "Create installation targets" ON)
option (PARASOL_VLOG "Enable verbose log messages in the generated binaries" OFF)
if (UNIX)
option (RUN_ANYWHERE "Build a framework that can run directly from the main folder. Typically used if redefining CMAKE_INSTALL_PREFIX" OFF)
else ()
set (RUN_ANYWHERE ON)
endif ()
option (BUILD_TESTS "Build/enable tests" ON)
option (BUILD_DEFS "Auto-generate C/C++ headers and documentation" OFF)
option (DISABLE_SSL "Disable built-in SSL support even if available on this system" ON)
option (DISABLE_X11 "Disable X11 even if available on this system" OFF)
option (DISABLE_AUDIO "Disable audio API" OFF)
option (DISABLE_DISPLAY "Disable display API" OFF)
option (DISABLE_DOCUMENT "Disable document API" OFF)
option (DISABLE_FONT "Disable font API" OFF)
option (DISABLE_HTTP "Disable HTTP API" OFF)
option (DISABLE_MP3 "Disable MP3 support" OFF)
option (DISABLE_NETWORK "Disable network API" OFF)
option (DISABLE_PICTURE "Disable picture API" OFF)
option (DISABLE_JPEG "Disable JPEG support" OFF)
option (DISABLE_SCINTILLA "Disable Scintilla API" OFF)
option (DISABLE_SVG "Disable SVG support" OFF)
option (DISABLE_VECTOR "Disable vector API" OFF)
option (INSTALL_EXAMPLES "Install the example scripts, typically for compiling a distribution" OFF)
option (INSTALL_INCLUDES "Install the header files. Turn this off for client releases." OFF)
option (INSTALL_TESTS "Install the test programs." OFF)
option (ENABLE_ANALYSIS "Enable run-time program analysis (with performance penalties) if available. May negatively affect gdb." OFF)
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_STANDARD_REQUIRED True)
set (CMAKE_POSITION_INDEPENDENT_CODE ON) # Enables -fPIC and -fPIE in gcc
set (BUILD_RPATH_USE_ORIGIN TRUE)
set (INCLUDE_OUTPUT "${PROJECT_SOURCE_DIR}/include/parasol")
set (DOCS "${PROJECT_SOURCE_DIR}/docs/xml")
if (PARASOL_STATIC)
set (BUILD_SHARED_LIBS OFF)
else ()
set (BUILD_SHARED_LIBS ON)
endif ()
if (RUN_ANYWHERE)
set (PARASOL_ROOT "${CMAKE_INSTALL_PREFIX}")
set (SHARE_TARGET .)
set (LIB_TARGET "lib")
set (PARASOL_CMD_PATH "${CMAKE_INSTALL_PREFIX}")
else ()
set (PARASOL_ROOT "${CMAKE_INSTALL_PREFIX}/share/parasol")
set (SHARE_TARGET "share/parasol")
set (LIB_TARGET "lib/parasol")
set (PARASOL_CMD_PATH "${CMAKE_INSTALL_PREFIX}/bin")
endif ()
set (PARASOL_CMD_TARGET "${PARASOL_CMD_PATH}/parasol")
test_big_endian (SYSTEM_ENDIAN_STYLE)
if (SYSTEM_ENDIAN_STYLE EQUAL 0) # Little endian (Intel)
set (REVERSE_BYTEORDER TRUE)
set (LITTLE_ENDIAN TRUE)
endif ()
if (NOT DISABLE_SSL)
set (OPENSSL_USE_STATIC_LIBS TRUE) # Doesn't work as expected in MinGW env.
include (FindOpenSSL)
endif ()
if (NOT DISABLE_X11)
include (FindX11)
endif ()
if (MINGW) # Undo the use of 'lib' as the default prefix set by MinGW
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_STATIC_LIBRARY_PREFIX "")
endif ()
include_directories("${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/include/parasol/3rdparty"
"${CMAKE_CURRENT_BINARY_DIR}")
CHECK_CXX_SOURCE_COMPILES ("
#include <stdio.h>
int main() {
printf(\"%lld\", 0x1122334455667788);
return 0;
}"
PRINTF64_LLD
FAIL_REGEX "warning")
CHECK_CXX_SOURCE_COMPILES ("
#include <stdio.h>
int main() {
printf(\"%I64lld\", 0x1122334455667788);
return 0;
}"
PRINTF64_ID
FAIL_REGEX "warning")
CHECK_CXX_SOURCE_COMPILES ("
#include <stdio.h>
#include <inttypes.h>
int main() {
printf(\"%\" PRId64, 0x1122334455667788);
return 0;
}"
PRINTF64_PRID
FAIL_REGEX "warning")
find_program (XXD_CMD "xxd")
find_program (PARASOL_CMD "parasol" NO_DEFAULT_PATH PATHS "${PARASOL_CMD_PATH}")
find_file (IDL_C_SCRIPT "idl-c.fluid" PATHS "${PROJECT_SOURCE_DIR}/tools/idl")
find_file (IDL_COMPILE_SCRIPT "idl-compile.fluid" PATHS "${PROJECT_SOURCE_DIR}/tools/idl")
find_file (FLUTE_SCRIPT "flute.fluid" PATHS "${PROJECT_SOURCE_DIR}/tools")
if (PARASOL_CMD STREQUAL "PARASOL_CMD-NOTFOUND")
message (STATUS "Definitions will not be built and tests are disabled.")
set (BUILD_DEFS OFF)
else ()
if (BUILD_DEFS)
message (STATUS "Definitions will be built with the Parasol exe installed @ ${PARASOL_CMD}.")
endif ()
endif ()
if (BUILD_TESTS)
message (STATUS "Integration tests are enabled.")
enable_testing()
endif ()
if (IDL_C_SCRIPT STREQUAL "IDL_C_SCRIPT-NOTFOUND")
message (FATAL_ERROR "The idl-c.fluid script was not found in ${PROJECT_SOURCE_DIR}/tools/idl")
endif ()
if (IDL_COMPILE_SCRIPT STREQUAL "IDL_COMPILE_SCRIPT-NOTFOUND")
message (FATAL_ERROR "The idl-compile.fluid script was not found in ${PROJECT_SOURCE_DIR}/tools/idl")
endif ()
if (FLUTE_SCRIPT STREQUAL "FLUTE_SCRIPT-NOTFOUND")
message (FATAL_ERROR "The flute.fluid script was not found in ${PROJECT_SOURCE_DIR}/tools")
endif ()
if (NOT MSVC)
set (MATH_LINK m)
endif ()
if (WIN32)
if (PARASOL_STATIC)
# NB: MinGW does not guarantee that libgcc and libstdc++ will be static even if these flags are specified.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set (CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
endif ()
set (INIT_LINK "init-win" core)
else ()
set (CMAKE_EXE_LINKER_FLAGS "-static")
set (INIT_LINK "init-win")
endif ()
else ()
# Note that compiling with -static in Linux is disabled because it appears to cause segfaults when writing __thread variables.
if (PARASOL_STATIC)
set (INIT_LINK "init-unix" core)
else ()
set (INIT_LINK "init-unix")
endif ()
endif ()
add_custom_target(build_headers ALL COMMENT "Generate headers and definition files on the fly")
# --------------------------------------------------------------------------------------------------------------------
# Use Flute to write tests against your code. All Flute tests are integration tests, i.e. run them post-install
# against the target installation folder.
function (flute_test name path)
if (BUILD_TESTS)
if (RUN_ANYWHERE)
set (FLUTE_EXE "${CMAKE_INSTALL_PREFIX}/parasol")
else ()
set (FLUTE_EXE "${CMAKE_INSTALL_PREFIX}/bin/parasol")
endif ()
get_filename_component(FLUTE_FULL_PATH "${path}" ABSOLUTE)
add_test (NAME ${name}
COMMAND "${FLUTE_EXE}" "--log-warning" "--gfx-driver=headless" "${FLUTE_SCRIPT}" "file=${FLUTE_FULL_PATH}"
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
endif ()
endfunction ()
# --------------------------------------------------------------------------------------------------------------------
# idl_gen() is used to generate both C/C++ headers and IDL strings from FDL files.
function (idl_gen)
cmake_parse_arguments (PARSE_ARGV 0 IDLC "" "OUTPUT;APPEND_IDL;NAME" "ARGS;FILES")
if (BUILD_DEFS)
if (DEFINED IDLC_NAME)
set (OUTPUT_NAME ${IDLC_NAME})
else ()
string (REGEX REPLACE "[/:\.]" "_" OUTPUT_NAME ${IDLC_OUTPUT})
endif ()
if (DEFINED IDLC_FILES)
list (APPEND IDLC_ARGS "files={" ${IDLC_FILES} "}")
endif ()
list (APPEND COMMAND_LIST COMMAND ${PARASOL_CMD} ${IDL_C_SCRIPT} "--log-warning" "src=${ARGV0}"
"output=${IDLC_OUTPUT}" "sdk=${PROJECT_SOURCE_DIR}" ${IDLC_ARGS})
if (DEFINED IDLC_APPEND_IDL)
list (APPEND COMMAND_LIST COMMAND ${PARASOL_CMD} ${IDL_COMPILE_SCRIPT} "--log-warning" "src=${ARGV0}"
"output=${IDLC_APPEND_IDL}" "sdk=${PROJECT_SOURCE_DIR}" "format=c" "append")
endif ()
add_custom_command (OUTPUT ${IDLC_OUTPUT}
PRE_BUILD
${COMMAND_LIST}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${ARGV0}
COMMENT "Generating C header file ${IDLC_OUTPUT} from ${ARGV0}"
VERBATIM)
add_custom_target (${OUTPUT_NAME} DEPENDS ${IDLC_OUTPUT})
add_dependencies (build_headers ${OUTPUT_NAME})
else ()
message (STATUS "The generation of ${IDLC_OUTPUT} will be skipped.")
endif ()
endfunction ()
# --------------------------------------------------------------------------------------------------------------------
# idl_compile() is used to generate universal IDL strings
# Always provide a full path for OUTPUT
function (idl_compile)
cmake_parse_arguments (PARSE_ARGV 0 IDLC "" "OUTPUT;NAME" "ARGS;FILES")
if (BUILD_DEFS)
if (DEFINED IDLC_NAME)
set (OUTPUT_NAME ${IDLC_NAME})
else ()
string (REGEX REPLACE "[/:\.]" "_" OUTPUT_NAME ${IDLC_OUTPUT})
endif ()
add_custom_command (OUTPUT ${IDLC_OUTPUT}
PRE_BUILD
COMMAND "${PARASOL_CMD}" "${IDL_COMPILE_SCRIPT}" "--log-warning" "src=${ARGV0}" "output=${IDLC_OUTPUT}" "sdk=${PROJECT_SOURCE_DIR}" "format=c" ${IDLC_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${ARGV0}
COMMENT "Producing definition file ${IDLC_OUTPUT} from ${ARGV0}"
VERBATIM)
add_custom_target (${OUTPUT_NAME} DEPENDS ${IDLC_OUTPUT})
add_dependencies (build_headers ${OUTPUT_NAME})
else ()
message (STATUS "The generation of ${IDLC_OUTPUT} will be skipped.")
endif ()
endfunction ()
# --------------------------------------------------------------------------------------------------------------------
# This is a convenience function that configures the default settings needed for Parasol modules
function (set_module_defaults ARG_TARGET)
target_include_directories (${ARG_TARGET} PRIVATE "${PROJECT_SOURCE_DIR}/include")
add_compile_definitions ("MOD_NAME=${ARG_TARGET}")
if (MSVC)
else ()
# Collect code and data that is never referenced
target_link_options (${ARG_TARGET} PRIVATE "$<${GCC_COMPAT}:$<LINK_ONLY:LINKER:--gc-sections>>")
endif ()
if (PARASOL_STATIC)
set_target_properties (${ARG_TARGET}
PROPERTIES
CXX_STANDARD 20)
else ()
if (CMAKE_BUILD_TYPE MATCHES "Release")
set_target_properties (${ARG_TARGET} PROPERTIES LINK_FLAGS_RELEASE -s)
endif ()
set_target_properties (${ARG_TARGET}
PROPERTIES
PREFIX ""
CXX_STANDARD 20
CMAKE_POSITION_INDEPENDENT_CODE ON # Enables -fPIC and -fPIE in gcc
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/release/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/release/lib")
if (PARASOL_INSTALL)
if (WIN32)
install(TARGETS ${ARG_TARGET} RUNTIME DESTINATION "${LIB_TARGET}")
else ()
install(TARGETS ${ARG_TARGET}
RUNTIME DESTINATION "${LIB_TARGET}"
ARCHIVE DESTINATION "${LIB_TARGET}"
LIBRARY DESTINATION "${LIB_TARGET}")
endif ()
endif ()
endif ()
endfunction ()
# --------------------------------------------------------------------------------------------------------------------
# 64-bit checks
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message (STATUS "This will be a 64-bit build for processor arch ${CMAKE_HOST_SYSTEM_PROCESSOR}")
set (_LP64 ON) # Used by config.h
# set (PARASOL_ARCH "-m64")
else ()
message (STATUS "This will be a 32-bit build for processor arch ${CMAKE_HOST_SYSTEM_PROCESSOR}")
# set (PARASOL_ARCH "-m32")
endif ()
if (PARASOL_VLOG)
add_compile_definitions ("_DEBUG")
endif ()
# Set system-specific compiler flags
if (MSVC)
# Turn off ugly warnings
add_compile_definitions ("_CRT_SECURE_NO_WARNINGS")
# Use NODEFAULTLIB to override sub-projects linking to incorrect standard libraries.
# https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-6.0/aa267384(v=vs.60)?redirectedfrom=MSDN
if (PARASOL_VLOG)
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
add_link_options ("/NODEFAULTLIB:libc.lib" "/NODEFAULTLIB:libcmt.lib" "/NODEFAULTLIB:libc.lib" "/NODEFAULTLIB:libcmtd.lib" "/NODEFAULTLIB:msvcrt.lib")
else ()
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
add_link_options ("/NODEFAULTLIB:libcmt.lib" "/NODEFAULTLIB:libcmtd.lib" "/NODEFAULTLIB:msvcrtd.lib")
endif ()
# add_link_options ("/VERBOSE:LIB")
if (ENABLE_ANALYSIS)
# Note that this option is not compatible with /ZI (edit-and-continue). To rectify complaints about the asan DLL, you may also need a line like this one added to each entry in launch.vs.json:
# "env": { "Path": "${env:Path};C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64" }
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address")
endif ()
# We don't use exceptions, so get the compiler to disable this functionality. This results in noticeably smaller binaries and more optimised code.
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_definitions ("_HAS_EXCEPTIONS=0")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /EHs-c- /GR")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c- /GR")
endif ()
else ()
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_compile_definitions ("_DARWIN_C_SOURCE")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
add_compile_definitions ("_GNU_SOURCE")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=auto -fdata-sections -ffunction-sections -fno-strict-aliasing -Wno-pointer-sign")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto -fdata-sections -ffunction-sections -fno-strict-aliasing")
elseif (WIN32)
add_definitions ("-D_WIN32" "-U__unix__")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -fdiagnostics-color=auto -fdata-sections -ffunction-sections -fno-strict-aliasing -Wno-pointer-sign ${PARASOL_ARCH}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fdiagnostics-color=auto -ffunction-sections -fno-strict-aliasing ${PARASOL_ARCH}")
if (PRINTF64_ID)
add_compile_definitions ("PRINTF64I")
endif ()
if (PRINTF64_PRID)
add_compile_definitions ("PRINTF64_PRID")
endif ()
elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
# TODO
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
endif ()
if (ENABLE_ANALYSIS)
# NB: The use of dlclose() is not permitted when analysis is enabled because it upsets the log output.
# In addition, gdb breakpoints are unlikely to work with these features enabled.
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=leak -DANALYSIS_ENABLED")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -DANALYSIS_ENABLED")
set (DISABLE_AUDIO ON)
if (NOT PARASOL_STATIC)
message (FATAL_ERROR "Address analysis requires the build to be compiled with PARASOL_STATIC on.")
endif ()
endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-empty-body -Wno-unused-result -Wno-format-zero-length -Wno-unused-but-set-variable -Wno-stringop-overflow")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-empty-body -Wno-unused-result -Wno-format-zero-length -Wno-unused-but-set-variable -Wno-stringop-overflow")
# These default compile options are for use by target_compile_options()
# TODO: Utilise target_compile_options() in the makefiles
set (GCC_COMPAT "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU>")
set (DEFAULT_GCC_FLAGS "-Wall" "-Wno-empty-body" "-Wno-unused-result" "-Wno-format-zero-length" "-Wno-unused-but-set-variable" "-Wno-stringop-overflow")
set (DEFAULT_GCXX_FLAGS "-Wall" "-Wno-empty-body" "-Wno-unused-result" "-Wno-format-zero-length" "-Wno-unused-but-set-variable" "-Wno-stringop-overflow")
endif ()
# Support for building Windows resource files with MINGW
if (MINGW)
set (CMAKE_RC_COMPILER_INIT windres)
enable_language (RC)
set (CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -i <SOURCE> -o <OBJECT>")
endif (MINGW)
# --------------------------------------------------------------------------------------------------------------------
# Sub-libraries are defined as linkable objects so that they work correctly between static and modular builds.
add_library(linear_rgb OBJECT src/link/linear_rgb.cpp)
add_library(unicode OBJECT src/link/unicode.cpp)
add_library(base64 OBJECT src/link/base64.cpp)
# --------------------------------------------------------------------------------------------------------------------
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
add_subdirectory (3rdparty/zlib-1.2.11) # Note that when upgrading, the CMakeLists.txt is customised
add_subdirectory (3rdparty/freetype-2.13.2)
if (NOT DISABLE_AUDIO)
add_subdirectory (src/audio)
list (APPEND LIB_LIST audio)
endif ()
if (NOT DISABLE_DISPLAY)
add_subdirectory (src/display)
list (APPEND LIB_LIST display)
endif ()
if ((NOT DISABLE_DOCUMENT) AND (NOT DISABLE_DISPLAY) AND (NOT DISABLE_VECTOR) AND (NOT DISABLE_FONT))
add_subdirectory (src/document)
list (APPEND LIB_LIST document)
endif ()
if (NOT DISABLE_FONT AND NOT DISABLE_DISPLAY)
add_subdirectory (src/font)
list (APPEND LIB_LIST font)
endif ()
if (NOT DISABLE_HTTP AND NOT DISABLE_NETWORK)
add_subdirectory (src/http)
list (APPEND LIB_LIST http)
endif ()
if (NOT DISABLE_MP3 AND NOT DISABLE_AUDIO)
add_subdirectory (src/mp3)
list (APPEND LIB_LIST mp3)
endif ()
if (NOT DISABLE_NETWORK)
add_subdirectory (src/network)
list (APPEND LIB_LIST network)
endif ()
if (NOT DISABLE_PICTURE AND NOT DISABLE_DISPLAY)
add_subdirectory (src/picture)
list (APPEND LIB_LIST picture)
endif ()
if (NOT DISABLE_JPEG AND NOT DISABLE_PICTURE)
add_subdirectory (src/picture_jpeg)
list (APPEND LIB_LIST jpeg)
endif ()
if (NOT DISABLE_SCINTILLA AND NOT DISABLE_DISPLAY AND NOT DISABLE_VECTOR AND NOT DISABLE_FONT)
add_subdirectory (src/scintilla)
list (APPEND LIB_LIST scintilla)
endif ()
if (NOT DISABLE_SVG AND NOT DISABLE_VECTOR AND NOT DISABLE_DISPLAY AND NOT DISABLE_FONT)
add_subdirectory (src/svg)
list (APPEND LIB_LIST svg)
endif ()
if (NOT DISABLE_VECTOR AND NOT DISABLE_DISPLAY AND NOT DISABLE_FONT)
add_subdirectory (src/vector)
list (APPEND LIB_LIST vector)
endif ()
list (APPEND LIB_LIST fluid json jpeg xml)
add_subdirectory (src/link)
add_subdirectory (src/core)
add_subdirectory (src/fluid)
add_subdirectory (src/xml)
add_subdirectory (src/json)
add_subdirectory (src/launcher)
# --------------------------------------------------------------------------------------------------------------------
# Generate the platform configuration header
configure_file ("src/config.h.in" "parasol/config.h" NEWLINE_STYLE UNIX)
# --------------------------------------------------------------------------------------------------------------------
# Icons are installed as a zip file
file(GLOB_RECURSE icon_files "data/icons/*.svg")
add_custom_command (
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/icons/Default.zip"
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/icons"
COMMAND ${CMAKE_COMMAND} -E tar "cf" "${CMAKE_CURRENT_BINARY_DIR}/icons/Default.zip" --format=zip -- "."
DEPENDS ${icon_files}
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/data/icons/Default"
COMMENT "Zipping icons")
add_custom_target (icon_package ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/icons/Default.zip")
# --------------------------------------------------------------------------------------------------------------------
# Installation steps
if (PARASOL_INSTALL)
if (INSTALL_INCLUDES)
install (DIRECTORY "${INCLUDE_OUTPUT}" DESTINATION "include")
install (FILES "${CMAKE_BINARY_DIR}/parasol/config.h" DESTINATION "include/parasol/")
endif ()
if (WIN32)
if (NOT DISABLE_SSL)
install (DIRECTORY "${PROJECT_SOURCE_DIR}/data/ssl/" DESTINATION "config/ssl")
endif ()
if (NOT DISABLE_FONT)
install (DIRECTORY "${PROJECT_SOURCE_DIR}/data/fonts/" DESTINATION "config/fonts")
endif ()
install (DIRECTORY "${PROJECT_SOURCE_DIR}/data/styles/" DESTINATION "config/styles")
install (FILES "${CMAKE_BINARY_DIR}/icons/Default.zip" DESTINATION "config/styles/icons")
install (DIRECTORY "${PROJECT_SOURCE_DIR}/scripts/" DESTINATION "scripts")
if (INSTALL_EXAMPLES)
install (DIRECTORY "${PROJECT_SOURCE_DIR}/examples/" DESTINATION "examples")
endif ()
else ()
if (NOT DISABLE_SSL)
install (DIRECTORY "${PROJECT_SOURCE_DIR}/data/ssl" DESTINATION "${SHARE_TARGET}/config")
endif ()
if (NOT DISABLE_FONT)
install (DIRECTORY "${PROJECT_SOURCE_DIR}/data/fonts" DESTINATION "${SHARE_TARGET}/config")
endif ()
install (DIRECTORY "${PROJECT_SOURCE_DIR}/data/styles" DESTINATION "${SHARE_TARGET}/config")
install (FILES "${CMAKE_BINARY_DIR}/icons/Default.zip" DESTINATION "${SHARE_TARGET}/config/styles/icons")
install (DIRECTORY "${PROJECT_SOURCE_DIR}/scripts" DESTINATION "${SHARE_TARGET}")
if (INSTALL_EXAMPLES)
install (DIRECTORY "${PROJECT_SOURCE_DIR}/examples" DESTINATION "${SHARE_TARGET}")
endif ()
endif ()
if (NOT PARASOL_STATIC)
install (CODE "file(REMOVE \"${PARASOL_ROOT}/config/classes.bin\")")
install (CODE "MESSAGE(STATUS \"${PARASOL_CMD_TARGET} --log-warning --gfx-driver=headless --verify\")")
install (CODE "execute_process(COMMAND \"${PARASOL_CMD_TARGET}\" --log-warning --gfx-driver=headless --verify WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\")")
endif ()
if (RUN_ANYWHERE)
install (CODE "MESSAGE(STATUS \"\nParasol has been installed to '${CMAKE_INSTALL_PREFIX}'. You may need to add this folder to your PATH variable in order to run parasol.exe from the command-line.\")")
else ()
install (CODE "MESSAGE(STATUS \"\nParasol has been installed to '${CMAKE_INSTALL_PREFIX}' and shared files are in '${PARASOL_ROOT}'.\")")
endif ()
endif ()