1# Copyright 2022 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15include($ENV{PW_ROOT}/pw_build/pigweed.cmake) 16 17set(dir_pw_third_party_freertos "" CACHE PATH 18 "Path to the FreeRTOS installation's Source directory. \ 19 If set, pw_third_party.freertos is provided") 20set(pw_third_party_freertos_CONFIG "" CACHE STRING 21 "The CMake target which provides the FreeRTOS config header") 22set(pw_third_party_freertos_PORT "" CACHE STRING 23 "The CMake target which provides the port specific includes and sources") 24option(pw_third_party_freertos_DISABLE_TASKS_STATICS 25 "Whether to disable statics inside of tasks.c") 26 27pw_add_library(pw_third_party.freertos.disable_warnings INTERFACE 28 PUBLIC_COMPILE_OPTIONS 29 -Wno-unused-parameter 30 -Wno-cast-qual 31) 32 33# If FreeRTOS is not configured, a script that displays an error message is used 34# instead. If the build rule is used in the build it fails with this error. 35if(NOT dir_pw_third_party_freertos) 36 pw_add_error_target(pw_third_party.freertos 37 MESSAGE 38 "Attempted to build the pw_third_party.freertos without configuring it " 39 "via dir_pw_third_party_freertos. " 40 "See https://pigweed.dev/third_party/freertos." 41 ) 42 return() 43else(dir_pw_third_party_freertos) 44 if(NOT pw_third_party_freertos_PORT) 45 message(FATAL_ERROR "FreeRTOS is being used, but " 46 "pw_third_party_freertos_PORT is not set.") 47 endif() 48 if(NOT pw_third_party_freertos_CONFIG) 49 message(FATAL_ERROR "FreeRTOS is being used, but " 50 "pw_third_party_freertos_CONFIG is not set.") 51 endif() 52 53 pw_add_library(pw_third_party.freertos STATIC 54 HEADERS 55 ${dir_pw_third_party_freertos}/include/FreeRTOS.h 56 ${dir_pw_third_party_freertos}/include/StackMacros.h 57 ${dir_pw_third_party_freertos}/include/croutine.h 58 ${dir_pw_third_party_freertos}/include/deprecated_definitions.h 59 ${dir_pw_third_party_freertos}/include/event_groups.h 60 ${dir_pw_third_party_freertos}/include/list.h 61 ${dir_pw_third_party_freertos}/include/message_buffer.h 62 ${dir_pw_third_party_freertos}/include/mpu_prototypes.h 63 ${dir_pw_third_party_freertos}/include/mpu_wrappers.h 64 ${dir_pw_third_party_freertos}/include/portable.h 65 ${dir_pw_third_party_freertos}/include/projdefs.h 66 ${dir_pw_third_party_freertos}/include/queue.h 67 ${dir_pw_third_party_freertos}/include/semphr.h 68 ${dir_pw_third_party_freertos}/include/stack_macros.h 69 ${dir_pw_third_party_freertos}/include/stream_buffer.h 70 ${dir_pw_third_party_freertos}/include/task.h 71 ${dir_pw_third_party_freertos}/include/timers.h 72 PUBLIC_INCLUDES 73 ${dir_pw_third_party_freertos}/include 74 PUBLIC_DEPS 75 ${pw_third_party_freertos_CONFIG} 76 ${pw_third_party_freertos_PORT} 77 SOURCES 78 ${dir_pw_third_party_freertos}/croutine.c 79 ${dir_pw_third_party_freertos}/event_groups.c 80 ${dir_pw_third_party_freertos}/list.c 81 ${dir_pw_third_party_freertos}/queue.c 82 ${dir_pw_third_party_freertos}/stream_buffer.c 83 ${dir_pw_third_party_freertos}/timers.c 84 PRIVATE_DEPS 85 pw_third_party.freertos.freertos_tasks 86 pw_third_party.freertos.disable_warnings 87 ) 88endif() 89 90if(pw_third_party_freertos_DISABLE_TASKS_STATICS) 91 set(disable_tasks_statics "static=" "PW_THIRD_PARTY_FREERTOS_NO_STATICS=1") 92endif() 93pw_add_library(pw_third_party.freertos.freertos_tasks STATIC 94 SOURCES 95 ${dir_pw_third_party_freertos}/tasks.c 96 PRIVATE_DEPS 97 ${pw_third_party_freertos_CONFIG} 98 ${pw_third_party_freertos_PORT} 99 pw_third_party.freertos.disable_warnings 100 PRIVATE_INCLUDES 101 ${dir_pw_third_party_freertos}/include 102 PRIVATE_DEFINES 103 ${disable_tasks_statics} 104) 105 106# ARM CM7 port of FreeRTOS. 107pw_add_library(pw_third_party.freertos.arm_cm7 STATIC 108 HEADERS 109 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM7/r0p1/portmacro.h 110 PUBLIC_DEPS 111 ${pw_third_party_freertos_CONFIG} 112 PUBLIC_INCLUDES 113 ${dir_pw_third_party_freertos}/include 114 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM7/r0p1 115 SOURCES 116 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM7/r0p1/port.c 117 PRIVATE_DEPS 118 pw_third_party.freertos.disable_warnings 119) 120 121# ARM CM4F port of FreeRTOS. 122pw_add_library(pw_third_party.freertos.arm_cm4f STATIC 123 HEADERS 124 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM4F/portmacro.h 125 PUBLIC_DEPS 126 ${pw_third_party_freertos_CONFIG} 127 PUBLIC_INCLUDES 128 ${dir_pw_third_party_freertos}/include 129 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM4F 130 SOURCES 131 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM4F/port.c 132 PRIVATE_DEPS 133 pw_third_party.freertos.disable_warnings 134) 135 136# ARM CM33F port of FreeRTOS. 137pw_add_library(pw_third_party.freertos.arm_cm33f STATIC 138 HEADERS 139 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM33F/portmacro.h 140 PUBLIC_DEPS 141 ${pw_third_party_freertos_CONFIG} 142 PUBLIC_INCLUDES 143 ${dir_pw_third_party_freertos}/include 144 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM33F 145 SOURCES 146 ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM33F/port.c 147 PRIVATE_DEPS 148 pw_third_party.freertos.disable_warnings 149) 150 151pw_add_library(pw_third_party.freertos.config_assert INTERFACE 152 HEADERS 153 public/pw_third_party/freertos/config_assert.h 154 PUBLIC_INCLUDES 155 public 156 PUBLIC_DEPS 157 pw_assert 158) 159