@@ -21,20 +21,31 @@ if (NOT TARGET _FreeRTOS_kernel_inclusion_marker)
21
21
22
22
pico_is_top_level_project(FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
23
23
24
- # The real work gets done in library.cmake which is called at the end of pico_sdk_init
25
- list (APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR} /library.cmake)
26
-
27
- # We need to inject the following header file into ALL SDK files (which we do via the config header)
28
- list (APPEND PICO_CONFIG_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR} /include /freertos_sdk_config.h)
29
-
30
- if (FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
31
- message ("FreeRTOS: initialize SDK since we're the top-level" )
32
- # Initialize the SDK
33
- pico_sdk_init()
24
+ # if the SDK has already been initialized, then just add our libraries now - this allows
25
+ # this FreeRTOS port to just be added as a sub-directory or include within another project, rather than
26
+ # having to include it at the top level before pico_sdk_init()
27
+ if (TARGET _pico_sdk_inclusion_marker)
28
+ if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.2" )
29
+ message (FATAL_ERROR "Require at least Raspberry Pi Pico SDK version 1.3.2 to include FreeRTOS after pico_sdk_init()" )
30
+ endif ()
31
+ include (${CMAKE_CURRENT_LIST_DIR} /library.cmake)
34
32
else ()
35
- set (PICO_SDK_POST_LIST_FILES ${PICO_SDK_POST_LIST_FILES} PARENT_SCOPE)
36
- set (PICO_CONFIG_HEADER_FILES ${PICO_CONFIG_HEADER_FILES} PARENT_SCOPE)
37
- set (FREERTOS_KERNEL_PATH ${FREERTOS_KERNEL_PATH} PARENT_SCOPE)
33
+ # The real work gets done in library.cmake which is called at the end of pico_sdk_init
34
+ list (APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR} /library.cmake)
35
+ if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.2" )
36
+ # We need to inject the following header file into ALL SDK files (which we do via the config header)
37
+ list (APPEND PICO_CONFIG_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR} /include /freertos_sdk_config.h)
38
+ endif ()
39
+
40
+ if (FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
41
+ message ("FreeRTOS: initialize SDK since we're the top-level" )
42
+ # Initialize the SDK
43
+ pico_sdk_init()
44
+ else ()
45
+ set (FREERTOS_KERNEL_PATH ${FREERTOS_KERNEL_PATH} PARENT_SCOPE)
46
+ set (PICO_CONFIG_HEADER_FILES ${PICO_CONFIG_HEADER_FILES} PARENT_SCOPE)
47
+ set (PICO_SDK_POST_LIST_FILES ${PICO_SDK_POST_LIST_FILES} PARENT_SCOPE)
48
+ endif ()
38
49
endif ()
39
50
endif ()
40
51
0 commit comments