Skip to content

Commit 2aff1a1

Browse files
committed
Work on making it so this cmake file can be included from anywhere, not just if it's used from this directoy
1 parent 8c9b032 commit 2aff1a1

File tree

3 files changed

+49
-47
lines changed

3 files changed

+49
-47
lines changed

CMakeLists.txt

+16-15
Original file line numberDiff line numberDiff line change
@@ -273,25 +273,26 @@ target_compile_options(freertos_kernel PRIVATE
273273

274274

275275
########################################################################
276-
add_subdirectory(include)
277-
add_subdirectory(portable)
276+
include(${CMAKE_CURRENT_LIST_DIR}/include/CMakeLists.txt)
277+
include(${CMAKE_CURRENT_LIST_DIR}/portable/CMakeLists.txt)
278278

279279
target_sources(freertos_kernel PRIVATE
280-
croutine.c
281-
event_groups.c
282-
list.c
283-
queue.c
284-
stream_buffer.c
285-
tasks.c
286-
timers.c
287-
288-
# Check if user requested to not include a heap implementation
289-
if(NOT DEFINED FREERTOS_DO_NOT_INCLUDE_HEAP)
290-
# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
291-
$<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>
292-
endif()
280+
${CMAKE_CURRENT_LIST_DIR}/croutine.c
281+
${CMAKE_CURRENT_LIST_DIR}/event_groups.c
282+
${CMAKE_CURRENT_LIST_DIR}/list.c
283+
${CMAKE_CURRENT_LIST_DIR}/queue.c
284+
${CMAKE_CURRENT_LIST_DIR}/stream_buffer.c
285+
${CMAKE_CURRENT_LIST_DIR}/tasks.c
286+
${CMAKE_CURRENT_LIST_DIR}/timers.c
293287
)
294288

289+
# Check if user requested to not include a heap implementation
290+
if(NOT DEFINED FREERTOS_DO_NOT_INCLUDE_HEAP)
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()
295296

296297
target_link_libraries(freertos_kernel
297298
PUBLIC

include/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ add_library(freertos_kernel_include INTERFACE)
44

55
target_include_directories(freertos_kernel_include
66
INTERFACE
7-
.
7+
${CMAKE_CURRENT_LIST_DIR}/.
88
# Note: DEPRECATED but still supported, may be removed in a future release.
99
$<$<NOT:$<TARGET_EXISTS:freertos_config>>:${FREERTOS_CONFIG_FILE_DIRECTORY}>
1010
)

include/portable.h

+32-31
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@
135135
/* Only include heap related functions and structs if using dynamic allocation */
136136
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
137137

138-
/* Used by heap_5.c to define the start address and size of each memory region
139-
* that together comprise the total FreeRTOS heap space. */
138+
/* Used by heap_5.c to define the start address and size of each memory region
139+
* that together comprise the total FreeRTOS heap space. */
140140
typedef struct HeapRegion
141141
{
142142
uint8_t * pucStartAddress;
143143
size_t xSizeInBytes;
144144
} HeapRegion_t;
145145

146-
/* Used to pass information about the heap out of vPortGetHeapStats(). */
146+
/* Used to pass information about the heap out of vPortGetHeapStats(). */
147147
typedef struct xHeapStats
148148
{
149149
size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */
@@ -155,31 +155,31 @@
155155
size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
156156
} HeapStats_t;
157157

158-
/*
159-
* Used to define multiple heap regions for use by heap_5.c. This function
160-
* must be called before any calls to pvPortMalloc() - not creating a task,
161-
* queue, semaphore, mutex, software timer, event group, etc. will result in
162-
* pvPortMalloc being called.
163-
*
164-
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
165-
* defines a region of memory that can be used as the heap. The array is
166-
* terminated by a HeapRegions_t structure that has a size of 0. The region
167-
* with the lowest start address must appear first in the array.
168-
*/
158+
/*
159+
* Used to define multiple heap regions for use by heap_5.c. This function
160+
* must be called before any calls to pvPortMalloc() - not creating a task,
161+
* queue, semaphore, mutex, software timer, event group, etc. will result in
162+
* pvPortMalloc being called.
163+
*
164+
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
165+
* defines a region of memory that can be used as the heap. The array is
166+
* terminated by a HeapRegions_t structure that has a size of 0. The region
167+
* with the lowest start address must appear first in the array.
168+
*/
169169
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
170170

171-
/*
172-
* Returns a HeapStats_t structure filled with information about the current
173-
* heap state.
174-
*/
171+
/*
172+
* Returns a HeapStats_t structure filled with information about the current
173+
* heap state.
174+
*/
175175
void vPortGetHeapStats( HeapStats_t * pxHeapStats );
176176

177-
/*
178-
* Map to the memory management routines required for the port.
179-
*/
177+
/*
178+
* Map to the memory management routines required for the port.
179+
*/
180180
void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
181181
void * pvPortCalloc( size_t xNum,
182-
size_t xSize ) PRIVILEGED_FUNCTION;
182+
size_t xSize ) PRIVILEGED_FUNCTION;
183183
void vPortFree( void * pv ) PRIVILEGED_FUNCTION;
184184
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
185185
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
@@ -194,15 +194,16 @@
194194
#endif
195195

196196
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
197-
/**
198-
* task.h
199-
* @code{c}
200-
* void vApplicationMallocFailedHook( void )
201-
* @endcode
202-
*
203-
* This hook function is called when allocation failed.
204-
*/
205-
void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
197+
198+
/**
199+
* task.h
200+
* @code{c}
201+
* void vApplicationMallocFailedHook( void )
202+
* @endcode
203+
*
204+
* This hook function is called when allocation failed.
205+
*/
206+
void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
206207
#endif /* ( configUSE_MALLOC_FAILED_HOOK == 1 ) */
207208

208209
#endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */

0 commit comments

Comments
 (0)