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