1cmake_minimum_required(VERSION 3.15)
2project(example)
3
4set(FREERTOS_KERNEL_PATH "../../")
5
6# Add the freertos_config for FreeRTOS-Kernel
7add_library(freertos_config INTERFACE)
8
9target_include_directories(freertos_config
10    INTERFACE
11    "../template_configuration"
12)
13
14if (DEFINED FREERTOS_SMP_EXAMPLE AND FREERTOS_SMP_EXAMPLE STREQUAL "1")
15    message(STATUS "Build FreeRTOS SMP example")
16    # Adding the following configurations to build SMP template port
17    add_compile_options( -DconfigNUMBER_OF_CORES=2 -DconfigUSE_PASSIVE_IDLE_HOOK=0 )
18endif()
19
20# Select the heap port.  values between 1-4 will pick a heap.
21set(FREERTOS_HEAP "4" CACHE STRING "" FORCE)
22
23# Select the native compile PORT
24set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE)
25
26# Adding the FreeRTOS-Kernel subdirectory
27add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel)
28
29########################################################################
30# Overall Compile Options
31# Note the compile option strategy is to error on everything and then
32# Per library opt-out of things that are warnings/errors.
33# This ensures that no matter what strategy for compilation you take, the
34# builds will still occur.
35#
36# Only tested with GNU and Clang.
37# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID
38# Naming of compilers translation map:
39#
40#   FreeRTOS    | CMake
41#   -------------------
42#   CCS         | ?TBD?
43#   GCC         | GNU, Clang, *Clang Others?
44#   IAR         | IAR
45#   Keil        | ARMCC
46#   MSVC        | MSVC # Note only for MinGW?
47#   Renesas     | ?TBD?
48
49target_compile_options(freertos_kernel PRIVATE
50    ### Gnu/Clang C Options
51    $<$<COMPILE_LANG_AND_ID:C,GNU>:-fdiagnostics-color=always>
52    $<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>
53
54    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
55    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
56    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
57    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
58    $<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
59    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>
60
61    # Suppressions required to build clean with clang.
62    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros>
63    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
64    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
65    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
66    $<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align> )
67
68add_executable(${PROJECT_NAME}
69    main.c
70)
71
72target_link_libraries(${PROJECT_NAME} freertos_kernel freertos_config)
73
74set_property(TARGET freertos_kernel PROPERTY C_STANDARD 90)