Skip to content

Commit fc12b5b

Browse files
conarakar-rahul-awschinglee-iotaggargSkptak
authored andcommitted
Remove default behaviour of FREERTOS_HEAP. (FreeRTOS#807)
To build a complete static application (configSUPPORT_DYNAMIC_ALLOCATION set to 0) an ugly workaround is necessary, because when FREERTOS_HEAP is not set, heap 4 is automatically selected in the current CMake. Co-authored-by: kar-rahul-aws <[email protected]> Co-authored-by: chinglee-iot <[email protected]> Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]> Co-authored-by: Soren Ptak <[email protected]>
1 parent 1ef1484 commit fc12b5b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ cmake_minimum_required(VERSION 3.15)
88
#
99
# DEPRECATED: FREERTOS_CONFIG_FILE_DIRECTORY - but still supported if no freertos_config defined for now.
1010
# May be removed at some point in the future.
11+
#
1112
# User can choose which heap implementation to use (either the implementations
12-
# included with FreeRTOS [1..5] or a custom implementation ) by providing the
13-
# option FREERTOS_HEAP. If the option is not set, the cmake will default to
14-
# using heap_4.c.
13+
# included with FreeRTOS [1..5] or a custom implementation) by providing the
14+
# option FREERTOS_HEAP. When dynamic allocation is used, the user must specify a
15+
# heap implementation. If the option is not set, the cmake will use no heap
16+
# implementation (e.g. when only static allocation is used).
1517

1618
# `freertos_config` target defines the path to FreeRTOSConfig.h and optionally other freertos based config files
1719
if(NOT TARGET freertos_config )
@@ -37,9 +39,6 @@ if(NOT TARGET freertos_config )
3739
endif()
3840
endif()
3941

40-
# Heap number or absolute path to custom heap implementation provided by user
41-
set(FREERTOS_HEAP "4" CACHE STRING "FreeRTOS heap model number. 1 .. 5. Or absolute path to custom heap source file")
42-
4342
# FreeRTOS port option
4443
if(NOT FREERTOS_PORT)
4544
message(WARNING " FREERTOS_PORT is not set. Please specify it from top-level CMake file (example):\n"
@@ -285,11 +284,16 @@ target_sources(freertos_kernel PRIVATE
285284
stream_buffer.c
286285
tasks.c
287286
timers.c
288-
289-
# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
290-
$<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>
291287
)
292288

289+
if (DEFINED FREERTOS_HEAP )
290+
# User specified a heap implementation add heap implementation to freertos_kernel.
291+
target_sources(freertos_kernel PRIVATE
292+
# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
293+
$<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>
294+
)
295+
endif()
296+
293297

294298
target_link_libraries(freertos_kernel
295299
PUBLIC

0 commit comments

Comments
 (0)