forked from STEllAR-GROUP/hpx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
2721 lines (2404 loc) · 82.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
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (c) 2020 Mikael Simberg
# Copyright (c) 2007-2024 Hartmut Kaiser
# Copyright (c) 2011-2014 Thomas Heller
# Copyright (c) 2007-2008 Chirag Dekate
# Copyright (c) 2011 Bryce Lelbach
# Copyright (c) 2011 Vinay C Amatya
# Copyright (c) 2013 Jeroen Habraken
# Copyright (c) 2014-2016 Andreas Schaefer
# Copyright (c) 2017 Abhimanyu Rawat
# Copyright (c) 2017 Google
# Copyright (c) 2017 Taeguk Kwon
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
# Overrides must go before the project() statement, otherwise they are ignored.
# ##############################################################################
# C++ overrides
# ##############################################################################
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/HPX_CXXOverrides.cmake"
)
# ##############################################################################
# Build type (needs to be handled before project command below)
# ##############################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Release"
CACHE
STRING
"Configuration type (one of Debug, RelWithDebInfo, Release, MinSizeRel)"
FORCE
)
endif()
# ##############################################################################
# project metadata
# ##############################################################################
project(HPX CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# ##############################################################################
# Special handling for building tests/examples against a previously installed
# version of HPX
# ##############################################################################
if(HPX_WITH_INSTALLED_VERSION)
include(cmake/installed_hpx.cmake)
return()
endif()
# ##############################################################################
# Build all of HPX
# ##############################################################################
set(HPX_VERSION_MAJOR 1)
set(HPX_VERSION_MINOR 10)
set(HPX_VERSION_SUBMINOR 0)
set(HPX_VERSION_DATE 20230804)
set(HPX_VERSION_TAG "-trunk")
set(HPX_VERSION
"${HPX_VERSION_MAJOR}.${HPX_VERSION_MINOR}.${HPX_VERSION_SUBMINOR}"
)
set(HPX_LIBRARY_VERSION "${HPX_VERSION}")
set(HPX_SOVERSION ${HPX_VERSION_MAJOR})
set(HPX_PACKAGE_NAME HPX)
# To keep track of the hpx_root when other subprojects are declared
set(HPX_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
set(HPX_BINARY_DIR "${PROJECT_BINARY_DIR}")
# ##############################################################################
# CMake configuration
# ##############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(HPX_Utils)
# explicitly set certain policies
cmake_policy(VERSION 3.18)
hpx_set_cmake_policy(CMP0042 NEW)
hpx_set_cmake_policy(CMP0060 NEW)
hpx_set_cmake_policy(CMP0074 NEW)
# We save the passed compiler flag to a special variable. This is needed for our
# build system unit tests. Some flags might influence the created symbols
# (_GLIBCXX_DEBUG, I look at you)
set(CMAKE_CXX_FLAGS_SAFE ${CMAKE_CXX_FLAGS})
include(HPX_CheckCXXStandard)
include(CheckCXXCompilerFlag)
include(CMakeDependentOption)
# include additional macro definitions
include(HPX_AddConfigTest)
include(HPX_AddDefinitions)
include(HPX_CreateSymbolicLink)
hpx_force_out_of_tree_build(
"This project requires an out-of-source-tree build. See README.rst. Clean your CMake cache and CMakeFiles if this message persists."
)
if(NOT HPX_CMAKE_LOGLEVEL)
set(HPX_CMAKE_LOGLEVEL "WARN")
endif()
# print initial diagnostics
hpx_info("CMake version: ${CMAKE_VERSION}, generator: ${CMAKE_GENERATOR}")
hpx_info("HPX version: ${HPX_VERSION}")
# ##############################################################################
# reset cached variables that need to be re-filled
unset(HPX_COMPONENTS CACHE)
unset(HPX_EXPORT_TARGETS CACHE)
unset(HPX_EXPORT_INTERNAL_TARGETS CACHE)
unset(HPX_ENABLED_MODULES CACHE)
unset(HPX_CORE_ENABLED_MODULES CACHE)
unset(HPX_FULL_ENABLED_MODULES CACHE)
unset(HPX_STATIC_PARCELPORT_PLUGINS CACHE)
# ##############################################################################
# Set up dummy compiler flags targets
# ##############################################################################
include(HPX_CompilerFlagsTargets)
# ##############################################################################
# Setup platform for which HPX should be compiled for.
#
include(HPX_SetPlatform)
if("${HPX_PLATFORM_UC}" STREQUAL "ANDROID")
unset(HPX_LIBRARY_VERSION)
unset(HPX_SOVERSION)
endif()
if(MSVC)
hpx_option(
HPX_WITH_VS_STARTUP_PROJECT STRING
"Define the startup project for the HPX solution (default: ALL_BUILD)."
"ALL_BUILD" ADVANCED
)
if(HPX_WITH_VS_STARTUP_PROJECT)
set(VS_STARTUP_PROJECT ${HPX_WITH_VS_STARTUP_PROJECT})
endif()
endif()
# ##############################################################################
# ##############################################################################
# Set our build options cache variables which are customizable by users
#
hpx_option(
HPX_WITH_DEPRECATION_WARNINGS BOOL
"Enable warnings for deprecated facilities. (default: ON)" ON ADVANCED
)
if(HPX_WITH_DEPRECATION_WARNINGS)
# enable deprecation warnings globally
hpx_add_config_cond_define(HPX_HAVE_DEPRECATION_WARNINGS 1)
endif()
# Generic build options
set(DEFAULT_MALLOC "system")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(DEFAULT_MALLOC "tcmalloc")
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(HPX_WITH_STACKOVERFLOW_DETECTION_DEFAULT OFF)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
if("${CMAKE_BUILD_TYPE_UC}" STREQUAL "DEBUG")
set(HPX_WITH_STACKOVERFLOW_DETECTION_DEFAULT ON)
endif()
hpx_option(
HPX_WITH_STACKOVERFLOW_DETECTION
BOOL
"Enable stackoverflow detection for HPX threads/coroutines. (default: OFF, debug: ON)"
${HPX_WITH_STACKOVERFLOW_DETECTION_DEFAULT}
ADVANCED
)
if(HPX_WITH_STACKOVERFLOW_DETECTION)
hpx_add_config_define(HPX_HAVE_STACKOVERFLOW_DETECTION)
endif()
endif()
hpx_option(
HPX_WITH_MALLOC
STRING
"Define which allocator should be linked in. Options are: system, tcmalloc, jemalloc, mimalloc, tbbmalloc, and custom (default is: tcmalloc)"
${DEFAULT_MALLOC}
STRINGS "system;tcmalloc;jemalloc;mimalloc;tbbmalloc;custom"
)
# On some systems jemalloc requires an explicit prefix for the API functions
# (i.e. 'malloc' is called 'je_malloc', etc.)
if(${HPX_WITH_MALLOC} STREQUAL "jemalloc")
if(MSVC)
set(HPX_WITH_JEMALLOC_PREFIX_DEFAULT "je_")
else()
set(HPX_WITH_JEMALLOC_PREFIX_DEFAULT "<none>")
endif()
hpx_option(
HPX_WITH_JEMALLOC_PREFIX STRING
"Optional naming prefix for jemalloc API functions"
${HPX_WITH_JEMALLOC_PREFIX_DEFAULT} ADVANCED
)
endif()
# Logging configuration
hpx_option(
HPX_WITH_LOGGING BOOL "Build HPX with logging enabled (default: ON)." ON
ADVANCED
)
if(HPX_WITH_LOGGING)
hpx_add_config_define(HPX_HAVE_LOGGING)
endif()
hpx_option(
HPX_WITH_FAULT_TOLERANCE
BOOL
"Build HPX to tolerate failures of nodes, i.e. ignore errors in active communication channels (default: OFF)"
OFF
ADVANCED
)
if(HPX_WITH_FAULT_TOLERANCE)
hpx_add_config_define(HPX_HAVE_FAULT_TOLERANCE)
endif()
# Compiler related build options
hpx_option(
HPX_WITH_GCC_VERSION_CHECK BOOL
"Don't ignore version reported by gcc (default: ON)" ON ADVANCED
)
hpx_option(
HPX_WITH_COMPILER_WARNINGS BOOL "Enable compiler warnings (default: ON)" ON
ADVANCED
)
hpx_option(
HPX_WITH_COMPILER_WARNINGS_AS_ERRORS BOOL
"Turn compiler warnings into errors (default: OFF)" OFF ADVANCED
)
hpx_option(
HPX_WITH_EXECUTABLE_PREFIX STRING
"Executable prefix (default none), 'hpx_' useful for system install." ""
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_DOCUMENTATION BOOL "Build the HPX documentation (default OFF)." OFF
CATEGORY "Build Targets"
)
if(HPX_WITH_DOCUMENTATION)
set(valid_output_formats html singlehtml latexpdf man)
hpx_option(
HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS
STRING
"List of documentation output formats to generate. Valid options are ${valid_output_formats}. Multiple values can be separated with semicolons. (default html)."
"html"
CATEGORY "Build Targets"
)
foreach(output_format ${HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS})
if(NOT ${output_format} IN_LIST valid_output_formats)
hpx_error(
"${output_format} is not a valid value for HPX_WITH_DOCUMENTATION_OUTPUT_FORMATS. Valid output format are: ${valid_output_formats}."
)
endif()
endforeach()
endif()
if(WIN32)
set(HPX_WITH_PSEUDO_DEPENDENCIES
OFF
CACHE INTERNAL "" FORCE
)
else()
set(HPX_WITH_PSEUDO_DEPENDENCIES
ON
CACHE INTERNAL "" FORCE
)
endif()
hpx_option(
HPX_WITH_UNITY_BUILD BOOL
"Enable unity build for certain build targets (default OFF)" OFF ADVANCED
)
if(HPX_WITH_UNITY_BUILD)
set(HPX_WITH_UNITY_BUILD_OPTION UNITY_BUILD)
endif()
hpx_option(
HPX_WITH_PRECOMPILED_HEADERS
BOOL
"Enable precompiled headers for certain build targets (experimental) (default OFF)"
OFF
ADVANCED
)
if(HPX_WITH_PRECOMPILED_HEADERS)
set(HPX_WITH_PRECOMPILED_HEADERS_INTERNAL ON)
# Only create the targets here. They will be set up later once all modules are
# known.
add_library(hpx_precompiled_headers OBJECT libs/src/dummy.cpp)
add_executable(hpx_exe_precompiled_headers libs/src/dummy.cpp)
set_target_properties(hpx_precompiled_headers PROPERTIES FOLDER "Core")
set_target_properties(hpx_exe_precompiled_headers PROPERTIES FOLDER "Core")
endif()
# ##############################################################################
# Dynamic hpx_main
# ##############################################################################
set(HPX_WITH_DYNAMIC_HPX_MAIN_DEFAULT OFF)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR APPLE)
set(HPX_WITH_DYNAMIC_HPX_MAIN_DEFAULT ON)
endif()
hpx_option(
HPX_WITH_DYNAMIC_HPX_MAIN
BOOL
"Enable dynamic overload of system ``main()`` (Linux and Apple only, default: ON)"
${HPX_WITH_DYNAMIC_HPX_MAIN_DEFAULT}
ADVANCED
)
if(HPX_WITH_DYNAMIC_HPX_MAIN)
if(NOT HPX_WITH_DYNAMIC_HPX_MAIN_DEFAULT)
hpx_error(
"HPX_WITH_DYNAMIC_HPX_MAIN was set to ON, but the option is only available on Linux and Apple (this is \"${CMAKE_SYSTEM_NAME}\")."
)
endif()
hpx_add_config_define(HPX_HAVE_DYNAMIC_HPX_MAIN)
endif()
# ##############################################################################
# Some platforms do not support dynamic linking. Enable this to link all
# libraries statically. This also changes some of the internals of HPX related
# to how components are loaded.
# ##############################################################################
hpx_option(
HPX_WITH_STATIC_LINKING BOOL
"Compile HPX statically linked libraries (Default: OFF)" OFF ADVANCED
)
if(HPX_WITH_STATIC_LINKING)
hpx_add_config_define(HPX_HAVE_STATIC_LINKING)
set(hpx_library_link_mode STATIC)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
hpx_option(
HPX_WITH_STATIC_EXE_LINKING BOOL
"Compile HPX statically linked executables (Default: OFF)" OFF ADVANCED
)
if(HPX_WITH_STATIC_EXE_LINKING)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
endif()
else()
set(hpx_library_link_mode SHARED)
endif()
# ##############################################################################
# The cmake Ninja generator runs out of memory if the modules are being built as
# OBJECT libraries. In this case the fallback is to build whole-archive STATIC
# libraries.
set(HPX_WITH_MODULES_AS_STATIC_LIBRARIES_DEFAULT OFF)
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(HPX_WITH_MODULES_AS_STATIC_LIBRARIES_DEFAULT ON)
endif()
hpx_option(
HPX_WITH_MODULES_AS_STATIC_LIBRARIES
BOOL
"Compile HPX modules as STATIC (whole-archive) libraries instead of OBJECT\
libraries (Default: ${HPX_WITH_MODULES_AS_STATIC_LIBRARIES_DEFAULT})"
${HPX_WITH_MODULES_AS_STATIC_LIBRARIES_DEFAULT}
ADVANCED
)
if(HPX_WITH_MODULES_AS_STATIC_LIBRARIES)
hpx_info("Building modules as STATIC (whole-archive) libraries")
else()
hpx_info("Building modules as OBJECT libraries")
endif()
# ##############################################################################
hpx_option(
HPX_WITH_EXAMPLES BOOL "Build the HPX examples (default ON)" ON
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS BOOL "Build the HPX tests (default ON)" ON
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS_BENCHMARKS BOOL "Build HPX benchmark tests (default: ON)" ON
ADVANCED CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS_REGRESSIONS BOOL "Build HPX regression tests (default: ON)" ON
ADVANCED CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS_UNIT BOOL "Build HPX unit tests (default: ON)" ON ADVANCED
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS_HEADERS BOOL "Build HPX header tests (default: OFF)" OFF
ADVANCED CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS_EXTERNAL_BUILD BOOL
"Build external cmake build tests (default: ON)" ON ADVANCED
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TESTS_EXAMPLES BOOL "Add HPX examples as tests (default: ON)" ON
ADVANCED CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_TOOLS BOOL "Build HPX tools (default: OFF)" OFF ADVANCED
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_COMPILE_ONLY_TESTS BOOL
"Create build system support for compile time only HPX tests (default ON)" ON
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_FAIL_COMPILE_TESTS BOOL
"Create build system support for fail compile HPX tests (default ON)" ON
CATEGORY "Build Targets"
)
hpx_option(
HPX_WITH_PARALLEL_LINK_JOBS
STRING
"Number of Parallel link jobs while building hpx (only for Ninja as generator) (default 2)"
"2"
CATEGORY "Build Targets"
)
if(CMAKE_GENERATOR MATCHES "Ninja")
if(NOT HPX_WITH_PARALLEL_LINK_JOBS)
set(HPX_WITH_PARALLEL_LINK_JOBS "2")
endif()
if(HPX_WITH_PARALLEL_LINK_JOBS)
set_property(
GLOBAL APPEND PROPERTY JOB_POOLS
link_job_pool=${HPX_WITH_PARALLEL_LINK_JOBS}
)
set(CMAKE_JOB_POOL_LINK link_job_pool)
endif()
elseif(HPX_WITH_PARALLEL_LINK_JOBS)
hpx_warn("Job pooling is only available with Ninja generators.")
endif()
# disable all tests if HPX_WITH_TESTS=OFF
if(NOT HPX_WITH_TESTS)
hpx_set_option(
HPX_WITH_TESTS_BENCHMARKS
VALUE OFF
FORCE
)
hpx_set_option(
HPX_WITH_TESTS_REGRESSIONS
VALUE OFF
FORCE
)
hpx_set_option(
HPX_WITH_TESTS_UNIT
VALUE OFF
FORCE
)
hpx_set_option(
HPX_WITH_TESTS_HEADERS
VALUE OFF
FORCE
)
hpx_set_option(
HPX_WITH_TESTS_EXTERNAL_BUILD
VALUE OFF
FORCE
)
hpx_set_option(
HPX_WITH_TESTS_EXAMPLES
VALUE OFF
FORCE
)
endif()
hpx_option(
HPX_WITH_DISTRIBUTED_RUNTIME
BOOL
"Enable the distributed runtime (default: ON). Turning off the distributed runtime completely disallows the creation and use of components and actions. Turning this option off is experimental!"
ON
CATEGORY "Build Targets"
ADVANCED
)
if(HPX_WITH_DISTRIBUTED_RUNTIME)
hpx_add_config_define(HPX_HAVE_DISTRIBUTED_RUNTIME)
endif()
# Enable IO-counters on linux systems only
set(HPX_WITH_IO_COUNTERS_DEFAULT OFF)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND HPX_WITH_DISTRIBUTED_RUNTIME)
set(HPX_WITH_IO_COUNTERS_DEFAULT ON)
endif()
hpx_option(
HPX_WITH_IO_COUNTERS BOOL
"Enable IO counters (default: ${HPX_WITH_IO_COUNTERS_DEFAULT})"
${HPX_WITH_IO_COUNTERS_DEFAULT} ADVANCED CATEGORY "Build Targets"
)
if(HPX_WITH_IO_COUNTERS AND HPX_WITH_DISTRIBUTED_RUNTIME)
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
hpx_error(
"HPX_WITH_IO_COUNTERS was set to ON, but IO counters are only available on Linux (this is \"${CMAKE_SYSTEM_NAME}\")"
)
endif()
hpx_add_config_define(HPX_HAVE_IO_COUNTERS)
endif()
set(HPX_FULL_RPATH_DEFAULT ON)
if(APPLE OR WIN32)
set(HPX_FULL_RPATH_DEFAULT OFF)
endif()
hpx_option(
HPX_WITH_FULL_RPATH
BOOL
"Build and link HPX libraries and executables with full RPATHs (default: ${HPX_FULL_RPATH_DEFAULT})"
${HPX_FULL_RPATH_DEFAULT}
ADVANCED
)
# ##############################################################################
# HPX CUDA configuration
# ##############################################################################
set(CUDA_OPTION_STRING "Enable support for CUDA (default: OFF)")
set(HIP_OPTION_STRING "Enable compilation with HIPCC (default: OFF)")
hpx_option(HPX_WITH_CUDA BOOL "${CUDA_OPTION_STRING}" OFF ADVANCED)
# No need for the user to specify the option explicitly
hpx_option(HPX_WITH_HIP BOOL "${HIP_OPTION_STRING}" OFF ADVANCED)
if("${CMAKE_CXX_COMPILER}" MATCHES "hipcc$")
set(HPX_WITH_HIP
ON
CACHE BOOL "${HIP_OPTION_STRING}" FORCE
)
endif()
if(HPX_WITH_CUDA AND HPX_WITH_HIP)
hpx_error(
"HPX_WITH_CUDA=ON and HPX_WITH_HIP=ON. Only one of them can be on at the same time.\
Note: HPX_WITH_HIP is automatically enabled when compiling with hipcc."
)
endif()
# ##############################################################################
# HPX SYCL configuration
# ##############################################################################
set(SYCL_OPTION_STRING "Enable support for Sycl (default: OFF)")
hpx_option(HPX_WITH_SYCL BOOL "${SYCL_OPTION_STRING}" OFF ADVANCED)
set(SYCL_OPTION_STRING
"Sycl compile flags for selecting specific targets (default: empty)"
)
hpx_option(HPX_WITH_SYCL_FLAGS STRING "${SYCL_OPTION_STRING}" "" ADVANCED)
set(HIPSYCL_OPTION_STRING "Use hipsycl cmake integration (default: OFF)")
hpx_option(HPX_WITH_HIPSYCL BOOL "${HIPSYCL_OPTION_STRING}" OFF ADVANCED)
# ##############################################################################
# pkgconfig file generation
# ##############################################################################
set(HPX_WITH_PKGCONFIG_DEFAULT ON)
if(APPLE
OR MSVC
OR HPX_WITH_CUDA
OR HPX_WITH_HIP
OR HPX_WITH_PARCELPORT_LCI
)
set(HPX_WITH_PKGCONFIG_DEFAULT OFF)
endif()
hpx_option(
HPX_WITH_PKGCONFIG
BOOL
"Enable generation of pkgconfig files (default: ON on Linux without CUDA/HIP, otherwise OFF)"
${HPX_WITH_PKGCONFIG_DEFAULT}
ADVANCED
)
# ##############################################################################
# Threadlevel Nice option
# ##############################################################################
hpx_option(
HPX_WITH_NICE_THREADLEVEL
BOOL
"Set HPX worker threads to have high NICE level (may impact performance) (default: OFF)"
OFF
ADVANCED
)
if(HPX_WITH_NICE_THREADLEVEL)
hpx_info("Nice threadlevel is enabled.")
hpx_add_config_define(HPX_HAVE_NICE_THREADLEVEL)
else()
hpx_info("Nice threadlevel is disabled.")
endif()
# ##############################################################################
# Utility configuration
# ##############################################################################
set(HPX_HIDDEN_VISIBILITY_DEFAULT ON)
if(CMAKE_COMPILER_IS_GNUCXX)
if("${HPX_PLATFORM_UC}" STREQUAL "ANDROID")
set(HPX_HIDDEN_VISIBILITY_DEFAULT OFF)
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(HPX_HIDDEN_VISIBILITY_DEFAULT OFF)
endif()
if(APPLE)
set(HPX_HIDDEN_VISIBILITY_DEFAULT OFF)
endif()
hpx_option(
HPX_WITH_HIDDEN_VISIBILITY
BOOL
"Use -fvisibility=hidden for builds on platforms which support it (default ${HPX_HIDDEN_VISIBILITY_DEFAULT})"
${HPX_HIDDEN_VISIBILITY_DEFAULT}
ADVANCED
)
hpx_option(
HPX_WITH_AUTOMATIC_SERIALIZATION_REGISTRATION
BOOL
"Use automatic serialization registration for actions and functions. This affects compatibility between HPX applications compiled with different compilers (default ON)"
ON
ADVANCED
)
if(HPX_WITH_AUTOMATIC_SERIALIZATION_REGISTRATION)
hpx_add_config_define(HPX_HAVE_AUTOMATIC_SERIALIZATION_REGISTRATION)
endif()
hpx_option(
HPX_WITH_ZERO_COPY_SERIALIZATION_THRESHOLD
STRING
"The threshold in bytes to when perform zero copy optimizations (default: 8192)"
"8192"
ADVANCED
)
hpx_add_config_define(
HPX_ZERO_COPY_SERIALIZATION_THRESHOLD
${HPX_WITH_ZERO_COPY_SERIALIZATION_THRESHOLD}
)
hpx_option(
HPX_WITH_DISABLED_SIGNAL_EXCEPTION_HANDLERS
BOOL
"Disables the mechanism that produces debug output for caught signals and unhandled exceptions (default: OFF)"
OFF
ADVANCED
)
if(HPX_WITH_DISABLED_SIGNAL_EXCEPTION_HANDLERS)
hpx_add_config_define(HPX_HAVE_DISABLED_SIGNAL_EXCEPTION_HANDLERS)
endif()
# Thread Manager related build options
set(HPX_MAX_CPU_COUNT_DEFAULT "")
hpx_option(
HPX_WITH_MAX_CPU_COUNT
STRING
"HPX applications will not use more that this number of OS-Threads (empty string means dynamic) (default: \"${HPX_MAX_CPU_COUNT_DEFAULT}\")"
"${HPX_MAX_CPU_COUNT_DEFAULT}"
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_MAX_CPU_COUNT)
hpx_add_config_define(HPX_HAVE_MAX_CPU_COUNT ${HPX_WITH_MAX_CPU_COUNT})
endif()
if((NOT HPX_WITH_MAX_CPU_COUNT) OR (HPX_WITH_MAX_CPU_COUNT GREATER 64))
hpx_add_config_define(HPX_HAVE_MORE_THAN_64_THREADS)
endif()
set(HPX_MAX_NUMA_DOMAIN_COUNT_DEFAULT "8")
hpx_option(
HPX_WITH_MAX_NUMA_DOMAIN_COUNT
STRING
"HPX applications will not run on machines with more NUMA domains (default: ${HPX_MAX_NUMA_DOMAIN_COUNT_DEFAULT})"
${HPX_MAX_NUMA_DOMAIN_COUNT_DEFAULT}
CATEGORY "Thread Manager"
ADVANCED
)
hpx_add_config_define(
HPX_HAVE_MAX_NUMA_DOMAIN_COUNT ${HPX_WITH_MAX_NUMA_DOMAIN_COUNT}
)
hpx_option(
HPX_WITH_THREAD_STACK_MMAP BOOL
"Use mmap for stack allocation on appropriate platforms" ON
CATEGORY "Thread Manager"
ADVANCED
)
hpx_option(
HPX_WITH_THREAD_MANAGER_IDLE_BACKOFF BOOL
"HPX scheduler threads do exponential backoff on idle queues (default: ON)" ON
CATEGORY "Thread Manager"
ADVANCED
)
hpx_option(
HPX_WITH_STACKTRACES BOOL "Attach backtraces to HPX exceptions (default: ON)"
ON
CATEGORY "Thread Manager"
ADVANCED
)
hpx_option(
HPX_WITH_THREAD_BACKTRACE_ON_SUSPENSION BOOL
"Enable thread stack back trace being captured on suspension (default: OFF)"
OFF
CATEGORY "Thread Manager"
ADVANCED
)
# We create a target to contain libraries like rt, dl etc. in order to remove
# global variables
add_library(hpx_base_libraries INTERFACE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_link_libraries(hpx_base_libraries INTERFACE imf svml irng intlc)
endif()
if(HPX_WITH_STACKTRACES OR HPX_WITH_THREAD_BACKTRACE_ON_SUSPENSION)
hpx_info("Stack traces are enabled.")
hpx_add_config_define(HPX_HAVE_STACKTRACES)
if(WIN32)
target_link_libraries(hpx_base_libraries INTERFACE dbghelp)
endif()
hpx_option(
HPX_WITH_THREAD_BACKTRACE_DEPTH STRING
"Thread stack back trace depth being captured (default: 20)" "20"
CATEGORY "Thread Manager"
ADVANCED
)
hpx_add_config_define(
HPX_HAVE_THREAD_BACKTRACE_DEPTH ${HPX_WITH_THREAD_BACKTRACE_DEPTH}
)
if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
)
# This option is OFF by default as we have seen random segfaults out in the
# wild if this is enabled.
hpx_option(
HPX_WITH_STACKTRACES_STATIC_SYMBOLS BOOL
"Thread stack back trace will resolve static symbols (default: OFF)" OFF
CATEGORY "Thread Manager"
ADVANCED
)
hpx_add_config_define(
HPX_HAVE_STACKTRACES_STATIC_SYMBOLS
${HPX_WITH_STACKTRACES_STATIC_SYMBOLS}
)
# Demangling can segfault in certain configurations.
hpx_option(
HPX_WITH_STACKTRACES_DEMANGLE_SYMBOLS BOOL
"Thread stack back trace symbols will be demangled (default: ON)" ON
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_STACKTRACES_DEMANGLE_SYMBOLS)
hpx_add_config_define(HPX_HAVE_STACKTRACES_DEMANGLE_SYMBOLS)
endif()
endif()
endif()
if(HPX_WITH_THREAD_BACKTRACE_ON_SUSPENSION)
hpx_add_config_define(HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION)
hpx_option(
HPX_WITH_THREAD_FULLBACKTRACE_ON_SUSPENSION BOOL
"Enable thread stack back trace being captured on suspension (default: OFF)"
OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_FULLBACKTRACE_ON_SUSPENSION)
hpx_add_config_define(HPX_HAVE_THREAD_FULLBACKTRACE_ON_SUSPENSION)
endif()
endif()
hpx_option(
HPX_WITH_THREAD_TARGET_ADDRESS BOOL
"Enable storing target address in thread for NUMA awareness (default: OFF)"
OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_TARGET_ADDRESS)
hpx_add_config_define(HPX_HAVE_THREAD_TARGET_ADDRESS)
endif()
hpx_option(
HPX_WITH_THREAD_QUEUE_WAITTIME BOOL
"Enable collecting queue wait times for threads (default: OFF)" OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_QUEUE_WAITTIME)
hpx_add_config_define(HPX_HAVE_THREAD_QUEUE_WAITTIME)
endif()
hpx_option(
HPX_WITH_THREAD_IDLE_RATES
BOOL
"Enable measuring the percentage of overhead times spent in the scheduler (default: OFF)"
OFF
CATEGORY "Thread Manager"
ADVANCED
)
hpx_option(
HPX_WITH_THREAD_CREATION_AND_CLEANUP_RATES BOOL
"Enable measuring thread creation and cleanup times (default: OFF)" OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_IDLE_RATES)
hpx_add_config_define(HPX_HAVE_THREAD_IDLE_RATES)
if(HPX_WITH_THREAD_CREATION_AND_CLEANUP_RATES)
hpx_add_config_define(HPX_HAVE_THREAD_CREATION_AND_CLEANUP_RATES)
endif()
endif()
hpx_option(
HPX_WITH_THREAD_CUMULATIVE_COUNTS
BOOL
"Enable keeping track of cumulative thread counts in the schedulers (default: ON)"
ON
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_CUMULATIVE_COUNTS)
hpx_add_config_define(HPX_HAVE_THREAD_CUMULATIVE_COUNTS)
endif()
hpx_option(
HPX_WITH_THREAD_STEALING_COUNTS
BOOL
"Enable keeping track of counts of thread stealing incidents in the schedulers (default: OFF)"
OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_STEALING_COUNTS)
hpx_add_config_define(HPX_HAVE_THREAD_STEALING_COUNTS)
endif()
hpx_option(
HPX_WITH_COROUTINE_COUNTERS BOOL
"Enable keeping track of coroutine creation and rebind counts (default: OFF)"
OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_COROUTINE_COUNTERS)
hpx_add_config_define(HPX_HAVE_COROUTINE_COUNTERS)
endif()
hpx_option(
HPX_WITH_THREAD_LOCAL_STORAGE BOOL
"Enable thread local storage for all HPX threads (default: OFF)" OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_THREAD_LOCAL_STORAGE)
hpx_add_config_define(HPX_HAVE_THREAD_LOCAL_STORAGE)
endif()
hpx_option(
HPX_WITH_SCHEDULER_LOCAL_STORAGE BOOL
"Enable scheduler local storage for all HPX schedulers (default: OFF)" OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_SCHEDULER_LOCAL_STORAGE)
hpx_add_config_define(HPX_HAVE_SCHEDULER_LOCAL_STORAGE)
endif()
hpx_option(
HPX_WITH_SPINLOCK_POOL_NUM STRING
"Number of elements a spinlock pool manages (default: 128)" 128
CATEGORY "Thread Manager"
ADVANCED
)
hpx_add_config_define(HPX_HAVE_SPINLOCK_POOL_NUM ${HPX_WITH_SPINLOCK_POOL_NUM})
hpx_option(
HPX_WITH_SPINLOCK_DEADLOCK_DETECTION BOOL
"Enable spinlock deadlock detection (default: OFF)" OFF
CATEGORY "Thread Manager"
ADVANCED
)
if(HPX_WITH_SPINLOCK_DEADLOCK_DETECTION)
hpx_add_config_define(HPX_HAVE_SPINLOCK_DEADLOCK_DETECTION)
endif()
# Profiling related build options
hpx_option(
HPX_WITH_APEX BOOL "Enable APEX instrumentation support." OFF
CATEGORY "Profiling"
)
hpx_option(
HPX_WITH_FETCH_APEX
BOOL
"Use FetchContent to fetch APEX. By default an installed APEX will be used. (default: OFF)"
OFF
CATEGORY "Build Targets"
ADVANCED
)
if(HPX_WITH_APEX)
hpx_add_config_define(HPX_HAVE_APEX) # tell HPX that we use APEX
hpx_option(
HPX_WITH_APEX_NO_UPDATE BOOL
"Do not update code from remote APEX repository." OFF CATEGORY "Profiling"
)
hpx_option(
HPX_WITH_APEX_TAG STRING "APEX repository tag or branch" "v2.6.5"
CATEGORY "Profiling"
)
endif()
# Options for automatically fetching Asio
hpx_option(
HPX_WITH_FETCH_ASIO
BOOL
"Use FetchContent to fetch Asio. By default an installed Asio will be used. (default: OFF)"
OFF
CATEGORY "Build Targets"
ADVANCED
)
set(HPX_WITH_ASIO_TAG_DEFAULT "asio-1-21-0")
if(HPX_WITH_HIP)
# newer versions of Asio currently fail when compiled with HIPCC
set(HPX_WITH_ASIO_TAG_DEFAULT "asio-1-16-0")
endif()
hpx_option(
HPX_WITH_ASIO_TAG STRING "Asio repository tag or branch"
${HPX_WITH_ASIO_TAG_DEFAULT}
CATEGORY "Build Targets"
ADVANCED
)
# Option for automatically fetching Hwloc
hpx_option(
HPX_WITH_FETCH_HWLOC
BOOL
"Use FetchContent to fetch Hwloc. By default an installed Hwloc will be used. (default: OFF)"
OFF
CATEGORY "Build Targets"
ADVANCED
)
# cmake-format: off
# LibCDS option
# NOTE: The libcds option is disabled for the 1.5.0 release as it is not ready
# for public consumption yet.
# hpx_option(
# HPX_WITH_LIBCDS BOOL "Enable LibCDS support (experimental)." OFF
# CATEGORY "Thread Manager" ADVANCED
# )