forked from nanoframework/nf-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
879 lines (675 loc) · 33.3 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
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#
cmake_minimum_required(VERSION 3.15)
include(CMakeToolsHelpers OPTIONAL)
include(ExternalProject)
if (BUILD_VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON" FORCE) # debug helper
endif()
# the following prevents launchin a build in the source tree
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# fatal error and message explaining this
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(STATUS "\n-- ###############################################\n")
message(STATUS "Please run the build outside of the source tree.\n\n")
message(STATUS "Hint: create a 'build' folder and run CMake from there..")
message(STATUS "###############################################\n\n")
message(FATAL_ERROR "Build launched in the source tree.")
endif()
#########################################
########################################################
# path to local CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
########################################################
include(NF_Utils)
######################################################
# set build type to release if not specified otherwise
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
######################################################
# add compiler define for DEBUG
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")
######################################################
# set time stamp of build
string(TIMESTAMP BUILD_TIMESTAMP UTC)
######################################################
#######################
# handle RTOSes choice
if(${RTOS} STREQUAL "")
# no RTOS selected, defaulting to ChibiOS
set(RTOS "CHIBIOS")
endif()
# list of supported RTOSes
# when adding a new RTOS add the corresponding string below AND...
# ... also on the compare block below
set(RTOS_SUPPORTED "CHIBIOS" "FREERTOS" "FREERTOS_ESP32" "TI_SIMPLELINK" CACHE INTERNAL "supported RTOS options")
list(FIND RTOS_SUPPORTED ${RTOS} RTOS_INDEX)
if(RTOS_INDEX EQUAL -1)
message(FATAL_ERROR "\n\n'${RTOS}' is an invalid option for RTOS. Please choose a valid RTOS.\n\n")
else()
message(STATUS "\nSetting RTOS to ${RTOS}\n")
endif()
string(COMPARE EQUAL "CHIBIOS" ${RTOS} RTOS_CHIBIOS_CHECK)
string(COMPARE EQUAL "FREERTOS" ${RTOS} RTOS_FREERTOS_CHECK)
string(COMPARE EQUAL "FREERTOS_ESP32" ${RTOS} RTOS_FREERTOS_ESP32_CHECK)
string(COMPARE EQUAL "TI_SIMPLELINK" ${RTOS} RTOS_TI_SIMPLELINK_CHECK)
##########################################################################
if(RTOS_FREERTOS_CHECK)
set(RTOS_FREERTOS_CHECK TRUE)
set(RTOS_FREERTOS_ESP32_CHECK FALSE)
set(RTOS_TI_SIMPLELINK_CHECK FALSE)
set(RTOS_CHIBIOS_CHECK FALSE)
endif()
if(RTOS_FREERTOS_ESP32_CHECK)
set(RTOS_FREERTOS_CHECK FALSE)
set(RTOS_FREERTOS_ESP32_CHECK TRUE)
set(RTOS_TI_SIMPLELINK_CHECK FALSE)
set(RTOS_CHIBIOS_CHECK FALSE)
endif()
if(RTOS_CHIBIOS_CHECK)
set(RTOS_CHIBIOS_CHECK TRUE)
set(RTOS_FREERTOS_CHECK FALSE)
set(RTOS_FREERTOS_ESP32_CHECK FALSE)
set(RTOS_TI_SIMPLELINK_CHECK FALSE)
endif()
if(RTOS_TI_SIMPLELINK_CHECK)
set(RTOS_TI_SIMPLELINK_CHECK TRUE)
set(RTOS_FREERTOS_CHECK FALSE)
set(RTOS_FREERTOS_ESP32_CHECK FALSE)
set(RTOS_CHIBIOS_CHECK FALSE)
endif()
#######################
# check for toolchain path (this is required for Windows builds and we are only building on Windows)
if(NOT DEFINED TOOLCHAIN_PREFIX)
message(STATUS "\n-- ########################################\nNo TOOLCHAIN_PREFIX specified, need one!\nCall CMake with -DTOOLCHAIN_PREFIX=\"<path_to_your_gcc_toolchain>\"\n specifing the path to your GCC toolchain (ex: E:/GNU_Tools_ARM_Embedded/5_4_2016q3)")
message(STATUS "\nNOTE: mind the forward slash in the path, without trailing slash.)")
message(STATUS "########################################\n\n")
message(FATAL_ERROR "No TOOLCHAIN_PREFIX specified")
endif()
# Set up short path substitution on Windows
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
if(EXISTS ${CMAKE_SOURCE_DIR}/SetNFRoot.bat)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/SetNFRoot.bat OUTPUT_VARIABLE NFROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ENV{nfRoot} ${NFROOT})
endif()
endif()
#########################################
# set default version
if(NOT BUILD_VERSION)
set(BUILD_VERSION 0.0.0.0)
endif()
project(nanoFramework VERSION ${BUILD_VERSION})
set(NANOBOOTER_PROJECT_NAME "nanoBooter")
set(NANOCLR_PROJECT_NAME "nanoCLR")
#######################
message(STATUS "")
message(STATUS "Building nanoFramework version ${PROJECT_VERSION} using build type '${CMAKE_BUILD_TYPE}'.")
message(STATUS "Source directory is '${CMAKE_SOURCE_DIR}'.")
message(STATUS "Build directory is '${CMAKE_BINARY_DIR}'.")
message(STATUS "")
#######################
#################################################################
# ouput RTM build option
# Build RTM version of firmware (default is OFF so the build is not RTM and the CLR outputs some debug informations)
option(NF_BUILD_RTM "option to build with RTM definition")
if(NF_BUILD_RTM)
message(STATUS "***************************")
message(STATUS "** Building RTM firmware **")
message(STATUS "***************************")
message(STATUS "")
endif()
#################################################################
if(RTOS_CHIBIOS_CHECK OR RTOS_TI_SIMPLELINK_CHECK)
#################################################################
# clear some CMake flavor flags that are being set as default
# in the GNU compiler init
# we want to control and fine tune these
set(CMAKE_C_FLAGS_DEBUG "" CACHE INTERNAL "clear c compiler flags")
set(CMAKE_C_FLAGS_MINSIZEREL "" CACHE INTERNAL "clear c compiler flags")
set(CMAKE_C_FLAGS_RELEASE "" CACHE INTERNAL "clear c compiler flags")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "clear c compiler flags")
set(CMAKE_CXX_FLAGS_DEBUG "" CACHE INTERNAL "clear c++ compiler flags")
set(CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE INTERNAL "clear c++ compiler flags")
set(CMAKE_CXX_FLAGS_RELEASE "" CACHE INTERNAL "clear c++ compiler flags")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "clear c++ compiler flags")
#################################################################
#################################################################
# clear default libraries that are set by CMake
# we want to control
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "" CACHE INTERNAL "clear c linker default libs")
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "" CACHE INTERNAL "clear c++ linker default libs")
#################################################################
endif()
#################################################################################
# chooses if double-point float point support is provided by the platform
# (default is OFF which means that single-precision floating point is effective)
option(DP_FLOATINGPOINT "option to enable support for double-precision floating point")
if(DP_FLOATINGPOINT)
set(TARGET_DP_FLOATINGPOINT TRUE CACHE INTERNAL "DP FP support")
message(STATUS "Double-precision floating point is effective")
else()
set(TARGET_DP_FLOATINGPOINT FALSE CACHE INTERNAL "DP FP support")
message(STATUS "Single-precision floating point is effective")
endif()
#################################################################################
# chooses if build without complex math functions
# (default is OFF which means that all floating point math functions are available)
option(NF_FEATURE_LIGHT_MATH "option to build without complex math functions")
if(NF_FEATURE_LIGHT_MATH)
set(TARGET_LIGHT_MATH TRUE CACHE INTERNAL "Complex Math functions disabled")
message(STATUS "Complex math functions available")
else()
set(TARGET_LIGHT_MATH FALSE CACHE INTERNAL "Complex Math functions enabled")
message(STATUS "Complex math functions not available")
endif()
###################################################################################
# chooses if platform provides support for converting string to values on any base
# (default is OFF which means that conversion to value from base 10 and 16 (partial) is effective)
option(SUPPORT_ANY_BASE_CONVERSION "option to enable support for converting strings to value on any base")
if(SUPPORT_ANY_BASE_CONVERSION)
set(TARGET_SUPPORT_ANY_BASE_CONVERSION TRUE CACHE INTERNAL "Option for string conversion to value from any base")
message(STATUS "String conversion to value on any base is effective")
else()
set(TARGET_SUPPORT_ANY_BASE_CONVERSION FALSE CACHE INTERNAL "Option for string conversion to value from base 10 and partial for 16")
message(STATUS "String conversion to value from base 10 and 16 (partial) is effective")
endif()
#################################################################
# true random number generation option supported by hardware
option(USE_RNG "option to enable use of true random generator hardware block" ON)
if(USE_RNG)
message(STATUS "Random Number Generation by target MCU is activated")
else()
message(STATUS "Random Number Generation by target MCU **IS NOT** activated")
endif()
#################################################################
# nanoFramework features
#################################################################
###################################################################
# debugger (default is OFF so no support for debugging is included
option(NF_FEATURE_DEBUGGER "option to enable support for debugging")
if(NF_FEATURE_DEBUGGER)
message(STATUS "Support for debugging managed applications is included.")
else()
message(STATUS "Support for debugging managed applications **IS NOT** included.")
endif()
#################################################################
# enables Application Domains support in nanoCLR
# (default is OFF so Application Domains is NOT supported)
option(NF_FEATURE_USE_APPDOMAINS "option to enable Application Domains")
if(NF_FEATURE_USE_APPDOMAINS)
message(STATUS "Application Domains support is included")
else()
message(STATUS "Application Domains support **IS NOT** included")
endif()
#################################################################
# disable all trace messages and checks on CLR
# (default is OFF so all traces and checks are enabled)
option(NF_PLATFORM_NO_CLR_TRACE "option to disable all trace stuff in CLR")
if(NF_PLATFORM_NO_CLR_TRACE)
message(STATUS "CLR has all trace messages and checks DISABLED")
else()
message(STATUS "CLR has all trace messages and checks enabled")
endif()
#################################################################
# disable CLR IL inlining
# (default is OFF so CLR IL inline is enabled)
option(NF_CLR_NO_IL_INLINE "option to disable CLR IL inlining")
if(NF_CLR_NO_IL_INLINE)
message(STATUS "CLR IL inlining is DISABLED")
else()
message(STATUS "CLR IL inlining is enabled")
endif()
#################################################################
# enables configuration block storage support
# (default is OFF so Configuration block storage is NOT supported)
option(NF_FEATURE_HAS_CONFIG_BLOCK "option to enable configuration block storage")
if(NF_FEATURE_HAS_CONFIG_BLOCK)
set(TARGET_HAS_CONFIG_BLOCK TRUE CACHE INTERNAL "Option for config block")
message(STATUS "Configuration block storage is included")
else()
set(TARGET_HAS_CONFIG_BLOCK FALSE CACHE INTERNAL "Option for config block")
message(STATUS "Configuration block storage **IS NOT** included")
endif()
#################################################################
# enables support for SD Card
# (default is OFF so SD Card is NOT supported)
option(NF_FEATURE_HAS_SDCARD "option to enable support for SD Card")
if(NF_FEATURE_HAS_SDCARD)
# this feature currently is supported only on ChibiOS, iMX.RT FreeRTOS and ESP32 FreeRTOS
if(NOT RTOS_CHIBIOS_CHECK AND NOT RTOS_FREERTOS_CHECK AND NOT RTOS_FREERTOS_ESP32_CHECK)
message(FATAL_ERROR "Support for SD Card is only available for ChibiOS Cortex-M targets, iMX.RT FreeRTOS and ESP32 targets..")
endif()
# force inclusion of Windows.Storage API
set(API_Windows.Storage ON CACHE INTERNAL "Forcing Windows.Storage API option to ON")
# force inclusion of System.IO.FileSystem API
set(API_System.IO.FileSystem ON CACHE INTERNAL "Forcing System.IO.FileSystem API option to ON")
if(RTOS_FREERTOS_ESP32_CHECK)
# can't System.IO.FileSystem API because of lack of suppporting configuration for FATFS. See issue #668
message(WARNING "Can't use System.IO.FileSystem API in ESP32 targets because of FATFS config. See issue #668.")
# force **REMOVAL** of System.IO.FileSystem API
set(API_System.IO.FileSystem OFF CACHE INTERNAL "Forcing **REMOVAL** of System.IO.FileSystem API option")
endif()
message(STATUS "Support for SD Card is included")
else()
message(STATUS "Support for SD Card **IS NOT** included")
endif()
#################################################################
#################################################################
# enables USB Mass Storage support
# (default is OFF so USB Mass Storage is NOT supported)
option(NF_FEATURE_HAS_USB_MSD "option to enable USB Mass Storage")
if(NF_FEATURE_HAS_USB_MSD)
# this feature currently is supported only on ChibiOS
if(NOT RTOS_CHIBIOS_CHECK)
message(FATAL_ERROR "Support for USB Mass Storage is only available for ChibiOS Cortex-M targets.")
endif()
# this feature requires inclusion of ChibiOS contribution repository
set(CHIBIOS_CONTRIB_REQUIRED ON CACHE INTERNAL "Forcing ChibiOS contribution repo option to ON")
# force inclusion of Windows.Storage API
set(API_Windows.Storage ON CACHE INTERNAL "Forcing Windows.Storage API option to ON")
# force inclusion of System.IO.FileSystem API
set(API_System.IO.FileSystem ON CACHE INTERNAL "Forcing System.IO.FileSystem API option to ON")
if(RTOS_FREERTOS_ESP32_CHECK)
# can't System.IO.FileSystem API because of lack of suppporting configuration for FATFS. See issue #668
message(WARNING "Can't use System.IO.FileSystem API in ESP32 targets because of FATFS config. See issue #668.")
# force **REMOVAL** of System.IO.FileSystem API
set(API_System.IO.FileSystem OFF CACHE INTERNAL "Forcing **REMOVAL** of System.IO.FileSystem API option")
endif()
message(STATUS "Support for USB Mass Storage is included")
else()
message(STATUS "Support for USB Mass Storage **IS NOT** included")
endif()
#################################################################
#################################################################
# enables support for SPI file system
# (default is OFF so SPIFFS is NOT supported)
option(NF_FEATURE_USE_SPIFFS "option to enable support for SPI file system")
if(NF_FEATURE_USE_SPIFFS)
# this feature currently is supported only on ChibiOS and ESP32
if(NOT RTOS_CHIBIOS_CHECK)
message(FATAL_ERROR "Support for SPIFFS is only available for ChibiOS Cortex-M and ESP32 targets.")
endif()
# force inclusion of Windows.Storage API
set(API_Windows.Storage ON CACHE INTERNAL "Forcing Windows.Storage API option to ON")
set(NF_FEATURE_USE_SPIFFS_OPTION TRUE CACHE INTERNAL "Set nF SPIFFS feature TRUE")
message(STATUS "Support for SPIFFS is included")
else()
set(NF_FEATURE_USE_SPIFFS_OPTION FALSE CACHE INTERNAL "Set nF SPIFFS feature FALSE")
message(STATUS "Support for SPIFFS **IS NOT** included")
endif()
#################################################################
# target has nanoBooter
# (default is ON so target device HAS nanoBooter)
option(NF_TARGET_HAS_NANOBOOTER "option to signal if target implements nanoBooter" ON)
if(NF_TARGET_HAS_NANOBOOTER)
set(TARGET_HAS_NANOBOOTER TRUE CACHE INTERNAL "Option for nanoBooter implementation")
message(STATUS "Target implements nanoBooter")
else()
set(TARGET_HAS_NANOBOOTER FALSE CACHE INTERNAL "Option for nanoBooter implementation")
message(STATUS "Target DOES NOT implement nanoBooter")
endif()
#################################################################
if(RTOS_CHIBIOS_CHECK)
#################################################################
# ARM Cortex-M Single Wire Output (SWO)
# (default is OFF so no SWO output)
option(SWO_OUTPUT "option to enable SWO")
if(SWO_OUTPUT)
set(SWO_OUTPUT_OPTION TRUE CACHE INTERNAL "Single Wire Output Option")
message(STATUS "Single Wire Output (SWO) enabled")
else()
set(SWO_OUTPUT_OPTION FALSE CACHE INTERNAL "Single Wire Output Option")
endif()
#################################################################
#################################################################
# enables use of ChibiOS Community contribution
# (default is OFF so ChibiOS Community is NOT included)
option(CHIBIOS_CONTRIB_REQUIRED "option to include ChibiOS Community contributions repository")
#################################################################
endif()
#################################################################
# Wire Protocol options
option(NF_WP_IMPLEMENTS_CRC32 "option to report if target implements CRC32 in Wire Protocol")
# handle Wire Protocol _TRACE_ preferences, if any
option(NF_WP_TRACE_ERRORS "option to Trace errors with Wire Protocol")
option(NF_WP_TRACE_HEADERS "option to Trace headers with Wire Protocol")
option(NF_WP_TRACE_STATE "option to Trace state with Wire Protocol")
option(NF_WP_TRACE_NODATA "option to Trace empty packets with Wire Protocol")
option(NF_WP_TRACE_ALL "option to Trace with Wire Protocol")
# reports Wire Protocol CRC32 implementation
if(NF_WP_IMPLEMENTS_CRC32)
message(STATUS "Wire Protocol implements CRC32")
else()
message(STATUS "Wire Protocol does NOT implement CRC32")
endif()
#################################################################
# enables Networking support in nanoCLR
# declares Networking option
# needs to show before the API namespaces processing because it's used there
# (default is OFF so Networking is NOT supported)
option(USE_NETWORKING_OPTION "option to use networking")
# (default is OFF so mbed TLS is NOT used)
option(NF_SECURITY_MBEDTLS "option to use mbed TLS as the network security provider")
# set default option for SNTP to ON
option(NF_NETWORKING_SNTP "option to use add SNTP support, requires networking otherwise has no effect" ON)
# (default is OFF so driver is NOT used)
option(NF_NETWORKING_ENC28J60 "option to use ENC28J60 network driver")
#################################################################
#############################################
# handles inclusion of System.Reflection API
#############################################
# set default option for SNTP to ON
option(NF_FEATURE_SUPPORT_REFLECTION "option to add support for System.Reflection API" ON)
if(NF_FEATURE_SUPPORT_REFLECTION)
set(TARGET_NANOCLR_REFLECTION TRUE CACHE INTERNAL "enable support for System.Reflection API")
message(STATUS "Support for System.Reflection API enabled")
else()
set(TARGET_NANOCLR_REFLECTION FALSE CACHE INTERNAL "DISABLE support for System.Reflection API")
message(STATUS "Support for System.Reflection API **IS NOT** enabled")
endif()
#################################################################
#################################################################
#############################################
# handles inclusion of System.Collections API
#############################################
if(API_nanoFramework.System.Collections)
set(TARGET_SYSTEM_COLLECTIONS TRUE CACHE INTERNAL "enable support for System.Collections API")
message(STATUS "Support for System.Collections API enabled")
else()
set(TARGET_SYSTEM_COLLECTIONS FALSE CACHE INTERNAL "DISABLE support for System.Collections API")
message(STATUS "Support for System.Collections API **IS NOT** enabled")
endif()
#################################################################
#############################################
# handles inclusion of System.Text API
#############################################
if(API_nanoFramework.System.Text)
set(TARGET_SYSTEM_TEXT TRUE CACHE INTERNAL "enable support for System.Text API")
message(STATUS "Support for System.Text API enabled")
else()
set(TARGET_SYSTEM_TEXT FALSE CACHE INTERNAL "DISABLE support for System.Text API")
message(STATUS "Support for System.Text API **IS NOT** enabled")
endif()
#################################################################
#################################################################
# manage HAL/PAL required for API namespaces
#################################################################
# for some APIs we need to enable the device in the HAL config
# and/or manage other APIs that are required
if( API_nanoFramework.Devices.OneWire OR
API_Windows.Devices.SerialCommunication OR
API_System.IO.Ports)
set(HAL_USE_UART_OPTION TRUE CACHE INTERNAL "HAL OneWire for nanoFramework.Devices.OneWire")
else()
set(HAL_USE_UART_OPTION FALSE CACHE INTERNAL "HAL OneWire for nanoFramework.Devices.OneWire")
endif()
if( API_System.Net)
# set NETWORKING option to true
set(USE_NETWORKING_OPTION TRUE CACHE INTERNAL "NF feature NETWORKING")
# set Security module to use
if(NF_SECURITY_MBEDTLS )
set(USE_SECURITY_MBEDTLS_OPTION TRUE CACHE INTERNAL "NF security MBEDTLS")
endif()
if(NF_NETWORKING_ENC28J60)
set(USE_ENC28J60_DRIVER_OPTION TRUE CACHE INTERNAL "NF ENC28J60 network driver")
else()
set(USE_ENC28J60_DRIVER_OPTION FALSE CACHE INTERNAL "NF ENC28J60 network driver")
endif()
if(API_Windows.Devices.Wifi)
set(USE_WIFI_OPTION TRUE CACHE INTERNAL "Wifi for Windows.Devices.WiFi")
else()
set(USE_WIFI_OPTION FALSE CACHE INTERNAL "Wifi for Windows.Devices.WiFi")
endif()
else()
# need to force SNTP to OFF
set(NF_NETWORKING_SNTP FALSE CACHE INTERNAL "SNTP is off as there is no network support")
endif()
if(API_Windows.Devices.Adc)
set(HAL_USE_ADC_OPTION TRUE CACHE INTERNAL "HAL ADC for Windows.Devices.Adc")
else()
set(HAL_USE_ADC_OPTION FALSE CACHE INTERNAL "HAL ADC for Windows.Devices.Adc")
endif()
if(API_System.Device.Dac)
set(HAL_USE_DAC_OPTION TRUE CACHE INTERNAL "HAL DAC for System.Device.Dac")
else()
set(HAL_USE_DAC_OPTION FALSE CACHE INTERNAL "HAL DAC for System.Device.Dac")
endif()
if(API_System.Device.Gpio)
set(HAL_USE_GPIO_OPTION TRUE CACHE INTERNAL "HAL GPIO for System.Device.Gpio")
else()
set(HAL_USE_GPIO_OPTION FALSE CACHE INTERNAL "HAL GPIO for System.Device.Gpio")
endif()
if(API_Windows.Devices.Gpio)
set(HAL_USE_GPIO_OPTION TRUE CACHE INTERNAL "HAL GPIO for Windows.Devices.Gpio")
else()
set(HAL_USE_GPIO_OPTION FALSE CACHE INTERNAL "HAL GPIO for Windows.Devices.Gpio")
endif()
if(API_System.Device.I2c)
set(HAL_USE_I2C_OPTION TRUE CACHE INTERNAL "HAL I2C for System.Device.I2c")
else()
set(HAL_USE_I2C_OPTION FALSE CACHE INTERNAL "HAL I2C for System.Device.I2c")
endif()
if(API_Windows.Devices.I2c)
set(HAL_USE_I2C_OPTION TRUE CACHE INTERNAL "HAL I2C for Windows.Devices.I2c")
else()
set(HAL_USE_I2C_OPTION FALSE CACHE INTERNAL "HAL I2C for Windows.Devices.I2c")
endif()
if(API_Windows.Devices.Pwm)
set(HAL_USE_PWM_OPTION TRUE CACHE INTERNAL "HAL PWM for Windows.Devices.Pwm")
else()
set(HAL_USE_PWM_OPTION FALSE CACHE INTERNAL "HAL PWM for Windows.Devices.Pwm")
endif()
if(API_Windows.Devices.Spi)
set(HAL_USE_SPI_OPTION TRUE CACHE INTERNAL "HAL SPI for Windows.Devices.Spi")
else()
set(HAL_USE_SPI_OPTION FALSE CACHE INTERNAL "HAL SPI for Windows.Devices.Spi")
endif()
if(API_System.Device.Spi)
set(HAL_USE_SPI_OPTION TRUE CACHE INTERNAL "HAL SPI for System.Device.Spi")
else()
set(HAL_USE_SPI_OPTION FALSE CACHE INTERNAL "HAL SPI for System.Device.Spi")
endif()
if(API_nanoFramework.Devices.Can)
set(HAL_USE_CAN_OPTION TRUE CACHE INTERNAL "HAL CAN for nanoFramework.Devices.Can")
else()
set(HAL_USE_CAN_OPTION FALSE CACHE INTERNAL "HAL CAN for nanoFramework.Devices.Can")
endif()
if(API_nanoFramework.Devices.OneWire)
set(HAL_USE_STM32_ONEWIRE_OPTION TRUE CACHE INTERNAL "HAL STM32_ONEWIRE for nanoFramework.Devices.OneWire")
else()
set(HAL_USE_STM32_ONEWIRE_OPTION FALSE CACHE INTERNAL "HAL STM32_ONEWIRE for nanoFramework.Devices.OneWire")
endif()
#################################################################################
# Option to include the graphics bitmap primitives
#################################################################################
if(API_nanoFramework.Graphics)
set(NANOCLR_GRAPHICS TRUE CACHE INTERNAL "Graphics Support")
else()
set(NANOCLR_GRAPHICS FALSE CACHE INTERNAL "No Graphics Support")
endif()
if(NF_FEATURE_HAS_SDCARD)
set(HAL_USE_SDC_OPTION TRUE CACHE INTERNAL "HAL SDC for NF_FEATURE_HAS_SDCARD")
else()
set(HAL_USE_SDC_OPTION FALSE CACHE INTERNAL "HAL SDC for NF_FEATURE_HAS_SDCARD")
endif()
if(NF_FEATURE_HAS_USB_MSD)
set(HAL_USBH_USE_MSD_OPTION TRUE CACHE INTERNAL "HAL USBH_USE_MSD for NF_FEATURE_HAS_USB_MSD")
else()
set(HAL_USBH_USE_MSD_OPTION FALSE CACHE INTERNAL "HAL USBH_USE_MSD for NF_FEATURE_HAS_USB_MSD")
endif()
#################################################################
# manage dependent APIs required for some API namespaces
#################################################################
# include nanoFramework.Runtime.Events API
if( API_nanoFramework.Devices.OneWire OR
API_System.Net OR
API_System.Device.Gpio OR
API_Windows.Devices.Gpio OR
API_Windows.Devices.SerialCommunication OR
API_System.IO.Ports OR
API_nanoFramework.Devices.Can OR
API_Windows.Storage OR
API_System.IO.FileSystem)
# these APIs requires nanoFramework.Runtime.Events
set(API_nanoFramework.Runtime.Events ON CACHE INTERNAL "enable of API_nanoFramework.Runtime.Events")
endif()
if(API_System.Net)
# manage inclusion of SNTP
if(NF_NETWORKING_SNTP)
set(API_nanoFramework.Networking.Sntp ON CACHE INTERNAL "enable API_nanoFramework.Networking.Sntp")
else()
set(API_nanoFramework.Networking.Sntp OFF CACHE INTERNAL "disable API_nanoFramework.Networking.Sntp")
endif()
endif()
#################################################################
# handles Networking support at HAL level
if(USE_NETWORKING_OPTION)
set(HAL_USE_MAC_OPTION TRUE CACHE INTERNAL "HAL MAC for USE_NETWORKING_OPTION")
if(NF_SECURITY_MBEDTLS)
message(STATUS "Support for networking enabled with security from mbedTLS")
elseif(RTOS_TI_SIMPLELINK_CHECK)
message(STATUS "Support for networking enabled with security")
else()
message(STATUS "Support for networking enabled WITHOUT security")
endif()
if(NF_NETWORKING_ENC28J60)
message(STATUS "Support for ENC28j60 network driver enabled")
endif()
# sanity check for missing configuration block option
# which is required for network
if(NOT NF_FEATURE_HAS_CONFIG_BLOCK)
message(FATAL_ERROR "\n\nERROR: network build requires NF_FEATURE_HAS_CONFIG_BLOCK build option to be 'ON'. Make sure you have that on your cmake-variants or in the build command line.")
endif()
else()
set(HAL_USE_MAC_OPTION FALSE CACHE INTERNAL "HAL MAC for USE_NETWORKING_OPTION")
message(STATUS "Support for networking **IS NOT** enabled")
endif()
#################################################################
#################################################################
# enables filesysytem support in nanoCLR
if(NF_FEATURE_HAS_SDCARD OR NF_FEATURE_HAS_USB_MSD)
set(USE_FILESYSTEM_OPTION TRUE CACHE INTERNAL "NF feature FILESYSTEM")
else()
set(USE_FILESYSTEM_OPTION FALSE CACHE INTERNAL "NF feature FILESYSTEM")
endif()
#################################################################
#################################################################
# RTC (real time clock) (default is OFF so RTC is NOT included)
option(NF_FEATURE_RTC "option to use hardware RTC")
if(NF_FEATURE_RTC)
set(HAL_USE_RTC_OPTION TRUE CACHE INTERNAL "NF feature RTC")
else()
set(HAL_USE_RTC_OPTION FALSE CACHE INTERNAL "NF feature RTC")
endif()
#################################################################
#################################################################
# CPU watchdog (default is ON so watchdog is included)
option(NF_FEATURE_WATCHDOG "option to use hardware watchdog" ON)
if(NF_FEATURE_WATCHDOG)
set(HAL_USE_WDG_OPTION TRUE CACHE INTERNAL "NF feature watchdog")
else()
set(HAL_USE_WDG_OPTION FALSE CACHE INTERNAL "NF feature watchdog")
endif()
#################################################################
#################################################################
# Baudrate for serial communication
if(TARGET_SERIAL_BAUDRATE)
message(STATUS "Baudrate for serial communication was set to ${TARGET_SERIAL_BAUDRATE}.")
endif()
#################################################################
#################################################################
# Override target name on device properties
if(TARGET_NAME)
message(STATUS "Target name set to ${TARGET_NAME}.")
else()
# use target board as the name
set(TARGET_NAME ${TARGET_BOARD})
endif()
#################################################################
#######################
# ChibiOS
if(RTOS_CHIBIOS_CHECK)
# Define base path for the class libraries
SET_BASE_PATH_FOR_LIBRARIES_MODULES(${CMAKE_SOURCE_DIR}/targets/ChibiOS/_nanoCLR)
add_subdirectory(targets/ChibiOS)
# now add the subdirectory for the board
# try to find board in the targets folder
if(EXISTS ${CMAKE_SOURCE_DIR}/targets/ChibiOS/${TARGET_BOARD})
# board found
message(STATUS "Support for target board '${TARGET_BOARD}' found")
message(STATUS "${CHIBIOS_BOARD_DEFINITIONS_LOCATION}")
# add TARGET board directory
add_subdirectory(${CMAKE_SOURCE_DIR}/targets/ChibiOS/${TARGET_BOARD})
else()
# try to find board in the Community targets folder
if(EXISTS ${CMAKE_SOURCE_DIR}/targets-community/ChibiOS/${TARGET_BOARD})
# board found
message(STATUS "Support for target board '${TARGET_BOARD}' found in Community targets")
message(STATUS "${CHIBIOS_BOARD_DEFINITIONS_LOCATION}")
# add TARGET board directory from Community
add_subdirectory(targets-community/ChibiOS/${TARGET_BOARD})
else()
# board NOT found in targets folder
# board NOT found in targets folder
message(FATAL_ERROR "\n\nSorry but support for ${TARGET_BOARD} target is not available...\n\You can wait for that to be added or you might want to contribute and start working on a PR for that.\n\n")
endif()
endif()
#######################
# FreeRTOS
elseif(RTOS_FREERTOS_CHECK)
add_subdirectory(targets/FreeRTOS)
#######################
# FreeRTOS ESP32
elseif(RTOS_FREERTOS_ESP32_CHECK)
if(${TARGET_SERIES} STREQUAL "ESP32")
message(STATUS "Platform ESP32 target board: ${TARGET_BOARD}")
# check watchdog feature
# EPS32 build has watchdog enabled by default, so setting it to OFF doesn't make sense
# becuase the build system can't honour that preference
if(NOT NF_FEATURE_WATCHDOG)
message(FATAL_ERROR "\n\nESP32 watchdog is enabled by default in so you can't have the NF_FEATURE_WATCHDOG option set to OFF.\n\n")
endif()
# Define base path for the class libraries
SET_BASE_PATH_FOR_LIBRARIES_MODULES(${CMAKE_SOURCE_DIR}/targets/FreeRTOS_ESP32/${TARGET_BOARD}/nanoCLR)
add_subdirectory(targets/FreeRTOS_ESP32)
# set target base location
set(TARGET_BASE_LOCATION ${CMAKE_SOURCE_DIR}/targets/FreeRTOS_ESP32/${TARGET_BOARD})
add_subdirectory(targets/FreeRTOS_ESP32/${TARGET_BOARD})
endif()
#######################
# TI_SIMPLELINK
elseif(RTOS_TI_SIMPLELINK_CHECK)
# Define base path for the class libraries
SET_BASE_PATH_FOR_LIBRARIES_MODULES(${CMAKE_SOURCE_DIR}/targets/TI-SimpleLink/_nanoCLR)
# now add the subdirectory for the board
# try to find board in the targets folder
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/targets/TI-SimpleLink/${TARGET_BOARD})
# set target base location
set(TARGET_BASE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/targets/TI-SimpleLink/${TARGET_BOARD})
# board found
message(STATUS "Support for target board '${TARGET_BOARD}' found")
message(STATUS "${TARGET_BASE_LOCATION}")
else()
# try to find board in the Community targets folder
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/targets-community/TI-SimpleLink/${TARGET_BOARD})
# set target base location
set(TARGET_BASE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/targets-community/TI-SimpleLink/${TARGET_BOARD})
# board found
message(STATUS "Support for target board '${TARGET_BOARD}' found in Community targets")
message(STATUS "${TARGET_BASE_LOCATION}")
else()
# board NOT found in targets folder
# board NOT found in targets folder
message(FATAL_ERROR "\n\nSorry but support for ${TARGET_BOARD} target is not available...\n\You can wait for that to be added or you might want to contribute and start working on a PR for that.\n\n")
endif()
endif()
# add common directory for SimpleLink
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/targets/TI-SimpleLink)
# add TARGET board directory
add_subdirectory(${TARGET_BASE_LOCATION})
endif()