1cmake_minimum_required(VERSION 3.15)
2
3project(coverity)
4
5set(FREERTOS_KERNEL_PATH "../../")
6FILE(GLOB FREERTOS_KERNEL_SOURCE ${FREERTOS_KERNEL_PATH}*.c)
7
8# Coverity incorrectly infers the type of pdTRUE and pdFALSE as boolean because
9# of their names. This generates multiple false positive warnings about type
10# mismatch. Replace pdTRUE with pdPASS and pdFALSE with pdFAIL to avoid these
11# false positive warnings. This workaround will not be needed after Coverity
12# fixes the issue of incorrectly inferring the type of pdTRUE and pdFALSE as
13# boolean.
14add_custom_target(fix_source ALL
15                  COMMAND sed -i -b -e 's/pdFALSE/pdFAIL/g' -e 's/pdTRUE/pdPASS/g' ${FREERTOS_KERNEL_SOURCE}
16                  DEPENDS ${FREERTOS_KERNEL_SOURCE})
17
18# Add the freertos_config for FreeRTOS-Kernel.
19add_library(freertos_config INTERFACE)
20
21target_include_directories(freertos_config
22                           INTERFACE
23                           ./)
24
25# Select the heap. Values between 1-5 will pick a heap.
26set(FREERTOS_HEAP "3" CACHE STRING "" FORCE)
27
28# Select the FreeRTOS port.
29set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE)
30
31# Add the FreeRTOS-Kernel subdirectory.
32add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel)
33
34add_executable(${PROJECT_NAME}
35               ../cmake_example/main.c)
36
37add_dependencies(${PROJECT_NAME} fix_source)
38
39target_link_libraries(${PROJECT_NAME} freertos_kernel freertos_config)
40