-
Notifications
You must be signed in to change notification settings - Fork 33
/
CMakeLists.txt
2029 lines (1811 loc) · 104 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
####################################################################################################################################
####################################################################################################################################
#### ####
#### ParaMonte: Parallel Monte Carlo and Machine Learning Library. ####
#### ####
#### Copyright (C) 2012-present, The Computational Data Science Lab ####
#### ####
#### This file is part of the ParaMonte library. ####
#### ####
#### LICENSE ####
#### ####
#### https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md ####
#### ####
####################################################################################################################################
####################################################################################################################################
# CMake project file for the ParaMonte library:
#
# WARNING:
# ALL MESSAGE LINES MUST BEGIN WITH A WHITESPACE CHARACTER in CMake.
# This is essential for proper printing of all message.
#
# NOTE:
# A variable reference has the form ${variable_name} and is evaluated inside a Quoted Argument or an Unquoted Argument.
# A variable reference is replaced by the value of the variable, or by the empty string if the variable is not set.
#
# For usage guidelines, see the contents of `CMakeLists.md` file in the root directory of the project.
#
# Commands to build ParaMonte on TACC:
#
# idev -N 1 -n 68 -m 15 # on KNL
# idev -p skx-dev -N 1 -n 48 -t 00:15:00 # on SKX
# cmake .. -DMPI_ENABLED=TRUE -DCFI_ENABLED=TRUE -DDLL_ENABLED=TRUE -DCMAKE_BUILD_TYPE=debug
# cmake ../../.. -Dbuild=release -Dpar=cafdist
# make
# make install
# make deploy
# make test
# make example
# make benchmark
cmake_minimum_required(VERSION 3.18)
#cmake_policy(VERSION 3.10...3.23)
cmake_policy(VERSION 3.10...3.28)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Add our local modules to the module path
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#unset(cmakeFileList)
#file(GLOB cmakeFiles "${CMAKE_MODULE_PATH}/string/*.cmake")
#set(cmakeFileList "${cmakeFileList}" "${cmakeFiles}")
#file(GLOB cmakeFiles "${CMAKE_MODULE_PATH}/string/encoding/*.cmake")
#set(cmakeFileList "${cmakeFileList}" "${cmakeFiles}")
#foreach(cmakeFile ${cmakeFileList})
# message("INCLUDE ${cmakeFile}")
# include(${cmakeFile})
#endforeach(cmakeFile)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Define CMake colors
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
string(ASCII 27 ESC)
set(ColorReset "${ESC}[0m")
set(ColorBold "${ESC}[1m")
set(Red "${ESC}[31m")
set(Green "${ESC}[32m")
set(Yellow "${ESC}[33m")
set(Blue "${ESC}[34m")
set(Magenta "${ESC}[35m")
set(Cyan "${ESC}[36m")
set(White "${ESC}[37m")
set(BoldRed "${ESC}[1;31m")
set(BoldGreen "${ESC}[1;32m")
set(BoldYellow "${ESC}[1;33m")
set(BoldBlue "${ESC}[1;34m")
set(BoldMagenta "${ESC}[1;35m")
set(BoldCyan "${ESC}[1;36m")
set(BoldWhite "${ESC}[1;37m")
set(pmcolor "${BoldCyan}")
set(pmnote " -- ${pmcolor}ParaMonte CMake -${ColorReset}") # This should not be really used anywhere, except in the following.
set(pmattn "${pmnote} ${BoldYellow}NOTE:${ColorReset}")
set(pmwarn "${pmnote} ${BoldMagenta}WARNING:${ColorReset}")
set(pmfatal "${pmnote} ${BoldRed}FATAL ERROR:${ColorReset}")
set(passed "${BoldGreen}PASSED${ColorReset}")
set(failed "${BoldRed}FAILED${ColorReset}")
set(found "${BoldGreen}FOUND${ColorReset}")
set(missing "${BoldMagenta}MISSING${ColorReset}")
function(printUsage)
file(READ "${CMAKE_SOURCE_DIR}/CMakeLists.md" paramonte_cmake_usage)
message("\n${pmnote} CMake Usage Guidelines:${ColorReset}\n")
message("${paramonte_cmake_usage}")
endfunction()
#function(message)
# list(GET ARGV 0 MessageType)
# if(MessageType STREQUAL FATAL_ERROR OR MessageType STREQUAL SEND_ERROR)
# list(REMOVE_AT ARGV 0)
# _message(${MessageType} "${BoldRed}${ARGV}${ColourReset}")
# elseif(MessageType STREQUAL WARNING)
# list(REMOVE_AT ARGV 0)
# _message(${MessageType} "${BoldYellow}${ARGV}${ColourReset}")
# elseif(MessageType STREQUAL AUTHOR_WARNING)
# list(REMOVE_AT ARGV 0)
# _message(${MessageType} "${BoldCyan}${ARGV}${ColourReset}")
# elseif(MessageType STREQUAL STATUS)
# list(REMOVE_AT ARGV 0)
# _message(${MessageType} "${Green}${ARGV}${ColourReset}")
# else()
# _message("${ARGV}")
# endif()
#endfunction()
macro(setSubDirList result current_dir)
file(GLOB children RELATIVE ${current_dir} ${current_dir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${current_dir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
# Assign logical variable to the result of the input expression.
macro(setBool var)
if(${ARGN})
set(${var} ON)
else()
set(${var} OFF)
endif()
endmacro()
# Convert file contents into a CMake list (where each element in the list is one line of the file).
#
# WARNING
#
# there are two caveats wherein this macro does not work as intended:
#
# (1) It puts each line of the (presumed to be text) file into an element of a
# cmake list including empty lines as unique elements... However, if you are
# familiar with cmake lists at all, you'll instantly say to yourself -- "ah
# ha, so blank lines will be skipped in a FOREACH loop." True : caveat #1 :
# blank lines are undetectable in a cmake FOREACH structure. But the non-blank
# lines are usually the important ones... so skipping the blank ones is
# probably ok... depends on your task, I suppose.
#
# (2) It does not handle trailing backslashes at the end of a line
# "correctly." It will end up with consecutive lines with trailing backslashes
# all put together as one line in the cmake list. caveat #2 : you'll need to
# do more work if you want to detect trailing backslashes and get lines
# including those stuffed into a cmake list properly
#
# Other than that, it's quite useful and works with CMake 2.4.6 (probably
# earlier versions, too, but most of my experience using this technique has
# been with 2.4.6.)
macro(setLineList filepath lineList)
file(READ "${filepath}" ${lineList})
string(REGEX REPLACE ";" "\\\\;" ${lineList} "${${lineList}}")
string(REGEX REPLACE "\n" ";" ${lineList} "${${lineList}}")
endmacro()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set the default for development mode environment.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (NOT DEFINED dev_enabled)
set(dev_enabled 0)
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set CMake verbosity level.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (NOT DEFINED VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "CMake Verbosity level." FORCE)
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Print an error message on an attempt to build inside the source directory tree:
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if ("${lib}" STREQUAL "")
set(lib "shared" CACHE STRING "ParaMonte library type: shared, static" FORCE)
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Print an error message on an attempt to build inside the source directory tree:
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
printUsage()
if (WIN32)
set(delfiles "del /F CMakeCache.txt; rmdir /Q /s CMakeFiles")
else()
set(delfiles "rm -rf CMakeCache.txt CMakeFiles/")
endif()
message(FATAL_ERROR
"\n"
"${pmfatal} CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}\n"
"${pmfatal} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}\n"
"\n"
"${pmfatal} This archive does not support in-source builds.\n"
"\n"
"${pmfatal} You must now delete the CMakeCache.txt file and the CMakeFiles/ directory under\n"
"${pmfatal} in the ParaMonte library's root directory, otherwise you will not be able to configure correctly.\n"
"${pmfatal} You must now run something like:\n"
"\n"
"${pmfatal} ${delfiles}\n"
"\n"
"${pmfatal} Please create a directory wither inside or outside the ParaMonte library source tree, \n"
"${pmfatal} change the directory to it, and build in this directory, in a manner such as the following,\n"
"\n"
)
endif()
if(DEFINED ENV{SOURCE_DATE_EPOCH})
set(SOURCE_DATE_EPOCH "$ENV{SOURCE_DATE_EPOCH}")
endif()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Display ParaMonte Banner
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
file(READ "${CMAKE_CURRENT_LIST_DIR}/src/auxil/.paramonte.banner" paramonte_banner)
message("\n${pmcolor}${paramonte_banner}${ColorReset}\n")
unset(paramonte_banner)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#: set the dependency packaging requirement. This is not used anymore as of version 2.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set(DEPS_ENABLED 0)
if(DEFINED deps)
message(NOTICE "${pmattn} deps=${deps}")
string(TOLOWER "${deps}" deps)
if("${deps}" STREQUAL "all")
set(DEPS_ENABLED 1)
endif()
endif()
message(NOTICE "${pmattn} DEPS_ENABLED=${DEPS_ENABLED}")
unset(deps)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#: set the required root directories.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
message(NOTICE "${pmattn} setting up the ParaMonte directory hierarchy...")
message(NOTICE "${pmattn} project root directory: ${CMAKE_SOURCE_DIR}")
# define paramonte_dir as CMAKE_SOURCE_DIR
set(paramonte_dir "${CMAKE_SOURCE_DIR}")
set(paramonte_ext_dir "${paramonte_dir}/external")
set(paramonte_ext_obl_dir "${paramonte_dir}/external/OpenBLAS")
set(paramonte_example_dir "${paramonte_dir}/example" CACHE PATH "ParaMonte example source files directory")
set(paramonte_benchmark_dir "${paramonte_dir}/benchmark" CACHE PATH "ParaMonte benchmark source files directory")
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# set the ParaMonte source files directory
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set(paramonte_src_dir "${CMAKE_SOURCE_DIR}/src" CACHE PATH "ParaMonte interface directory")#/interface
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#: Set the ParaMonte other-language source files directory and loop over them to ensure their existence.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
set(list_lang c cpp fortran go java julia mathematica matlab python r)
if (EXISTS "${paramonte_src_dir}/")
message(NOTICE "${pmattn} Interface source files directory: ${paramonte_src_dir}")
foreach(item ${list_lang}) # WARNING: lang cannot be used as loop variable because it is already used as an input variable to CMake.
set(paramonte_src_${item}_dir "${paramonte_src_dir}/${item}" CACHE PATH "ParaMonte ${item} source files directory.")
if (EXISTS "${paramonte_src_${item}_dir}/")
message(NOTICE "${pmattn} Checking the existence of ${paramonte_src_${item}_dir} ... ${found}")
set(paramonte_src_${item}_main_dir "${paramonte_src_${item}_dir}/main" CACHE PATH "ParaMonte ${item} main source files directory.")
set(paramonte_src_${item}_test_dir "${paramonte_src_${item}_dir}/test" CACHE PATH "ParaMonte ${item} test source files directory.")
set(paramonte_src_${item}_test_input_dir "${paramonte_src_${item}_test_dir}/input" CACHE PATH "ParaMonte ${item} test input source files directory.")
else()
message(NOTICE "${pmattn} Checking the existence of ${paramonte_src_${item}_dir} ... ${missing}")
endif()
set(collections "benchmark" "example")
foreach(collection in ${collections})
set(paramonte_${collection}_${item}_dir "${paramonte_${collection}_dir}/${item}" CACHE PATH "ParaMonte ${item} ${collection} files directory.")
if (EXISTS "${paramonte_${collection}_${item}_dir}/")
message(NOTICE "${pmattn} Checking the existence of ${paramonte_${collection}_${item}_dir} ... ${found}")
else()
message(NOTICE "${pmattn} Checking the existence of ${paramonte_${collection}_${item}_dir} ... ${missing}")
endif()
endforeach()
endforeach()
else()
message(FATAL_ERROR
"\n"
"${pmfatal} The ParaMonte interface source directories does not exist.\n"
"${pmfatal} The integrity of the ParaMonte library is compromised.\n"
"${pmfatal} Clone the ParaMonte library from GitHub and retry:\n"
"\n"
" https://github.com/cdslaborg/paramonte\n"
"\n"
)
endif()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#: Set and generate the required build and binary installation directories.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if (DEFINED fresh)
string(TOLOWER "${fresh}" fresh)
endif()
message(NOTICE "${pmattn} Setting up the ParaMonte build directories...")
#if (DEFINED bdir)
# message(NOTICE "${pmattn} User-specified ParaMonte build directory detected. bdir=\"${bdir}\"")
#else()
# set(bdir "${CMAKE_SOURCE_DIR}/bld/${os}/${arch}/${csid}/${CMAKE_Fortran_COMPILER_VERSION}/${build}/${lib}/${mem}/${par}/${lang}")
# message(NOTICE "${pmattn} Defining and generating the ParaMonte build directory: bdir=\"${bdir}\"")
# set(ENV{bdir} "${bdir}")
# #set(paramonte_bld_dir "${CMAKE_BINARY_DIR}/${csid}/${CMAKE_Fortran_COMPILER_VERSION}/${CMAKE_BUILD_TYPE}/${LTYPE}/${PARALLELISM_DIR}")
# #set(paramonte_bld_dir "${CMAKE_BINARY_DIR}")
#endif()
set(bdir "${CMAKE_BINARY_DIR}")
set(paramonte_bld_dir "${bdir}")
set(ENV{paramonte_bld_dir} "${paramonte_bld_dir}")
set(CMAKE_INSTALL_PREFIX "${paramonte_bld_dir}" CACHE BOOL "ParaMonte/OpenBLAS/dependencies install directory prefix." FORCE)
message(NOTICE "${pmattn} All build files will be stored at paramonte_bld_dir=\"${paramonte_bld_dir}\"")
#### Purge files or folders within the build folder if requested.
file(GLOB bld_dir_items LIST_DIRECTORIES true RELATIVE "${paramonte_bld_dir}" "${paramonte_bld_dir}/*")
message(NOTICE "${pmattn} The current contents of the ParaMonte build directory: \"${bld_dir_items}\"")
message(NOTICE "${pmattn} Purging any requested contents prior to the ParaMonte library build...")
if (NOT "${fresh}" STREQUAL "none" AND NOT "${fresh}" STREQUAL "")
foreach(fitem ${fresh})
set (purge_failed 1)
if ("${fitem}" MATCHES ".*[\.][\.].*")
message(NOTICE "${pmwarn} Purging parent-level or higher folders and objects are impossible: \"${fitem}\"")
elseif ("${fitem}" STREQUAL "bdir" OR "${fitem}" STREQUAL "all")
message(NOTICE "${pmattn} Purging the entire ParaMonte library build directory: \"${paramonte_bld_dir}/\"")
foreach(bld_dir_item ${bld_dir_items})
file(REMOVE_RECURSE "${paramonte_bld_dir}/${bld_dir_item}")
endforeach()
set (purge_failed 0)
elseif (NOT "${fitem}" STREQUAL "ddir") # This will be taken care of later.
unset(dirsep)
if ("${fitem}" MATCHES ".*[/].*")
set(dirsep "/")
elseif ("${fitem}" MATCHES ".*[\\].*")
set(dirsep "\\")
endif()
if (DEFINED dirsep)
list(GET fitems 0 fitems1)
list(GET fitems 1 fitems2)
if(IS_DIRECTORY "${paramonte_bld_dir}/${fitems1}")
set(purge_path "${paramonte_bld_dir}/${fitems1}/${fitems2}")
message(NOTICE "${pmattn} Purging the build sub-subdirectory: \"${purge_path}/\"")
file(REMOVE_RECURSE "${purge_path}")
set (purge_failed 0)
endif()
else()
set(purge_path "${paramonte_bld_dir}/${fitem}")
message(NOTICE "${pmattn} Purging the build subdirectory: \"${purge_path}/\"")
file(REMOVE_RECURSE "${purge_path}")
set (purge_failed 0)
endif()
endif()
if (purge_failed)
message(NOTICE "${pmwarn} Nonexistent or unrecognized pattern to remove from the current build: \"${fitem}\"")
endif()
endforeach()
endif()
set(subdir_list benchmark example inc lib obj pkg)
foreach(subdir ${subdir_list})
set(paramonte_bld_${subdir}_dir "${paramonte_bld_dir}/${subdir}")
message(NOTICE "${pmattn} paramonte_bld_${subdir}_dir: ${paramonte_bld_${subdir}_dir}")
if (NOT EXISTS "${paramonte_bld_${subdir}_dir}/")
file(MAKE_DIRECTORY "${paramonte_bld_${subdir}_dir}")
elseif ("${fresh}" MATCHES ".*${subdir}.*")
file(REMOVE_RECURSE "${paramonte_bld_${subdir}_dir}/")
file(MAKE_DIRECTORY "${paramonte_bld_${subdir}_dir}")
endif()
endforeach()
# paramonte_bld_pkg_dir must be created before calling the library target file.
set(paramonte_bld_pkg_benchmark_dir "${paramonte_bld_pkg_dir}/benchmark")
set(paramonte_bld_pkg_example_dir "${paramonte_bld_pkg_dir}/example")
set(paramonte_bld_pkg_fpp_dir "${paramonte_bld_pkg_dir}/fpp")
set(paramonte_bld_pkg_lib_dir "${paramonte_bld_pkg_dir}/lib")
set(paramonte_bld_pkg_inc_dir "${paramonte_bld_pkg_dir}/inc")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#: Set the default performance profiling option.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set(perfprof_enabled FALSE)
if ("${perfprof}" MATCHES "[Aa][Ll][Ll]")
set(perfprof_enabled TRUE)
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#: Set the code coverage preprocessor flag.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (DEFINED test)
string(TOLOWER "${test}" test)
endif()
if ("${test}" STREQUAL "all")
if (NOT "${mod}" STREQUAL "" AND NOT "${mod}" STREQUAL "all")
message(WARNING
"\n"
"${pmwarn} Specifying `all` for the value of build configuration option `test`\n"
"${pmwarn} requires setting the build configuration option `mod` also to `all`.\n"
"${pmwarn} You have specified `-Dmod=${mod}`.\n"
"${pmwarn} Resetting `mod` to `all`...\n"
"\n"
)
set(mod "all" CACHE STRING "modules to compiler." FORCE)
endif()
endif()
set(codecov_enabled FALSE)
if("${codecov}" MATCHES "[Aa][Ll][Ll]")
add_compile_definitions("CODECOV_ENABLED=1")
set(codecov_enabled TRUE)
if (NOT DEFINED test)# OR "${test}" STREQUAL "none"
set(test "all")
endif()
if (NOT DEFINED checking)
set(checking "all")
endif()
endif()
if (DEFINED fpp)
string(TOLOWER "${fpp}" fpp)
endif()
if (codecov_enabled)
if ("${fpp}" STREQUAL "all")
if (NOT "${fpp}" STREQUAL "" AND NOT "${fpp}" STREQUAL "all")
message(WARNING
"\n"
"${pmwarn} Specifying `all` for the value of build configuration option `test`\n"
"${pmwarn} requires setting the build configuration option `fpp` also to `all`.\n"
"${pmwarn} You have specified `-Dfpp=${fpp}`.\n"
"${pmwarn} Resetting `fpp` to `all`...\n"
"\n"
)
set(fpp "all" CACHE "Fortran preprocessing rule." FORCE)
endif()
endif()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Predefine the build mode. This must be done before calling project() or enable_language().
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include(presetParaMonteBuild) # Predefines `CMAKE_BUILD_TYPE` and `CMAKE_CONFIGURATION_TYPES` based on the user choice `build`.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Preset the desired compiler suite. This must be done before calling project() or enable_language().
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include(presetParaMonteCompiler) # Predefines `CMAKE_Fortran_COMPILER` based on the user choice `fc`.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Specify source languages and standards.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
message(NOTICE "${pmattn} Build from git repository detected.")
endif()
message(NOTICE "${pmattn} CMake executable path: ${CMAKE_COMMAND}")
message(NOTICE "${pmattn} ParaMonte root directory: ${CMAKE_CURRENT_SOURCE_DIR}")
# Languages are enabled by the project() command.
# Language-specific built-in variables, such as CMAKE_CXX_COMPILER, CMAKE_CXX_COMPILER_ID etc are set by invoking `project()`.
# An implicit `project()` command will be automatically generated if no project command is in the top-level CMakeLists file.
set(CMAKE_Fortran_STANDARD 2008)
set(CMAKE_SHARED_LIBRARY_PREFIX_Fortran "") # The default is `lib`.
set(CMAKE_STATIC_LIBRARY_PREFIX_Fortran "") # The default is `lib`.
enable_language(Fortran) # Fortran C CXX # redundant
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Reset the compiler suite name variable `CMAKE_Fortran_COMPILER_ID` if undefined. This must be done after project initiation.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if (NOT DEFINED CMAKE_Fortran_COMPILER_ID OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "")
#set(csid "${CMAKE_Fortran_COMPILER_ID}" CACHE STRING "CMAKE_Fortran_COMPILER_ID suite" FORCE)
message(WARNING
"\n"
"${pmwarn} The CMake Compiler Suite variable is undefined. CMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}\n"
"${pmwarn} This name is required for naming the output binary. skipping...\n"
"\n"
)
if ("${CMAKE_Fortran_COMPILER}" MATCHES "ifort" OR "${CMAKE_Fortran_COMPILER_ID}" MATCHES "intel")
set(CMAKE_Fortran_COMPILER_ID "Intel")
elseif("${CMAKE_Fortran_COMPILER}" MATCHES "gfortran" OR "${CMAKE_Fortran_COMPILER_ID}" MATCHES "gnu")
set(CMAKE_Fortran_COMPILER_ID "GNU")
endif()
endif()
set(csid_is_gnu FALSE)
set(csid_is_intel FALSE)
if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "[Ii][Nn][Tt][Ee][Ll]")
set(csid_is_intel TRUE)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "[Gg][Nn][Uu]")
set(csid_is_gnu TRUE)
else()
message(WARNING
"\n"
"${pmwarn} \n"
"${pmwarn} The compiler choice to build the ParaMonte library is unsupported and untested:\n"
"${pmwarn} CMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}\n"
"${pmwarn} CMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}\n"
"${pmwarn} Currently, only the Intel and the GNU compiler suites are officially supported\n"
"${pmwarn} for building the ParaMonte library. You can specify either of these compiler suites\n"
"${pmwarn} by providing their names or path to their executables to cmake as arguments\n"
"${pmwarn} \n"
"${pmwarn} -Dfc=ifort\n"
"${pmwarn} \n"
"${pmwarn} or\n"
"${pmwarn} \n"
"${pmwarn} -Dfc=ifort\n"
"${pmwarn} \n"
"${pmwarn} Proceeding without any guarantee of build success. You are now in an uncharted territory.\n"
"${pmwarn} Please report any failures to: https://github.com/cdslaborg/paramonte/issues/new/choose\n"
"\n"
)
endif()
if (${csid_is_gnu} OR ${csid_is_intel})
#set(CMAKE_C_FLAGS_INIT "")
#set(CMAKE_C_FLAGS_DEBUG_INIT "")
#set(CMAKE_C_FLAGS_RELEASE_INIT "")
#set(CMAKE_CXX_FLAGS_INIT "")
#set(CMAKE_CXX_FLAGS_DEBUG_INIT "")
#set(CMAKE_CXX_FLAGS_RELEASE_INIT "")
set(CMAKE_Fortran_FLAGS "")
set(CMAKE_Fortran_FLAGS_DEBUG "")
set(CMAKE_Fortran_FLAGS_RELEASE "")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "")
set(CMAKE_Fortran_FLAGS_INIT "")
set(CMAKE_Fortran_FLAGS_DEBUG_INIT "")
set(CMAKE_Fortran_FLAGS_RELEASE_INIT "")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "")
endif()
set(csid "${CMAKE_Fortran_COMPILER_ID}")
string(TOLOWER "${csid}" csid)
message(NOTICE "${pmattn} CMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}")
message(NOTICE "${pmattn} CMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}")
message(NOTICE "${pmattn} CMAKE_Fortran_COMPILER_VERSION=${CMAKE_Fortran_COMPILER_VERSION}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set CMAKE_Fortran_COMPILER_VERSION if CMake doesn't do it for us. This must happen after calling project().
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
# This script defines the following variables:
# `CMAKE_Fortran_COMPILER_VERSION` (if undefined already): the full version of the compiler in `major[.minor[.patch[.tweak]]]` format.
include(setParaMonteCompilerVersion)
# We have populated CMAKE_Fortran_COMPILER_VERSION if it was missing.
# Now extract the compiler major version.
if (
(${csid_is_gnu} AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.3.0)) OR
(${csid_is_intel} AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 21.0.0))
)
message(FATAL_ERROR
"\n"
"${pmfatal} Building ParaMonte minimally requires either:\n"
"${pmfatal} \n"
"${pmfatal} 1. GNU Fortran compiler version 11.0.0 or newer.\n"
"${pmfatal} 2. Intel Fortran compiler version 21.0.0 or newer.\n"
"${pmfatal} \n"
"${pmfatal} Please install one of the above two comiler suites and rebuild.\n"
"\n"
)
else()
if (NOT (${csid_is_gnu} OR ${csid_is_intel}))
message(WARNING
"\n"
"${pmwarn} Untested Fortran compiler version.\n"
"${pmwarn} The ParaMonte library is currently only tested with the following compilers:\n"
"${pmwarn} \n"
"${pmwarn} 1. GNU Fortran compiler version 11.0.0 or newer.\n"
"${pmwarn} 2. Intel Fortran compiler version 21.0.0 or newer\n"
"${pmwarn} \n"
"${pmwarn} The build will proceed with no guarantee of success...\n"
"${pmwarn} \n"
"\n"
)
endif()
string(REPLACE "." ";" COMPILER_VERSION_LIST ${CMAKE_Fortran_COMPILER_VERSION})
list(GET COMPILER_VERSION_LIST 0 COMPILER_VERSION_MAJOR)
unset(COMPILER_VERSION_LIST)
message(NOTICE "${pmattn} COMPILER_VERSION_MAJOR=${COMPILER_VERSION_MAJOR}")
endif()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Test modern/Coarray Fortran compiler awareness.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include(testParaMonteCompiler)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set the processor architecture.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
# CMAKE_HOST_SYSTEM_PROCESSOR:
#
# On Windows, the value of the PROCESSOR_ARCHITECTURE environment variable is used.
# The options are: AMD64, IA64, ARM64, EM64T, X86. Source: this SuperUser answer.
#
# On macOS, the value of uname -m is used by default.
# However, since this might vary based on whether you're using x86 or ARM CMake, version 3.19.2+ will use the value of CMAKE_APPLE_SILICON_PROCESSOR instead, if it is set.
# It also normalizes Power Macintosh to powerpc. The possible values here are x86_64, arm64, and powerpc.
#
# Note that CMake will use the value of CMAKE_HOST_SYSTEM_PROCESSOR (and CMAKE_SYSTEM_NAME) for a number of tasks (one should not change its value):
#
# -# The default value of CPACK_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}.
# -# The language modules Modules/CMake<LANG>Information.cmake all optionally include platform modules suffixed with -${CMAKE_SYSTEM_PROCESSOR}.cmake.
# In most cases, no such modules exist. On Android, very many platform modules exist with processor-specific variants.
# -# The FindJNI module uses it to guide its search.
# -# It is passed to ARMClang via --mcpu (compile) and --cpu (link).
#
if (
"${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "x64" OR
"${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR
"${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR
"${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "[Xx]86[_-]64" # [_-] must have - as the last character.
)
set(arch "amd64")
else()
set(arch "${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
string(TOLOWER ${arch} arch)
message(NOTICE "${pmattn} Building for target architecture: ${arch}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Silence warnings about dereferencing unset variables.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if(NOT CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_FLAGS "")
endif()
if(NOT CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES "")
endif()
if(NOT CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_INCLUDES "")
endif()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Predefine the blas/lapack mode. This must be done before calling project() or enable_language().
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# WARNING
# No generic-target compile definition must be added above this line.
# Though generally harmless, the definitions will leak to OpenBLAS build.
if (TRUE)
# Set up BLAS / LAPACK requirements.
set(BLAS_REQUIRED 0)
if (DEFINED blas AND NOT "${blas}" MATCHES "[nN][oO][nN][eE]" AND NOT "${blas}" MATCHES "[Dd][Ee][Ff][Aa][Uu][Ll][Tt]")
set(BLAS_REQUIRED 1)
endif()
set(LAPACK_REQUIRED 0)
if (DEFINED lapack AND NOT "${lapack}" MATCHES "[nN][oO][nN][eE]" AND NOT "${lapack}" MATCHES "[Dd][Ee][Ff][Aa][Uu][Ll][Tt]")
set(LAPACK_REQUIRED 1)
endif()
# Build the OpenBLAS source library if it exists and no other blas library is enabled.
set(BLAS_ENABLED 0)
set(LAPACK_ENABLED 0)
set(OpenBLAS_ENABLED 0)
if (EXISTS "${paramonte_ext_obl_dir}/") # This is source directory of OpenBLAS # "${blas}" MATCHES "[Oo][Pp][eE][nN][Bb][Ll][Aa][Ss]" OR "${lapack}" MATCHES "[Oo][Pp][eE][nN][Bb][Ll][Aa][Ss]"
if (BLAS_REQUIRED OR LAPACK_REQUIRED)
message(NOTICE "${pmwarn} A requested BLAS library is already enabled, while OpenBLAS source is detected in the project root directory. Skipping OpenBLAS source build...")
message(NOTICE "${pmwarn} lapack=${lapack}")
message(NOTICE "${pmwarn} blas=${blas}")
elseif ("${blas}" MATCHES "[Dd][Ee][Ff][Aa][Uu][Ll][Tt]") # default to local OpenBLAS project build.
# Full list of options at: https://github.com/xianyi/OpenBLAS/blob/develop/Makefile.rule
if (FALSE)
# Always build OpenBLAS as static position-independent library.
# This is likely what we want to do for non-compiled languages.
set(BUILD_STATIC_LIBS 1 CACHE BOOL "OpenBLAS no static library." FORCE)
set(BUILD_SHARED_LIBS 0 CACHE BOOL "OpenBLAS no shared library." FORCE)
elseif ("${lib}" MATCHES "[Dd][Yy][Nn][Aa][Mm][Ii][Cc]" OR "${lib}" MATCHES "[sS][hH][aA][rR][eE][dD]") # DLL_ENABLED
set(BUILD_STATIC_LIBS 0 CACHE BOOL "OpenBLAS no static library." FORCE)
set(BUILD_SHARED_LIBS 1 CACHE BOOL "OpenBLAS no shared library." FORCE)
else()
set(BUILD_STATIC_LIBS 1 CACHE BOOL "OpenBLAS no static library." FORCE)
set(BUILD_SHARED_LIBS 0 CACHE BOOL "OpenBLAS no shared library." FORCE)
endif()
set(NO_CBLAS 1 CACHE BOOL "OpenBLAS No CBLAS." FORCE)
set(NO_LAPACKE 1 CACHE BOOL "OpenBLAS no C-LAPACK." FORCE)
if (NOT DEFINED DYNAMIC_ARCH)
set(DYNAMIC_ARCH 0 CACHE BOOL "OpenBLAS multiple dispatch." FORCE)
endif()
#set(USE_THREAD ${OMP_ENABLED} CACHE BOOL "OpenBLAS threading." FORCE)
set(USE_THREAD 1 CACHE BOOL "OpenBLAS threading." FORCE)
# The following install prefix is now set globally for the entire project.
#set(CMAKE_INSTALL_PREFIX "${paramonte_bld_dir}" CACHE BOOL "OpenBLAS install directory." FORCE)
# setup openblas files directory
set(paramonte_bld_obl_dir "${paramonte_bld_dir}/obl")
message(NOTICE "${pmattn} paramonte_bld_obl_dir: ${paramonte_bld_obl_dir}")
if (NOT EXISTS "${paramonte_bld_obl_dir}/")
file(MAKE_DIRECTORY "${paramonte_bld_obl_dir}")
elseif ("${fresh}" MATCHES ".*obl.*" OR "${fresh}" MATCHES ".*openblas.*")
file(REMOVE_RECURSE "${paramonte_bld_obl_dir}/")
endif()
add_subdirectory("${paramonte_ext_obl_dir}" "${paramonte_bld_obl_dir}")
set(OpenBLAS_ENABLED 1)
set(LAPACK_ENABLED 1)
set(BLAS_ENABLED 1)
endif()
endif()
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# set the target language.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
set(C_ENABLED 0)
set(CPP_ENABLED 0)
set(FORTRAN_ENABLED 0)
set(GO_ENABLED 0)
set(JAVA_ENABLED 0)
set(JULIA_ENABLED 0)
set(MATHEMATICA_ENABLED 0)
set(MATLAB_ENABLED 0)
set(PYTHON_ENABLED 0)
set(R_ENABLED 0)
set(lang_is_dynamic 1)
string(TOLOWER "${lang}" lang)
if ("${lang}" STREQUAL "c" OR "${lang}" STREQUAL "C")
set(lang_is_dynamic 0)
set(lang_ext ".c")
set(C_ENABLED 1)
elseif ("${lang}" MATCHES "[Cc][XxPp+][XxPp+]")
set(lang_is_dynamic 0)
set(lang_ext ".cpp")
set(CPP_ENABLED 1)
set(lang "cpp")
elseif ("${lang}" MATCHES "[Cc]#" OR "${lang}" MATCHES "[Cc][sS][hH][aA][rR][pP]")
set(lang_is_dynamic 0)
set(CSHARP_ENABLED 1)
set(lang_ext ".cs")
set(lang "csharp")
elseif ("${lang}" MATCHES "[Ff][Oo][Rr][Tt][Rr][Aa][Nn]")
set(lang_is_dynamic 0)
set(FORTRAN_ENABLED 1)
set(lang_ext ".F90")
elseif ("${lang}" MATCHES "[Gg][Oo]")
set(lang_ext ".go")
set(GO_ENABLED 1)
elseif ("${lang}" MATCHES "[Jj][Aa][Vv][Aa]")
set(lang_ext ".java")
set(JAVA_ENABLED 1)
elseif ("${lang}" MATCHES "[Jj][Uu][Ll][Ii][Aa]")
set(JULIA_ENABLED 1)
set(lang_ext ".jl")
elseif ("${lang}" MATCHES "[mM][aA][tT][hH][eE][mM][aA][tT][iI][cC][aA]")
set(MATHEMATICA_ENABLED 1)
set(lang_ext ".wls")
elseif ("${lang}" MATCHES "[mM][aA][tT][lL][aA][bB]")
set(MATLAB_ENABLED 1)
set(lang_ext ".m")
elseif ("${lang}" MATCHES "[pP][yY][tT][hH][oO][nN]")
set(PYTHON_ENABLED 1)
set(lang_ext ".py")
elseif ("${lang}" STREQUAL "R" OR "${lang}" STREQUAL "r")
set(lang_ext ".R")
set(R_ENABLED 1)
elseif ("${lang}" MATCHES "[rR][uU][sS][tT]")
set(RUST_ENABLED 1)
set(lang_ext ".rs")
elseif ("${lang}" MATCHES "[sS][aA][sS]")
set(lang_ext ".sas")
set(SAS_ENABLED 1)
elseif ("${lang}" MATCHES "[sS][wW][iI][fF][tT]")
set(lang_ext ".swift")
set(SWIFT_ENABLED 1)
elseif (NOT DEFINED lang OR "${lang}" STREQUAL "")
set(FORTRAN_ENABLED 1)
set(lang_ext ".F90")
set(lang "fortran")
message(NOTICE
"${pmwarn} Unspecified target language. You can set the target language via -Dlang=target_lang\n"
"${pmwarn} where `target_lang` is the name of the target language as written most commonly.\n"
"${pmwarn} Defaulting to `${lang}` as the target language of choice."
)
else()
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} The user-specified target language is unsupported. lang=${lang}\n"
"${pmfatal} See the above usage notes for the possible choices.\n"
"\n"
)
endif()
add_compile_definitions("C_ENABLED=${C_ENABLED}")
add_compile_definitions("CPP_ENABLED=${CPP_ENABLED}")
add_compile_definitions("FORTRAN_ENABLED=${FORTRAN_ENABLED}")
add_compile_definitions("GO_ENABLED=${GO_ENABLED}")
add_compile_definitions("JAVA_ENABLED=${JAVA_ENABLED}")
add_compile_definitions("JULIA_ENABLED=${JULIA_ENABLED}")
add_compile_definitions("MATHEMATICA_ENABLED=${MATHEMATICA_ENABLED}")
add_compile_definitions("MATLAB_ENABLED=${MATLAB_ENABLED}")
add_compile_definitions("PYTHON_ENABLED=${PYTHON_ENABLED}")
add_compile_definitions("R_ENABLED=${R_ENABLED}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Enable or disable the Parameterized Derived Type interface. This is important as GNU gfortran as of 13.2 does not support PDTs.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if (DEFINED pdt) # anything other than 0, N, NO, or FALSE
if ("${pdt}" MATCHES "[Aa][Ll][Ll]")
set(PDT_ENABLED 1)
else()
set(PDT_ENABLED 0)
endif()
elseif (${csid_is_gnu})
set(PDT_ENABLED 0)
elseif (${csid_is_intel})
set(PDT_ENABLED 0)
else()
set(PDT_ENABLED 0)
endif()
add_compile_definitions("PDT_ENABLED=${PDT_ENABLED}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set the C-Fortran interoperability. Enable C-Fortran interoperability (required to call ParaMonte from non-Fortran languages)
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if (DEFINED cfi)
message(NOTICE "${pmattn} cfi=${cfi}")
string(TOLOWER ${cfi} cfi)
endif()
if ("${cfi}" STREQUAL "all")
set(CFI_ENABLED 1)
elseif ("${cfi}" STREQUAL "none") # The only target language can be Fortran.
if (NOT FORTRAN_ENABLED)
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} The user-specified C-Fortran Interoperability (cfi=${cfi})\n"
"${pmfatal} evaluates to FALSE which is inconsistent with the target language.\n"
"${pmfatal} Set this option according to the guidelines above or drop it.\n"
"\n"
)
endif()
set(CFI_ENABLED 0)
elseif (DEFINED cfi)
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} Unrecognized specified value for the `cfi` C-Fortran Interoperability flag (cfi=${cfi})\n"
"${pmfatal} See the above documentation for possible usage.\n"
"\n"
)
elseif (FORTRAN_ENABLED) # cfi is undefined.
set(CFI_ENABLED 0)
else() # for all other target languages.
set(CFI_ENABLED 1)
endif()
add_compile_definitions("CFI_ENABLED=${CFI_ENABLED}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Define the library linking type. This must happen after the choice of target language.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
# shared: Use this flag when you have R/Python/MATLAB/Julia code to which you need to link the ParaMonte library dynamically, using DLL files.
# static: Use this flag when you have Fortran/C/C++ code to which you want to link the ParaMonte library statically.
# You can also link dynamically your Fortran/C/C++ codes using DLL files by specifying LTYPE=shared flag instead.
unset(DLL_ENABLED) # If not set below, it will be set automatically based on the
if ("${lib}" MATCHES "[Dd][Yy][Nn][Aa][Mm][Ii][Cc]" OR "${lib}" MATCHES "[sS][hH][aA][rR][eE][dD]")
set(DLL_ENABLED 1)
elseif ("${lib}" MATCHES "[sS][tT][aA][tT][iI][cC]")
if (NOT (C_ENABLED OR CPP_ENABLED OR FORTRAN_ENABLED))
#printUsage()
message(NOTICE
"${pmwarn} The user-specified library build (lib=${lib})\n"
"${pmwarn} can be specified only with C, C++, and Fortran programming languages.\n"
"${pmwarn} The library build for all other (dynamic) languages has to be `shared`."
)
endif()
set(DLL_ENABLED 0)
elseif (DEFINED lib)
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} The user-specified library build is unsupported. lib=${lib}\n"
"${pmfatal} See the above usage notes for the possible choices.\n"
"\n"
)
elseif (C_ENABLED OR CPP_ENABLED OR FORTRAN_ENABLED)
set(DLL_ENABLED 0)
else()
set(DLL_ENABLED 1)
endif()
add_compile_definitions("DLL_ENABLED=${DLL_ENABLED}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set runtime checking flag. By this time, `build` must have become lowercase in setParaMonteBuild.cmake
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if (DEFINED checking)
string(TOLOWER ${checking} checking)
if ("${checking}" STREQUAL "nocheck")
set(CHECK_ENABLED 0)
elseif ("${checking}" STREQUAL "checked")
set(CHECK_ENABLED 1)
else()
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} The user-specified `checking` option is unsupported. checking=${checking}\n"
"${pmfatal} See the above usage notes for the possible choices.\n"
"\n"
)
endif()
elseif ("${build}" STREQUAL "debug" OR "${build}" STREQUAL "testing")
set(CHECK_ENABLED 1)
elseif ("${build}" STREQUAL "release" OR "${build}" STREQUAL "ipo" OR "${build}" STREQUAL "tuned" OR "${build}" STREQUAL "native")
set(CHECK_ENABLED 0)
else()
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} Internal CMake file error occurred. Unrecognized `build`. build=${build}\n"
"${pmfatal} This CMake file is compromised. Download a fresh clone of the ParaMonte library from\n"
"\n"
"${pmfatal} https://github.com/cdslaborg/paramonte\n"
"\n"
)
endif()
add_compile_definitions("CHECK_ENABLED=${CHECK_ENABLED}")
endif()
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set runtime procedure purity flag.
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if (TRUE)
if(DEFINED purity)
message(NOTICE "${pmattn} purity=${purity}")
string(TOLOWER "${purity}" purity)
if("${purity}" STREQUAL "purity")
add_compile_definitions("PURE=impure")
elseif("${purity}" STREQUAL "pure")
add_compile_definitions("PURE=pure")
else()
printUsage()
message(FATAL_ERROR
"\n"
"${pmfatal} Unrecognized value for `purity` (purity=${purity}).\n"
"${pmfatal} See the documentation above for the usage.\n"
"\n"
)
endif()