-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathfunctions.cmake
1212 lines (1072 loc) · 62.5 KB
/
functions.cmake
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
# ###########################################################################
# AREG CMake functions
# Copyright 2022-2023 Aregtech
# ###########################################################################
# ---------------------------------------------------------------------------
# Macro ...: macro_check_fix_areg_cxx_standard
# Purpose ....: Validates and sets C++ standard compatibility.
# The variable 'AREG_CXX_STANDARD' must be defined before calling this macro.
# Details ....: Ensures `CMAKE_CXX_STANDARD` matches `AREG_CXX_STANDARD`. If incompatible, outputs a warning.
# Usage ......: macro_check_fix_areg_cxx_standard()
# ---------------------------------------------------------------------------
macro(macro_check_fix_areg_cxx_standard)
# Ensure that the required 'AREG_CXX_STANDARD' variable is defined.
if (DEFINED AREG_CXX_STANDARD)
# If 'CMAKE_CXX_STANDARD' is not set, assign 'AREG_CXX_STANDARD' to it.
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${AREG_CXX_STANDARD})
# ###################################################################
# Do not disable extensions if googletest compilation is included.
# It causes googletest compilation due to using non-standard POSIX API use
# like 'fileno', 'fdopen' and 'mkstemp' method calls.
# ###################################################################
# set(CMAKE_CXX_EXTENSIONS OFF)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ###################################################################
# If the current C++ standard is less than the required 'AREG_CXX_STANDARD', issue a warning.
elseif(${CMAKE_CXX_STANDARD} LESS ${AREG_CXX_STANDARD})
message(WARNING "AREG: >>> AREG requires C++${AREG_CXX_STANDARD} or higher, \
current version is C++${CMAKE_CXX_STANDARD}. \
To avoid compilation errors, set 'CMAKE_CXX_STANDARD' to ${AREG_CXX_STANDARD}. \
Example: 'set(CMAKE_CXX_STANDARD ${AREG_CXX_STANDARD})'")
endif()
else()
message(WARNING "AREG: >>> Cannot check and set C++ standard, variable 'AREG_CXX_STANDARD' is not defined.")
endif()
endmacro(macro_check_fix_areg_cxx_standard)
# ---------------------------------------------------------------------------
# Macro ......: macro_normalize_path
# Purpose ....: Normalizes Windows paths to Cygwin format if applicable.
# Note .......: This macro does not address OS-specific path separator issues.
# Parameters .: ${normal_path} [out] -- Name of variable to hold normalized path.
# ${os_path} [in] -- The Windows-specific path to normalize.
# Usage ......: macro_normalize_path(<out-var> <windows-path>)
# Example ....: macro_normalize_path(_norm_path "c:\path\to\my\directory")
# ---------------------------------------------------------------------------
macro(macro_normalize_path normal_path os_path)
if (CYGWIN)
execute_process(COMMAND cygpath.exe -m "${os_path}" OUTPUT_VARIABLE _normalized_path OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${normal_path} "${_normalized_path}")
else()
set(${normal_path} "${os_path}")
endif()
endmacro(macro_normalize_path)
# Read-only variable of 32-bit 'x86' processor name
set(_proc_x86 "i386")
# Read-only variable of 64-bit 'x64' processor name
set(_proc_x64 "x86_64")
# Read-only variable of 32-bit 'arm' processor name
set(_proc_arm32 "ARM")
# Read-only variable of 64-bit 'aarch64' processor name
set(_proc_arm64 "AARCH64")
# ---------------------------------------------------------------------------
# Macro .......: macro_get_processor
# Purpose .....: Detects and validates a processor architecture from an input name.
# Matches the provided name against a predefined list of supported
# architectures and retrieves:
# - The canonical architecture name.
# - The bitness (32-bit or 64-bit).
# Parameters ...: ${processor_name} [in] -- The input processor architecture name to validate.
# ${var_processor} [out] -- The canonical name of the processor architecture (if supported).
# ${var_bitness} [out] -- The bitness (32/64) of the processor.
# ${var_found} [out] -- Boolean flag indicating whether the processor is supported (TRUE/FALSE).
# Usage ........: macro_get_processor(<processor_name> <var_processor> <var_bitness> <var_found>)
# Example ......:
# macro_get_processor("arm64" AREG_PROCESSOR AREG_BITNESS _entry_found)
# ---------------------------------------------------------------------------
macro(macro_get_processor processor_name var_processor var_bitness var_found)
set(${var_found} FALSE)
string(TOLOWER "${processor_name}" _proc_name)
set(_arch_list "x86|${_proc_x86}|32"
"i386|${_proc_x86}|32"
"i486|${_proc_x86}|32"
"i686|${_proc_x86}|32"
"x64|${_proc_x64}|64"
"x86_64|${_proc_x64}|64"
"x86-64|${_proc_x64}|64"
"amd64|${_proc_x64}|64"
"ia64|${_proc_x64}|64"
"arm|${_proc_arm32}|32"
"arm32|${_proc_arm32}|32"
"armv7|${_proc_arm32}|32"
"arm64|${_proc_arm64}|64"
"aarch64|${_proc_arm64}|64"
)
foreach(_entry IN LISTS _arch_list)
string(REPLACE "|" ";" _entry "${_entry}")
list(GET _entry 0 _arch)
if ("${_arch}" STREQUAL "${_proc_name}")
# If a match is found, extract processor details
list(GET _entry 1 ${var_processor})
list(GET _entry 2 ${var_bitness})
set(${var_found} TRUE)
break()
endif()
endforeach()
endmacro(macro_get_processor)
# ---------------------------------------------------------------------------
# Macro ........: macro_check_module_architect
# Purpose ......: Validates whether a given binary module (executable or library)
# matches the specified processor architecture. The validation
# uses object dumping tools to analyze the module. Typically,
# this macro is invoked after identifying a package or library.
#
# Parameters ...: ${path_module} [in] -- Full path to the binary module (executable, shared, or static library).
# ${target_name} [in] -- Target name, typically the same as AREG_TARGET.
# ${target_proc} [in] -- Target processor architecture to validate.
# ${var_compatible} [out] -- Boolean variable set to TRUE if the binary is compatible with the target processor, FALSE otherwise.
#
# Usage ........: macro_check_module_architect(<path_to_binary> <target_name> <target_processor> <output_compatibility_var>)
# Example ......:
# macro_check_module_architect("/usr/lib/i386-linux-gnu/sqlite3.so" "i386-linux-gnu" i386 _is_compatible)
# ---------------------------------------------------------------------------
macro(macro_check_module_architect path_module target_name target_proc var_compatible)
message(STATUS "AREG: >>> Validating binary '${path_module}' for compatibility with processor '${target_proc}'")
# Determine the appropriate objdump command
if (NOT "${CMAKE_OBJDUMP}" STREQUAL "")
set(_objdump "${CMAKE_OBJDUMP}")
else()
set(_objdump "${target_name}-objdump")
endif()
# Check existence of the binary and objdump tool
if (EXISTS "${path_module}" AND EXISTS "${_objdump}")
macro_get_processor(${target_proc} _proc _bitness _found)
execute_process(
COMMAND bash -c "${_objdump} -f ${path_module} | grep ^architecture | cut -d' ' -f2 | sort -u"
OUTPUT_VARIABLE _data
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
# Match the processor type with extracted architecture
if (${_proc} STREQUAL ${_proc_x86})
string(FIND "${_data}" "x86-64" _pos)
if (_pos EQUAL -1)
string(FIND "${_data}" "i386" _pos)
else()
set(_pos -1)
endif()
elseif (${_proc} STREQUAL ${_proc_x64})
string(FIND "${_data}" "x86-64" _pos)
elseif (${_proc} STREQUAL ${_proc_arm32})
string(FIND "${_data}" "ARM" _pos)
elseif (${_proc} STREQUAL ${_proc_arm64})
string(FIND "${_data}" "AARCH64" _pos)
else()
string(FIND "${_data}" "${_proc}" _pos)
endif()
# Set compatibility flag based on architecture match
if (_pos GREATER -1)
set(${var_compatible} TRUE)
else()
message(WARNING "AREG: >>> Binary '${path_module}' is NOT compatible with target processor '${target_proc}'")
set(${var_compatible} FALSE)
endif()
elseif (${AREG_OS} STREQUAL Windows)
set(${var_compatible} TRUE)
else()
set(${var_compatible} FALSE)
endif()
endmacro(macro_check_module_architect)
# ---------------------------------------------------------------------------
# Macro .......: macro_find_ncurses_package
# Purpose .....: Locates the 'ncurses' library and its associated header files on the system.
# Sets output variables with the include directory and library path if found.
# Parameters ...: ${var_include} [out] -- Variable to store the path to the directory containing the 'ncurses.h' header file.
# ${var_library} [out] -- Variable to store the full path to the 'ncurses' library file.
# ${var_found} [out] -- Variable to indicate whether the 'ncurses' library and headers were successfully located (TRUE/FALSE).
# Usage ........: macro_find_ncurses_package(<ncurses-include-var> <ncurses-library-var> <found-flag-var>)
# Example ......:
# macro_find_ncurses_package(NCURSES_INCLUDE NCURSES_LIB NCURSES_FOUND)
# ---------------------------------------------------------------------------
macro(macro_find_ncurses_package var_include var_library var_found)
set(${var_found} FALSE)
set(${var_include})
set(${var_library})
find_path(${var_include} NAMES ncurses.h)
find_library(${var_library} NAMES ncurses)
if (${var_include} AND ${var_library})
macro_check_module_architect("${${var_library}}" ${AREG_TARGET} ${AREG_PROCESSOR} ${var_found})
endif()
endmacro(macro_find_ncurses_package)
# ---------------------------------------------------------------------------
# Macro .......: macro_find_gtest_package
# Purpose .....: Locates the Google Test (GTest) package, including its header files and libraries.
# Sets output variables with the include directory and library paths if found.
# Parameters ...: ${var_include} [out] -- Variable to store the path to the directory containing GTest header files.
# ${var_library} [out] -- Variable to store the full paths to the GTest libraries.
# ${var_found} [out] -- Variable to indicate whether the GTest package was successfully located (TRUE/FALSE).
# Usage ........: macro_find_gtest_package(<gtest-include-var> <gtest-library-var> <gtest-found-flag-var>)
# Example ......:
# macro_find_gtest_package(GTEST_INCLUDE GTEST_LIB GTEST_FOUND)
# ---------------------------------------------------------------------------
macro(macro_find_gtest_package var_include var_library var_found)
set(${var_found} FALSE)
set(${var_include})
set(${var_library})
include(FindGTest)
if (GTest_FOUND)
set(${var_library} "${GTEST_LIBRARIES}")
set(${var_include} "${GTEST_INCLUDE_DIRS}")
if (NOT EXISTS "${GTEST_LIBRARIES}")
get_target_property(_gtest_location GTest::gtest LOCATION)
if (NOT _gtest_location)
get_target_property(_gtest_location GTest::gtest IMPORTED_LOCATION)
if (NOT _gtest_location)
get_target_property(_gtest_location GTest::GTest LOCATION)
if (NOT _gtest_location)
get_target_property(_gtest_location GTest::GTest IMPORTED_LOCATION)
endif()
endif()
endif()
else()
set(_gtest_location "${GTEST_LIBRARIES}")
endif()
if (EXISTS "${_gtest_location}")
macro_check_module_architect("${_gtest_location}" ${AREG_TARGET} ${AREG_PROCESSOR} ${var_found})
else()
set(${var_found} TRUE)
endif()
unset(_gtest_location)
endif()
endmacro(macro_find_gtest_package)
# ---------------------------------------------------------------------------
# Macro .......: macro_find_sqlite_package
# Purpose .....: Locates the SQLite3 package, including its header files and libraries.
# Sets output variables with the include directory and library paths if found.
# Parameters ...: ${var_include} [out] -- Variable to store the path to the directory containing SQLite3 header files.
# ${var_library} [out] -- Variable to store the full path to the SQLite3 library file(s).
# ${var_found} [out] -- Variable to indicate whether the SQLite3 package was successfully located (TRUE/FALSE).
# Usage ........: macro_find_sqlite_package(<sqlite3-include-var> <sqlite3-library-var> <sqlite3-found-flag-var>)
# Example ......:
# macro_find_sqlite_package(SQLITE_INCLUDE SQLITE_LIB SQLITE_FOUND)
# ---------------------------------------------------------------------------
macro(macro_find_sqlite_package var_include var_library var_found)
set(${var_found} FALSE)
set(${var_include})
set(${var_library})
include(FindSQLite3)
if (SQLite3_FOUND)
set(${var_library} "${SQLite3_LIBRARIES}")
set(${var_include} "${SQLite3_INCLUDE_DIRS}")
macro_check_module_architect("${SQLite3_LIBRARY}" ${AREG_TARGET} ${AREG_PROCESSOR} ${var_found})
endif()
endmacro(macro_find_sqlite_package)
# ---------------------------------------------------------------------------
# Macro ......: macro_create_option
# Purpose ....: Creates a boolean cache variable with a default value.
# Parameters .: ${var_name} [out] -- Name of the boolean variable.
# ${var_value} [in] -- Default value if the variable is not yet defined.
# ${var_describe} [in] -- Description of the variable for the CMake cache.
# Usage ......: macro_create_option(<name-var> <default-value> <describe>)
# Example ....: macro_create_option(AREG_LOGS ON "Compile with logs")
# ---------------------------------------------------------------------------
macro(macro_create_option var_name var_value var_describe)
if (NOT DEFINED ${var_name})
option(${var_name} "${var_describe}" ${var_value})
else()
option(${var_name} "${${var_name}}" ${var_value})
endif()
endmacro(macro_create_option)
# ---------------------------------------------------------------------------
# Macro ......: macro_add_source
# Purpose ....: Adds existing source files to a list based on a base directory. Checks file existence.
# Parameters .: ${result_list} -- Name of variable that on output will contain the list of source files.
# ${src_base_dir} -- Base directory of the source files.
# ${ARGN} -- List of source files, relative to the base directory.
# Usage ......: macro_add_source(<src-list-var> <base-dirpath> <files>)
# Example ....:
# set(aregextend_SRC)
# macro_add_source(aregextend_SRC "${AREG_FRAMEWORK}" aregextend/db/private/LogSqliteDatabase.cpp ...)
# ---------------------------------------------------------------------------
macro(macro_add_source result_list src_base_dir)
set(_list "${ARGN}")
foreach(_item IN LISTS _list)
set(_src "${src_base_dir}/${_item}")
if (EXISTS "${_src}")
list(APPEND ${result_list} "${_src}")
else()
message(FATAL_ERROR "AREG: >>> The item '${_item}' does not exist in '${src_base_dir}'")
endif()
endforeach()
unset(_list)
endmacro(macro_add_source)
# ---------------------------------------------------------------------------
# Macro ......: macro_parse_arguments
# Purpose ....: Parses files and libraries into separate lists for sources,
# libraries, and resources. Library names must match known targets.
# Resource files should have `.rc` extension (Windows-specific).
#
# Note .......: - Throws an error if file does not exist.
# - List of resource files is Windows specific, it contains files with extension .rc.
#
# Parameters .: ${res_sources} [out] -- Name of variable that on output will contain the list of source files.
# ${res_libs} [out] -- Name of variable that on output will contain the list of recognized CMake targets.
# ${res_resources} [out] -- Name of variable that on output will contain the List of resource files ('*.rc')
# ${ARGN} [in] -- List of files, libraries, or resources to categorize.
#
# Usage ......: macro_parse_arguments(<sources-var> <libs-var> <resources-var> <sources-targets-resources>)
# Example ....:
# macro_parse_arguments(src_files lib_targets res_files my_lib src/main.cpp src/object.cpp res/resource.rc)
# ---------------------------------------------------------------------------
macro(macro_parse_arguments res_sources res_libs res_resources)
set(_list "${ARGN}")
foreach(_item IN LISTS _list)
# Determine full path if file exists in the current directory
set(_full_path "${_item}")
if (NOT EXISTS "${_full_path}" AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_item}")
set(_full_path "${CMAKE_CURRENT_LIST_DIR}/${_item}")
endif()
# Add to appropriate lists
if (TARGET ${_item})
list(APPEND ${res_libs} ${_item})
elseif (EXISTS "${_full_path}")
list(APPEND ${res_sources} "${_full_path}")
# Check for resource file extension
cmake_path(GET _full_path EXTENSION _ext)
if (_ext STREQUAL "rc")
list(APPEND ${res_resources} "${_full_path}")
endif()
else()
message(FATAL_ERROR "AREG: >>> File \'${_item}\' does not exist, stopping.")
endif()
endforeach()
endmacro(macro_parse_arguments)
# ---------------------------------------------------------------------------
# Macro ......: macro_guess_processor_architecture
# Purpose ....: If possible, detects the processor architecture and bitness by given compiler path.
# Parameters .: ${compiler_path} [in] -- Path of the cross-compiler.
# ${target_processor} [out] -- Name of variable to store the CPU type.
# ${target_bitness} [out] -- Name of variable to store bitness.
#
# Usage ......: macro_guess_processor_architecture(<compiler-path> <processor-var> <bitness-var>)
# Example ....:
# macro_guess_processor_architecture("arm-linux-gnueabihf-g++" cpu_architect cpu_bitness)
# ---------------------------------------------------------------------------
macro(macro_guess_processor_architecture compiler_path target_processor target_bitness)
foreach(_entry "arm;${_proc_arm32};32" "aarch64;${_proc_arm64};64")
list(GET _entry 0 _proc)
list(GET _entry 1 _arch)
list(GET _entry 2 _bits)
string(FIND "${compiler_path}" ${_proc} _proc_pos)
if (_proc_pos GREATER -1)
set(${target_processor} ${_arch})
set(${target_bitness} ${_bits})
break()
endif()
endforeach()
unset(_entry)
unset(_proc)
unset(_arch)
unset(_bits)
unset(_proc_pos)
endmacro(macro_guess_processor_architecture)
# ---------------------------------------------------------------------------
# Macro ......: macro_system_bitness
# Purpose ....: Extracts the system default bitness.
# Parameters : ${var_bitness} [out] -- The name of variable to set the bitness.
# Usage ......: macro_system_bitness(<var-name>)
# Example ....:
# macro_system_bitness(_sys_bitness)
# ---------------------------------------------------------------------------
macro(macro_system_bitness var_bitness)
# Detect and set bitness here
# 8 bytes ==> 64-bits (x64) and 4 bytes ==> 32-nit (x86)
if (DEFINED CMAKE_SIZEOF_VOID_P)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(${var_bitness} 64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(${var_bitness} 32)
else()
set(${var_bitness} 0)
endif()
endif()
endmacro(macro_system_bitness)
# ---------------------------------------------------------------------------
# Macro .......: macro_default_target
# Purpose .....: Configures the default compiler target based on the specified processor architecture.
# The configured target is also used to determine the library architecture for linking.
# Parameters ...: ${target_processor} [in] -- The target processor architecture (e.g., AARCH64, X86_64).
# ${var_name_target} [out] -- Variable to store the determined compiler target.
# Usage ........: macro_default_target(<target-processor> <compiler-target-var>)
# Example ......:
# macro_default_target(AARCH64 AREG_TARGET)
# ---------------------------------------------------------------------------
macro(macro_default_target target_processor var_name_target)
macro_get_processor("${target_processor}" _proc _bitness _found)
if ("${_proc}" STREQUAL "")
set(${var_name_target})
elseif (UNIX)
if (${_proc} MATCHES "${_proc_x64}")
set(${var_name_target} x86_64-linux-gnu)
elseif (${_proc} MATCHES "${_proc_x86}")
set(${var_name_target} i386-linux-gnu)
elseif (${_proc} MATCHES "${_proc_arm64}")
set(${var_name_target} aarch64-linux-gnu)
elseif (${_proc} MATCHES "${_proc_arm32}")
set(${var_name_target} arm-linux-gnueabihf)
endif()
elseif (MSVC)
if (${_proc} MATCHES "${_proc_x64}")
set(${var_name_target} x64)
elseif (${_proc} MATCHES "${_proc_x86}")
set(${var_name_target} "win32")
endif()
elseif(CYGWIN)
if (${_proc} MATCHES "${_proc_x64}")
set(${var_name_target} "x86_64-pc-cygwin")
elseif (${_proc} MATCHES "${_proc_x86}")
set(${var_name_target} "i386-pc-cygwin")
endif()
endif()
endmacro(macro_default_target)
# ---------------------------------------------------------------------------
# Macro .......: macro_setup_compilers_data
# Purpose .....: Detects and configures compiler attributes including family, short name, paths,
# target, processor architecture, and application bitness.
# Note ........: In addition to "gnu", "llvm", and "msvc", GNU compilers used in CYGWIN are
# categorized under the "cygwin" family.
# Parameters ...: ${compiler_path} [in] -- Path to the C++ compiler.
# ${var_name_family} [out] -- Variable to store the compiler family (e.g., "gnu", "msvc", "llvm", "cygwin").
# ${var_name_short} [out] -- Variable to store the short name of the compiler (e.g., "gcc", "clang", "cl").
# ${var_name_cxx} [out] -- Variable to store the path to the C++ compiler (typically same as ${compiler_path}).
# ${var_name_c} [out] -- Variable to store the corresponding C compiler name or path.
# ${var_name_target} [out] -- Variable to store the compiler target value.
# ${var_name_arch} [in, out] -- Variable containing the processor architecture (input) and updated with the determined architecture (output).
# ${var_name_bitness} [out] -- Variable to store the application bitness value (e.g., 32 or 64).
# ${var_name_found} [out] -- Variable to indicate whether the compiler was successfully identified (TRUE/FALSE).
# Usage ........: macro_setup_compilers_data(<compiler-path> <family-var> <short-var>
# <CXX-compiler-var> <C-compiler-var>
# <compiler-target-var> <processor-architecture-var>
# <target-bitness-var> <found-flag-var>)
# Example ......: macro_setup_compilers_data("${CMAKE_CXX_COMPILER}"
# AREG_COMPILER_FAMILY
# AREG_COMPILER_SHORT
# AREG_CXX_COMPILER
# AREG_C_COMPILER
# AREG_TARGET
# AREG_PROCESSOR
# AREG_BITNESS
# _compiler_supports)
# ---------------------------------------------------------------------------
macro(macro_setup_compilers_data
compiler_path
var_name_family
var_name_short
var_name_cxx
var_name_c
var_name_target
var_name_arch
var_name_bitness
var_name_found)
set(${var_name_found} FALSE)
if(NOT "${${var_name_arch}}" STREQUAL "")
macro_get_processor("${${var_name_arch}}" ${var_name_arch} ${var_name_bitness} _ignore)
elseif()
macro_system_bitness(${var_name_bitness})
endif()
# Iterate over known compilers to identify the compiler type
foreach(_entry "clang-cl;llvm;clang-cl" "clang++;llvm;clang" "clang;llvm;clang" "g++;gnu;gcc" "gcc;gnu;gcc" "c++;gnu;cc" "cc;gnu;cc" "cl;msvc;cl")
list(GET _entry 0 _cxx_comp)
# Check if the provided compiler matches the known C++ compiler
string(TOLOWER "${compiler_path}" _comp_path)
string(FIND "${_comp_path}" "${_cxx_comp}" _found_pos REVERSE)
if (_found_pos GREATER -1)
list(GET _entry 1 _family)
list(GET _entry 2 _cc_comp)
# Handle special case for CYGWIN and GNU family compilers
if (${_family} STREQUAL gnu)
if (CYGWIN)
set(${var_name_family} "cygwin")
macro_default_target("${${var_name_arch}}" ${var_name_target})
else()
set(${var_name_family} "gnu")
macro_guess_processor_architecture("${_comp_path}" ${var_name_arch} ${var_name_bitness})
string(FIND "${_comp_path}" "-${_cxx_comp}" _found_pos REVERSE)
if (_found_pos GREATER -1)
cmake_path(GET _comp_path FILENAME _file_name)
string(REPLACE "-${_cxx_comp}" "" ${var_name_target} "${_file_name}")
else()
macro_default_target("${${var_name_arch}}" ${var_name_target})
endif()
endif()
elseif (${_family} STREQUAL llvm)
set(${var_name_family} "llvm")
macro_default_target("${${var_name_arch}}" ${var_name_target})
elseif (${_family} STREQUAL msvc)
set(${var_name_family} "msvc")
macro_default_target("${${var_name_arch}}" ${var_name_target})
else()
set(${var_name_family} "${_family}")
macro_default_target("${${var_name_arch}}" ${var_name_target})
endif()
set(${var_name_short} "${_cxx_comp}")
set(${var_name_cxx} "${compiler_path}")
# Determine the corresponding C compiler path or name
if ("${_cxx_comp}" STREQUAL "${_cc_comp}")
set(${var_name_c} "${compiler_path}")
else()
string(REPLACE "${_cxx_comp}" "${_cc_comp}" ${var_name_c} "${compiler_path}")
endif()
# Mark compiler as found
set(${var_name_found} TRUE)
# break the loop, we have found
break()
endif()
endforeach()
unset(_entry)
unset(_cxx_comp)
unset(_family)
unset(_cc_comp)
unset(_found_pos)
endmacro(macro_setup_compilers_data)
# ---------------------------------------------------------------------------
# Macro ......: macro_setup_compilers_data_by_family
# Purpose ....: Configures compiler names based on family (e.g., gnu, msvc, llvm, cygwin), and compiler target.
# Note .......: The "cygwin" family is supported for GNU compilers on the CYGWIN platform in Windows.
# Parameters .: ${compiler_family} [in] -- Compiler family name (e.g., "gnu", "msvc").
# ${var_name_short} [out] -- Variable to hold the short name of the compiler (e.g., "gcc", "clang").
# ${var_name_cxx} [out] -- Variable to hold the C++ compiler name.
# ${var_name_c} [out] -- Variable to hold the corresponding C compiler name.
# ${var_name_target} [out] -- Variable to hold the compiler default target name.
# ${var_name_found} [out] -- Name of variable to hold Boolean indicating successful identification.
# Usage ......: macro_setup_compilers_data_by_family(<compiler-family> <short-var> <CXX-compiler-var> <C-compiler-var> <identified-var>)
# Example ....: macro_setup_compilers_data_by_family("gnu"
# AREG_COMPILER_SHORT
# AREG_CXX_COMPILER
# AREG_C_COMPILER
# AREG_TARGET
# _compiler_supports
# )
# ---------------------------------------------------------------------------
macro(macro_setup_compilers_data_by_family compiler_family var_name_short var_name_cxx var_name_c var_name_target var_name_found)
set(${var_name_found} FALSE)
# Iterate over known compilers and match the family
foreach(_entry "clang++;llvm;clang" "g++;gnu;gcc" "cl;msvc;cl" "g++;cygwin;gcc")
list(GET _entry 1 _family)
if ("${_family}" STREQUAL "${compiler_family}")
list(GET _entry 0 _cxx_comp)
list(GET _entry 2 _cc_comp)
# Special case for Windows
if ("${_family}" STREQUAL "llvm")
if (MSVC)
set(${var_name_short} "clang-cl")
set(${var_name_cxx} "clang-cl")
set(${var_name_c} "clang-cl")
else()
set(${var_name_short} "${_cxx_comp}")
set(${var_name_cxx} "${_cxx_comp}")
set(${var_name_c} "${_cc_comp}")
endif()
macro_default_target("${AREG_PROCESSOR}" ${var_name_target})
elseif ("${AREG_PROCESSOR}" STREQUAL "${_proc_arm32}" AND "${_family}" STREQUAL "gnu")
set(${var_name_short} g++)
set(${var_name_cxx} arm-linux-gnueabihf-g++)
set(${var_name_c} arm-linux-gnueabihf-gcc)
set(${var_name_target} arm-linux-gnueabihf)
elseif ("${AREG_PROCESSOR}" STREQUAL "${_proc_arm64}" AND "${_family}" STREQUAL "gnu")
set(${var_name_short} g++)
set(${var_name_cxx} aarch64-linux-gnu-g++)
set(${var_name_c} aarch64-linux-gnu-gcc)
set(${var_name_target} aarch64-linux-gnu)
else()
set(${var_name_short} "${_cxx_comp}")
set(${var_name_cxx} "${_cxx_comp}")
set(${var_name_c} "${_cc_comp}")
macro_default_target("${AREG_PROCESSOR}" ${var_name_target})
endif()
# Mark compiler as found
set(${var_name_found} TRUE)
# break the loop, we have found
break()
endif()
endforeach()
unset(_entry)
unset(_cxx_comp)
unset(_family)
unset(_cc_comp)
endmacro(macro_setup_compilers_data_by_family)
# ---------------------------------------------------------------------------
# Function ...: setAppOptions
# Purpose ....: Configures the compiler and linker options for executable applications.
# Automatically links the AREG library, along with any additional libraries specified.
# Parameters .: ${target_name} -- Name of the executable to apply options to.
# ${library_list} -- List of additional libraries to link.
# Usage ......: setAppOptions(<target-name> <library-list>)
# ---------------------------------------------------------------------------
function(setAppOptions target_name library_list)
# Set common compile definitions for the executable
target_compile_definitions(${target_name} PRIVATE ${COMMON_COMPILE_DEF})
# Apply common compiler options, such as disabling certain warnings
target_compile_options(${target_name} PRIVATE "${AREG_OPT_DISABLE_WARN_COMMON}")
# Link the AREG library, additional specified libraries, and any extended or extra libraries
target_link_libraries(${target_name}
${AREG_PACKAGE_NAME}::aregextend # AREG extended library
${library_list} # Custom libraries to link
${AREG_PACKAGE_NAME}::areg # Core AREG library
${AREG_EXTENDED_LIBS} # Extended libraries, if any
${AREG_LDFLAGS} # Additional linker flags
)
endfunction(setAppOptions)
# ---------------------------------------------------------------------------
# Purpose ....: Creates an executable, sets its source files, applies necessary options,
# and links it with the provided list of libraries.
# The AREG library is automatically linked, no need to specify it.
# Function ...: addExecutableEx
# Parameters .: ${target_name} -- The name of the executable target.
# ${target_namespace} -- Namespace for aliasing. Can be empty.
# ${source_list} -- List of source files used to build the target executable.
# ${library_list} -- Libraries to link with the executable.
# Usage ......: addExecutableEx(<target-name> <namespace-opt> <source-list> <library-list>)
# ---------------------------------------------------------------------------
function(addExecutableEx target_name target_namespace source_list library_list)
# Ensure the source list is not empty
if (NOT source_list)
message(FATAL_ERROR "AREG: >>> Source list for executable \'${target_name}\' is empty")
endif()
# Gather any additional libraries passed as arguments (ARGN)
set(exList "${ARGN}")
foreach(_item IN LISTS exList)
list(APPEND library_list "${_item}")
endforeach()
# Create the executable with the specified source files
add_executable(${target_name} ${source_list})
# Optionally create an alias for the executable using the specified namespace
if (NOT "${target_namespace}" STREQUAL "")
add_executable(${target_namespace}::${target_name} ALIAS ${target_name})
endif()
# Apply compiler and linker options, including linking with AREG and additional libraries
setAppOptions(${target_name} "${library_list}")
# Set the include directories for the executable
target_include_directories(${target_name} BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR})
endfunction(addExecutableEx)
# ---------------------------------------------------------------------------
# Function ...: addExecutable
# Purpose ....: Wrapper for addExecutableEx, assuming there is not list of libraries to link with.
# The AREG library is automatically linked, no need to specify it.
# Parameters .: ${target_name} -- Name of the executable to build.
# ${source_list} -- List of source files used to build the executable.
# Usage ......: addExecutable(<target-name> <source-list>)
# ---------------------------------------------------------------------------
function(addExecutable target_name source_list)
addExecutableEx(${target_name} "" "${source_list}" "")
endfunction(addExecutable)
# ---------------------------------------------------------------------------
# Function ...: setStaticLibOptions
# Purpose ....: Configures compiler and linker settings for a static library,
# automatically linking the AREG Framework library along with any
# additional specified libraries
# Parameters .: ${target_name} -- Name of the static library to apply options to.
# ${library_list} -- List of libraries to link with the static library.
# Usage ......: setStaticLibOptions(<target-name> <library-list>)
# ---------------------------------------------------------------------------
function(setStaticLibOptions target_name library_list)
# Apply common compile definitions and options for static libraries
target_compile_definitions(${target_name} PRIVATE ${COMMON_COMPILE_DEF} _LIB)
target_compile_options(${target_name} PRIVATE ${AREG_COMPILER_VERSION})
target_compile_options(${target_name} PRIVATE "${AREG_OPT_DISABLE_WARN_COMMON}")
# Additional compile options for non-Windows platforms
if (NOT ${AREG_DEVELOP_ENV} MATCHES "Win32")
target_compile_options(${target_name} PRIVATE "-Bstatic") # Ensure static linking
target_compile_options(${target_name} PRIVATE -fPIC) # Position-independent code
endif()
# Link the static library with the provided libraries and AREG framework
target_link_libraries(${target_name} ${library_list} ${AREG_PACKAGE_NAME}::areg ${AREG_LDFLAGS})
endfunction(setStaticLibOptions)
# ---------------------------------------------------------------------------
# Function ...: addStaticLibEx
# Purpose ....: Creates a static library with specified source files and options,
# importing and auto-linking the AREG Framework library along with
# any additional libraries.
# Parameters .: ${target_name} -- Name of the static library to build.
# ${target_namespace} -- Namespace for aliasing. Can be empty string if no aliasing.
# ${source_list} -- List of source files to build the static library.
# ${library_list} -- List of libraries to link.
# Usage ......: addStaticLibEx(<target-name> <namespace-opt> <source-list> <library-list>)
# ---------------------------------------------------------------------------
function(addStaticLibEx target_name target_namespace source_list library_list)
# Gather any additional libraries passed as arguments (ARGN)
set(exList "${ARGN}")
foreach(_item IN LISTS exList)
list(APPEND library_list "${_item}")
endforeach()
# Create the static library with the specified source files
add_library(${target_name} STATIC ${source_list})
# Optionally create an alias for the static library using the specified namespace
if (NOT "${target_namespace}" STREQUAL "")
add_library(${target_namespace}::${target_name} ALIAS ${target_name})
endif()
# Apply compiler and linker options, including linking with AREG and additional libraries
setStaticLibOptions(${target_name} "${library_list}")
# Set the include directories for the static library
target_include_directories(${target_name} BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR})
endfunction(addStaticLibEx)
# ---------------------------------------------------------------------------
# Function ...: addStaticLib
# Purpose ....: Wrapper of addStaticLibEx, assuming there is no list of libraries to link.
# Creates a static library, setting sources and options, importing,
# and auto-linking the AREG Framework library.
# Parameters .: ${target_name} -- Name of the static library to build.
# ${source_list} -- List of source files to build the static library.
# Usage ......: addStaticLib(<target-name> <source-list>)
# ---------------------------------------------------------------------------
function(addStaticLib target_name source_list)
addStaticLibEx(${target_name} "" "${source_list}" "")
endfunction(addStaticLib)
# ---------------------------------------------------------------------------
# Function ...: addStaticLibEx_C
# Purpose ....: Creates a static library compiled with C, setting sources,
# importing, and auto-linking the AREG Framework library along
# with any additional libraries.
# Parameters .: ${target_name} -- Name of the static library to build.
# ${target_namespace} -- Namespace for aliasing. Pass empty string if no aliasing.
# ${source_list} -- List of C-source files to build the static library.
# ${library_list} -- Libraries to link with the static library.
# Usage ......: addStaticLibEx_C(<target-name> <namespace-opt> <C-source-list> <library-list>)
# ---------------------------------------------------------------------------
function(addStaticLibEx_C target_name target_namespace source_list library_list)
set(exList "${ARGN}")
foreach(_item IN LISTS exList)
list(APPEND library_list "${_item}")
endforeach()
add_library(${target_name} STATIC ${source_list})
if (NOT "${target_namespace}" STREQUAL "")
add_library(${target_namespace}::${target_name} ALIAS ${target_name})
endif()
target_compile_options(${target_name} PRIVATE "${AREG_OPT_DISABLE_WARN_COMMON}")
# Set common compile definition
target_compile_definitions(${target_name} PRIVATE ${COMMON_COMPILE_DEF} _LIB)
if (NOT ${AREG_DEVELOP_ENV} MATCHES "Win32")
target_compile_options(${target_name} PRIVATE "-Bstatic")
target_compile_options(${target_name} PRIVATE -fPIC)
endif()
target_link_libraries(${target_name} ${library_list} ${AREG_PACKAGE_NAME}::areg ${AREG_LDFLAGS})
endfunction(addStaticLibEx_C)
# ---------------------------------------------------------------------------
# Function ...: addStaticLib_C
# Purpose ....: Wrapper for addStaticLibEx_C, assuming there is no aliasing and
# list of libraries for linking. Creates a static library compiled with C,
# setting sources, importing, and auto-linking the AREG Framework library.
# Parameters .: ${target_name} -- Name of the static library to build.
# ${source_list} -- List of C-source files to build the static library.
# Usage ......: addStaticLib_C(<target-name> <C-source-list>)
# ---------------------------------------------------------------------------
function(addStaticLib_C target_name source_list)
addStaticLibEx_C(${target_name} "" "${source_list}" "")
endfunction(addStaticLib_C)
# ---------------------------------------------------------------------------
# Function ...: setSharedLibOptions
# Purpose ....: Configures settings for a shared library, automatically linking
# the AREG Framework library and any additional specified libraries.
# Parameters .: ${target_name} -- Name of the shared library to apply options to.
# ${library_list} -- List of libraries for linking.
# Usage ......: setSharedLibOptions(<target-name> <library-list>)
# ---------------------------------------------------------------------------
function(setSharedLibOptions target_name library_list)
# Apply common compile definitions for shared libraries
target_compile_definitions(${target_name} PRIVATE ${COMMON_COMPILE_DEF} _USRDLL)
target_compile_options(${target_name} PRIVATE "${AREG_OPT_DISABLE_WARN_COMMON}")
# Link the shared library with provided libraries and AREG framework
target_link_libraries(${target_name} ${AREG_PACKAGE_NAME}::aregextend ${library_list} ${AREG_PACKAGE_NAME}::areg ${AREG_EXTENDED_LIBS} ${AREG_LDFLAGS})
# Additional compile options for non-Windows platforms
if (NOT ${AREG_DEVELOP_ENV} MATCHES "Win32")
target_compile_options(${target_name} PRIVATE "-Bdynamic") # Ensure dynamic linking
target_compile_options(${target_name} PRIVATE -fPIC) # Position-independent code for shared libraries
endif()
endfunction(setSharedLibOptions)
# ---------------------------------------------------------------------------
# Function ...: addSharedLibEx
# Purpose ....: Creates a shared library with specified source files and options,
# importing and auto-linking the AREG Framework library along with
# any additional libraries.
# Parameters .: ${target_name} -- Name of the shared library to build.
# ${target_namespace} -- Namespace for aliasing. Can be empty string if no aliasing.
# ${source_list} -- List of source files to build the shared library.
# ${library_list} -- Libraries for linking.
# Usage ......: addSharedLibEx(<target-name> <namespace-opt> <source-list> <library-list>)
# ---------------------------------------------------------------------------
function(addSharedLibEx target_name target_namespace source_list library_list)
# Gather any additional libraries passed as arguments (ARGN)
set(exList "${ARGN}")
foreach(_item IN LISTS exList)
list(APPEND library_list "${_item}")
endforeach()
# Create the shared library with the specified source files
add_library(${target_name} SHARED ${source_list})
# Optionally create an alias for the shared library using the specified namespace
if (NOT "${target_namespace}" STREQUAL "")
add_library(${target_namespace}::${target_name} ALIAS ${target_name})
endif()
# Apply compiler and linker options, including linking with AREG and additional libraries
setSharedLibOptions(${target_name} "${library_list}")
# Set the include directories for the shared library
target_include_directories(${target_name} BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR})
endfunction(addSharedLibEx)
# ---------------------------------------------------------------------------
# Function ...: addSharedLib
# Purpose ....: Wrapper for addSharedLibEx, assuming there is no aliasing and no list for linking.
# Creates a shared library with specified sources, options, imports,
# and auto-linking the AREG Framework library.
# Parameters .: ${target_name} -- Name of the shared library to build.
# ${source_list} -- List of source files to build the shared library.
# Usage ......: addSharedLib(<target-name> <source-list>)
# ---------------------------------------------------------------------------
function(addSharedLib target_name target_source_list)
addSharedLibEx(${target_name} "" "${target_source_list}" "")
endfunction(addSharedLib)
# ---------------------------------------------------------------------------
# Macro ......: macro_add_service_interface
# Purpose ....: The macro_add_service_interface function automates the generation and
# inclusion of service-specific source and header files for a static library,
# based on a provided Service Interface document (*.siml).
# Parameters .: ${lib_name} -- The name of the static library where generated files will be included.
# ${interface_doc} -- Full path to the Service Interface document file (.siml), which defines the service interface details.
# ${codegen_root} -- Root directory where generated files will be stored.
# ${output_path} -- Relative path from ${codegen_root} to the directory where generated files will be placed.
# ${codegen_tool} -- Full path to the code generation tool (codegen.jar) used to generate the necessary source and header files.
#
# Usage ......: macro_add_service_interface(<name-lib> <full-path-siml> <root-gen> <relative-path> <codegen-tool>)
# Example ....:
# macro_add_service_interface(funlib "/home/dev/fun/src/service/HelloWorld.siml" "/home/dev/fun/product" "generate/service" /tools/areg/codegen.jar)
# macro_add_service_interface(funlib "/home/dev/fun/src/service/WeHaveFun.siml" "/home/dev/fun/product" "generate/service" /tools/areg/codegen.jar)
# ---------------------------------------------------------------------------
macro(macro_add_service_interface lib_name interface_doc codegen_root output_path codegen_tool)
if (NOT ${Java_FOUND})
message(FATAL_ERROR "AREG Setup: Java not found! Install Java 17 or higher to run the code generator.")
return()
endif()
if (NOT EXISTS "${interface_doc}")
message(FATAL_ERROR "AREG Setup: The Service Interface file \'${interface_doc}\' does not exist. Cannot generate files.")
return()
endif()
set(_si_doc "${interface_doc}")
cmake_path(GET _si_doc STEM _interface_name)
if ("${_interface_name}" STREQUAL "")
message(FATAL_ERROR "AREG Setup: The path \'${interface_doc}\' has no file name. Cannot generate Service Interface files.")
return()
endif()
# Run the code generator tool
execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -jar ${codegen_tool} --doc=${interface_doc} --root=${codegen_root} --target=${output_path})
# Set path for generated files
set(_generate "${codegen_root}/${output_path}")
# List of generated source and header files
list(APPEND _sources
${_generate}/private/${_interface_name}ClientBase.cpp
${_generate}/private/${_interface_name}Events.cpp
${_generate}/private/${_interface_name}Proxy.cpp
${_generate}/private/${_interface_name}Stub.cpp
${_generate}/private/NE${_interface_name}.cpp
${_generate}/private/${_interface_name}Events.hpp
${_generate}/private/${_interface_name}Proxy.hpp
${_generate}/${_interface_name}ClientBase.hpp
${_generate}/${_interface_name}Stub.hpp
${_generate}/NE${_interface_name}.hpp
)
# Add generated files to an existing or new static library
if (TARGET ${lib_name})
target_sources(${lib_name} PRIVATE "${_sources}")
else()
message(STATUS "AREG Setup: Adding new service interface library ${lib_name}")
addStaticLib(${lib_name} "${_sources}")
target_compile_options(${lib_name} PRIVATE "${AREG_OPT_DISABLE_WARN_CODEGEN}")
endif()
unset(_generate)
unset(_sources)
endmacro(macro_add_service_interface)
# ---------------------------------------------------------------------------
# Function ...: addServiceInterfaceEx
# Purpose ....: The addServiceInterfaceEx function acts as a wrapper for
# macro_add_service_interface, facilitating the generation of code
# and header files for a Service Interface document (.siml file)
# within a specified static library. This function assumes the
# code generator tool is located at ${AREG_SDK_TOOLS}/codegen.jar.
# The generated files are placed within the ${AREG_GENERATE_DIR},
# with a subdirectory structure specified by ${generate_path}.
# Parameters .: ${lib_name} -- The name of the static library to be created for the generated Service Interface code.
# ${source_root} -- The root directory containing the project's source files.
# ${siml_path} -- Path to the Service Interface document file (.siml), relative to the specified ${source_root}.
# ${generate_path} -- Subdirectory path within ${AREG_GENERATE_DIR} where the generated files will be stored.
# Usage ......: addServiceInterfaceEx(<library-name> <source-root> <service-interface-relative-path> <relative-path-to-generate-codes>)
# Example ....:
# addServiceInterfaceEx(fun_library "/home/dev/project/fun/src" "fun/service/interfaces/FunService.siml" "fun/service/interfaces")
# ---------------------------------------------------------------------------