]> begriffs open source - freertos/blob - CMakeLists.txt
Fix cmake example errors (#1037)
[freertos] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.15)
2
3 # User is responsible to one mandatory option:
4 #   FREERTOS_PORT, if not specified and native port detected, uses the native compile.
5 #
6 # User is responsible for one library target:
7 #   freertos_config ,typically an INTERFACE library
8 #
9 # DEPRECATED: FREERTOS_CONFIG_FILE_DIRECTORY - but still supported if no freertos_config defined for now.
10 #             May be removed at some point in the future.
11 #
12 # User can choose which heap implementation to use (either the implementations
13 # included with FreeRTOS [1..5] or a custom implementation) by providing the
14 # option FREERTOS_HEAP. When dynamic allocation is used, the user must specify a
15 # heap implementation. If the option is not set, the cmake will use no heap
16 # implementation (e.g. when only static allocation is used).
17
18 # `freertos_config` target defines the path to FreeRTOSConfig.h and optionally other freertos based config files
19 if(NOT TARGET freertos_config )
20     if (NOT DEFINED FREERTOS_CONFIG_FILE_DIRECTORY )
21
22         message(FATAL_ERROR " freertos_config target not specified.  Please specify a cmake target that defines the include directory for FreeRTOSConfig.h:\n"
23             "  add_library(freertos_config INTERFACE)\n"
24             "  target_include_directories(freertos_config SYSTEM\n"
25             "    INTERFACE\n"
26             "      include) # The config file directory\n"
27             "  target_compile_definitions(freertos_config\n"
28             "    PUBLIC\n"
29             "    projCOVERAGE_TEST=0)\n")
30     else()
31         message(WARNING " Using deprecated 'FREERTOS_CONFIG_FILE_DIRECTORY' - please update your project CMakeLists.txt file:\n"
32             "  add_library(freertos_config INTERFACE)\n"
33             "  target_include_directories(freertos_config SYSTEM\n"
34             "    INTERFACE\n"
35             "      include) # The config file directory\n"
36             "  target_compile_definitions(freertos_config\n"
37             "    PUBLIC\n"
38             "    projCOVERAGE_TEST=0)\n")
39     endif()
40 endif()
41
42 # FreeRTOS port option
43 if(NOT FREERTOS_PORT)
44     message(WARNING " FREERTOS_PORT is not set. Please specify it from top-level CMake file (example):\n"
45         "  set(FREERTOS_PORT GCC_ARM_CM4F CACHE STRING \"\")\n"
46         " or from CMake command line option:\n"
47         "  -DFREERTOS_PORT=GCC_ARM_CM4F\n"
48         " \n"
49         " Available port options:\n"
50         " A_CUSTOM_PORT                    - Compiler: User Defined  Target: User Defined\n"
51         " BCC_16BIT_DOS_FLSH186            - Compiler: BCC           Target: 16 bit DOS Flsh186\n"
52         " BCC_16BIT_DOS_PC                 - Compiler: BCC           Target: 16 bit DOS PC\n"
53         " CCS_ARM_CM3                      - Compiler: CCS           Target: ARM Cortex-M3\n"
54         " CCS_ARM_CM4F                     - Compiler: CCS           Target: ARM Cortex-M4 with FPU\n"
55         " CCS_ARM_CR4                      - Compiler: CCS           Target: ARM Cortex-R4\n"
56         " CCS_MSP430X                      - Compiler: CCS           Target: MSP430X\n"
57         " CODEWARRIOR_COLDFIRE_V1          - Compiler: CoreWarrior   Target: ColdFire V1\n"
58         " CODEWARRIOR_COLDFIRE_V2          - Compiler: CoreWarrior   Target: ColdFire V2\n"
59         " CODEWARRIOR_HCS12                - Compiler: CoreWarrior   Target: HCS12\n"
60         " GCC_ARM_CA9                      - Compiler: GCC           Target: ARM Cortex-A9\n"
61         " GCC_ARM_AARCH64                  - Compiler: GCC           Target: ARM v8-A\n"
62         " GCC_ARM_AARCH64_SRE              - Compiler: GCC           Target: ARM v8-A SRE\n"
63         " GCC_ARM_CM0                      - Compiler: GCC           Target: ARM Cortex-M0\n"
64         " GCC_ARM_CM3                      - Compiler: GCC           Target: ARM Cortex-M3\n"
65         " GCC_ARM_CM3_MPU                  - Compiler: GCC           Target: ARM Cortex-M3 with MPU\n"
66         " GCC_ARM_CM4_MPU                  - Compiler: GCC           Target: ARM Cortex-M4 with MPU\n"
67         " GCC_ARM_CM4F                     - Compiler: GCC           Target: ARM Cortex-M4 with FPU\n"
68         " GCC_ARM_CM7                      - Compiler: GCC           Target: ARM Cortex-M7\n"
69         " GCC_ARM_CM23_NONSECURE           - Compiler: GCC           Target: ARM Cortex-M23 non-secure\n"
70         " GCC_ARM_CM23_SECURE              - Compiler: GCC           Target: ARM Cortex-M23 secure\n"
71         " GCC_ARM_CM23_NTZ_NONSECURE       - Compiler: GCC           Target: ARM Cortex-M23 non-trustzone non-secure\n"
72         " GCC_ARM_CM33_NONSECURE           - Compiler: GCC           Target: ARM Cortex-M33 non-secure\n"
73         " GCC_ARM_CM33_SECURE              - Compiler: GCC           Target: ARM Cortex-M33 secure\n"
74         " GCC_ARM_CM33_NTZ_NONSECURE       - Compiler: GCC           Target: ARM Cortex-M33 non-trustzone non-secure\n"
75         " GCC_ARM_CM33_TFM                 - Compiler: GCC           Target: ARM Cortex-M33 non-secure for TF-M\n"
76         " GCC_ARM_CM35P_NONSECURE          - Compiler: GCC           Target: ARM Cortex-M35P non-secure\n"
77         " GCC_ARM_CM35P_SECURE             - Compiler: GCC           Target: ARM Cortex-M35P secure\n"
78         " GCC_ARM_CM35P_NTZ_NONSECURE      - Compiler: GCC           Target: ARM Cortex-M35P non-trustzone non-secure\n"
79         " GCC_ARM_CM55_NONSECURE           - Compiler: GCC           Target: ARM Cortex-M55 non-secure\n"
80         " GCC_ARM_CM55_SECURE              - Compiler: GCC           Target: ARM Cortex-M55 secure\n"
81         " GCC_ARM_CM55_NTZ_NONSECURE       - Compiler: GCC           Target: ARM Cortex-M55 non-trustzone non-secure\n"
82         " GCC_ARM_CM55_TFM                 - Compiler: GCC           Target: ARM Cortex-M55 non-secure for TF-M\n"
83         " GCC_ARM_CM85_NONSECURE           - Compiler: GCC           Target: ARM Cortex-M85 non-secure\n"
84         " GCC_ARM_CM85_SECURE              - Compiler: GCC           Target: ARM Cortex-M85 secure\n"
85         " GCC_ARM_CM85_NTZ_NONSECURE       - Compiler: GCC           Target: ARM Cortex-M85 non-trustzone non-secure\n"
86         " GCC_ARM_CM85_TFM                 - Compiler: GCC           Target: ARM Cortex-M85 non-secure for TF-M\n"
87         " GCC_ARM_CR5                      - Compiler: GCC           Target: ARM Cortex-R5\n"
88         " GCC_ARM_CRX_MPU                  - Compiler: GCC           Target: ARM Cortex-Rx with MPU\n"
89         " GCC_ARM_CRX_NOGIC                - Compiler: GCC           Target: ARM Cortex-Rx no GIC\n"
90         " GCC_ARM7_AT91FR40008             - Compiler: GCC           Target: ARM7 Atmel AT91R40008\n"
91         " GCC_ARM7_AT91SAM7S               - Compiler: GCC           Target: ARM7 Atmel AT91SAM7S\n"
92         " GCC_ARM7_LPC2000                 - Compiler: GCC           Target: ARM7 LPC2000\n"
93         " GCC_ARM7_LPC23XX                 - Compiler: GCC           Target: ARM7 LPC23xx\n"
94         " GCC_ATMEGA323                    - Compiler: GCC           Target: ATMega323\n"
95         " GCC_AVR32_UC3                    - Compiler: GCC           Target: AVR32 UC3\n"
96         " GCC_COLDFIRE_V2                  - Compiler: GCC           Target: ColdFire V2\n"
97         " GCC_CORTUS_APS3                  - Compiler: GCC           Target: CORTUS APS3\n"
98         " GCC_H8S2329                      - Compiler: GCC           Target: H8S2329\n"
99         " GCC_HCS12                        - Compiler: GCC           Target: HCS12\n"
100         " GCC_IA32_FLAT                    - Compiler: GCC           Target: IA32 flat\n"
101         " GCC_MICROBLAZE                   - Compiler: GCC           Target: MicroBlaze\n"
102         " GCC_MICROBLAZE_V8                - Compiler: GCC           Target: MicroBlaze V8\n"
103         " GCC_MICROBLAZE_V9                - Compiler: GCC           Target: MicroBlaze V9\n"
104         " GCC_MSP430F449                   - Compiler: GCC           Target: MSP430F449\n"
105         " GCC_NIOSII                       - Compiler: GCC           Target: NiosII\n"
106         " GCC_PPC405_XILINX                - Compiler: GCC           Target: Xilinx PPC405\n"
107         " GCC_PPC440_XILINX                - Compiler: GCC           Target: Xilinx PPC440\n"
108         " GCC_RISC_V                       - Compiler: GCC           Target: RISC-V\n"
109         " GCC_RISC_V_PULPINO_VEGA_RV32M1RM - Compiler: GCC           Target: RISC-V Pulpino Vega RV32M1RM\n"
110         " GCC_RISC_V_GENERIC               - Compiler: GCC           Target: RISC-V with FREERTOS_RISCV_EXTENSION\n"
111         " GCC_RL78                         - Compiler: GCC           Target: Renesas RL78\n"
112         " GCC_RX100                        - Compiler: GCC           Target: Renesas RX100\n"
113         " GCC_RX200                        - Compiler: GCC           Target: Renesas RX200\n"
114         " GCC_RX600                        - Compiler: GCC           Target: Renesas RX600\n"
115         " GCC_RX600_V2                     - Compiler: GCC           Target: Renesas RX600 v2\n"
116         " GCC_RX700_V3_DPFPU               - Compiler: GCC           Target: Renesas RX700 v3 with DPFPU\n"
117         " GCC_STR75X                       - Compiler: GCC           Target: STR75x\n"
118         " GCC_TRICORE_1782                 - Compiler: GCC           Target: TriCore 1782\n"
119         " GCC_ARC_EM_HS                    - Compiler: GCC           Target: DesignWare ARC EM HS\n"
120         " GCC_ARC_V1                       - Compiler: GCC           Target: DesignWare ARC v1\n"
121         " GCC_ATMEGA                       - Compiler: GCC           Target: ATmega\n"
122         " GCC_POSIX                        - Compiler: GCC           Target: Posix\n"
123         " GCC_RP2040                       - Compiler: GCC           Target: RP2040 ARM Cortex-M0+\n"
124         " GCC_XTENSA_ESP32                 - Compiler: GCC           Target: Xtensa ESP32\n"
125         " GCC_AVRDX                        - Compiler: GCC           Target: AVRDx\n"
126         " GCC_AVR_MEGA0                    - Compiler: GCC           Target: AVR Mega0\n"
127         " IAR_78K0K                        - Compiler: IAR           Target: Renesas 78K0K\n"
128         " IAR_ARM_CA5_NOGIC                - Compiler: IAR           Target: ARM Cortex-A5 no GIC\n"
129         " IAR_ARM_CA9                      - Compiler: IAR           Target: ARM Cortex-A9\n"
130         " IAR_ARM_CM0                      - Compiler: IAR           Target: ARM Cortex-M0\n"
131         " IAR_ARM_CM3                      - Compiler: IAR           Target: ARM Cortex-M3\n"
132         " IAR_ARM_CM4F                     - Compiler: IAR           Target: ARM Cortex-M4 with FPU\n"
133         " IAR_ARM_CM4F_MPU                 - Compiler: IAR           Target: ARM Cortex-M4 with FPU and MPU\n"
134         " IAR_ARM_CM7                      - Compiler: IAR           Target: ARM Cortex-M7\n"
135         " IAR_ARM_CM23_NONSECURE           - Compiler: IAR           Target: ARM Cortex-M23 non-secure\n"
136         " IAR_ARM_CM23_SECURE              - Compiler: IAR           Target: ARM Cortex-M23 secure\n"
137         " IAR_ARM_CM23_NTZ_NONSECURE       - Compiler: IAR           Target: ARM Cortex-M23 non-trustzone non-secure\n"
138         " IAR_ARM_CM33_NONSECURE           - Compiler: IAR           Target: ARM Cortex-M33 non-secure\n"
139         " IAR_ARM_CM33_SECURE              - Compiler: IAR           Target: ARM Cortex-M33 secure\n"
140         " IAR_ARM_CM33_NTZ_NONSECURE       - Compiler: IAR           Target: ARM Cortex-M33 non-trustzone non-secure\n"
141         " IAR_ARM_CM35P_NONSECURE          - Compiler: IAR           Target: ARM Cortex-M35P non-secure\n"
142         " IAR_ARM_CM35P_SECURE             - Compiler: IAR           Target: ARM Cortex-M35P secure\n"
143         " IAR_ARM_CM35P_NTZ_NONSECURE      - Compiler: IAR           Target: ARM Cortex-M35P non-trustzone non-secure\n"
144         " IAR_ARM_CM55_NONSECURE           - Compiler: IAR           Target: ARM Cortex-M55 non-secure\n"
145         " IAR_ARM_CM55_SECURE              - Compiler: IAR           Target: ARM Cortex-M55 secure\n"
146         " IAR_ARM_CM55_NTZ_NONSECURE       - Compiler: IAR           Target: ARM Cortex-M55 non-trustzone non-secure\n"
147         " IAR_ARM_CM85_NONSECURE           - Compiler: IAR           Target: ARM Cortex-M85 non-secure\n"
148         " IAR_ARM_CM85_SECURE              - Compiler: IAR           Target: ARM Cortex-M85 secure\n"
149         " IAR_ARM_CM85_NTZ_NONSECURE       - Compiler: IAR           Target: ARM Cortex-M85 non-trustzone non-secure\n"
150         " IAR_ARM_CRX_NOGIC                - Compiler: IAR           Target: ARM Cortex-Rx no GIC\n"
151         " IAR_ATMEGA323                    - Compiler: IAR           Target: ATMega323\n"
152         " IAR_ATMEL_SAM7S64                - Compiler: IAR           Target: Atmel SAM7S64\n"
153         " IAR_ATMEL_SAM9XE                 - Compiler: IAR           Target: Atmel SAM9XE\n"
154         " IAR_AVR_AVRDX                    - Compiler: IAR           Target: AVRDx\n"
155         " IAR_AVR_MEGA0                    - Compiler: IAR           Target: AVR Mega0\n"
156         " IAR_AVR32_UC3                    - Compiler: IAR           Target: AVR32 UC3\n"
157         " IAR_LPC2000                      - Compiler: IAR           Target: LPC2000\n"
158         " IAR_MSP430                       - Compiler: IAR           Target: MSP430\n"
159         " IAR_MSP430X                      - Compiler: IAR           Target: MSP430X\n"
160         " IAR_RISC_V                       - Compiler: IAR           Target: RISC-V\n"
161         " IAR_RISC_V_GENERIC               - Compiler: IAR           Target: RISC-V with FREERTOS_RISCV_EXTENSION\n"
162         " IAR_RL78                         - Compiler: IAR           Target: Renesas RL78\n"
163         " IAR_RX100                        - Compiler: IAR           Target: Renesas RX100\n"
164         " IAR_RX600                        - Compiler: IAR           Target: Renesas RX600\n"
165         " IAR_RX700_V3_DPFPU               - Compiler: IAR           Target: Renesas RX700 v3 with DPFPU\n"
166         " IAR_RX_V2                        - Compiler: IAR           Target: Renesas RX v2\n"
167         " IAR_STR71X                       - Compiler: IAR           Target: STR71x\n"
168         " IAR_STR75X                       - Compiler: IAR           Target: STR75x\n"
169         " IAR_STR91X                       - Compiler: IAR           Target: STR91x\n"
170         " IAR_V850ES_FX3                   - Compiler: IAR           Target: Renesas V850ES/Fx3\n"
171         " IAR_V850ES_HX3                   - Compiler: IAR           Target: Renesas V850ES/Hx3\n"
172         " MIKROC_ARM_CM4F                  - Compiler: MikroC        Target: ARM Cortex-M4 with FPU\n"
173         " MPLAB_PIC18F                     - Compiler: MPLAB         Target: PIC18F\n"
174         " MPLAB_PIC24                      - Compiler: MPLAB         Target: PIC24\n"
175         " MPLAB_PIC32MEC14XX               - Compiler: MPLAB         Target: PIC32MEC14xx\n"
176         " MPLAB_PIC32MX                    - Compiler: MPLAB         Target: PIC32MX\n"
177         " MPLAB_PIC32MZ                    - Compiler: MPLAB         Target: PIC32MZ\n"
178         " MSVC_MINGW                       - Compiler: MSVC or MinGW Target: x86\n"
179         " OWATCOM_16BIT_DOS_FLSH186        - Compiler: Open Watcom   Target: 16 bit DOS Flsh186\n"
180         " OWATCOM_16BIT_DOS_PC             - Compiler: Open Watcom   Target: 16 bit DOS PC\n"
181         " PARADIGM_TERN_EE_LARGE           - Compiler: Paradigm      Target: Tern EE large\n"
182         " PARADIGM_TERN_EE_SMALL           - Compiler: Paradigm      Target: Tern EE small\n"
183         " RENESAS_RX100                    - Compiler: Renesas       Target: RX100\n"
184         " RENESAS_RX200                    - Compiler: Renesas       Target: RX200\n"
185         " RENESAS_RX600                    - Compiler: Renesas       Target: RX600\n"
186         " RENESAS_RX600_V2                 - Compiler: Renesas       Target: RX600 v2\n"
187         " RENESAS_RX700_V3_DPFPU           - Compiler: Renesas       Target: RX700 v3 with DPFPU\n"
188         " RENESAS_SH2A_FPU                 - Compiler: Renesas       Target: SH2A with FPU\n"
189         " ROWLEY_MSP430F449                - Compiler: Rowley        Target: MSP430F449\n"
190         " RVDS_ARM_CA9                     - Compiler: RVDS          Target: ARM Cortex-A9\n"
191         " RVDS_ARM_CM0                     - Compiler: RVDS          Target: ARM Cortex-M0\n"
192         " RVDS_ARM_CM3                     - Compiler: RVDS          Target: ARM Cortex-M3\n"
193         " RVDS_ARM_CM4_MPU                 - Compiler: RVDS          Target: ARM Cortex-M4 with MPU\n"
194         " RVDS_ARM_CM4F                    - Compiler: RVDS          Target: ARM Cortex-M4 with FPU\n"
195         " RVDS_ARM_CM7                     - Compiler: RVDS          Target: ARM Cortex-M7\n"
196         " RVDS_ARM7_LPC21XX                - Compiler: RVDS          Target: ARM7 LPC21xx\n"
197         " SDCC_CYGNAL                      - Compiler: SDCC          Target: Cygnal\n"
198         " SOFTUNE_MB91460                  - Compiler: Softune       Target: MB91460\n"
199         " SOFTUNE_MB96340                  - Compiler: Softune       Target: MB96340\n"
200         " TASKING_ARM_CM4F                 - Compiler: Tasking       Target: ARM Cortex-M4 with FPU\n"
201         " TEMPLATE                         - Compiler: HOST          Target: None\n"
202         " CDK_THEAD_CK802                  - Compiler: CDK           Target: T-head CK802\n"
203         " XCC_XTENSA                       - Compiler: XCC           Target: Xtensa\n"
204         " WIZC_PIC18                       - Compiler: WizC          Target: PIC18")
205     # Native FREERTOS_PORT for Linux and Windows MINGW builds
206     if(UNIX)
207         message(STATUS " Auto-Detected Unix, setting FREERTOS_PORT=GCC_POSIX")
208         set(FREERTOS_PORT GCC_POSIX CACHE STRING "FreeRTOS port name")
209     elseif(MINGW)
210         message(STATUS " Auto-Detected MINGW, setting FREERTOS_PORT=MSVC_MINGW")
211         set(FREERTOS_PORT MSVC_MINGW CACHE STRING "FreeRTOS port name")
212     endif()
213 elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) )
214     message(FATAL_ERROR " FREERTOS_PORT is set to A_CUSTOM_PORT. Please specify the custom port target with all necessary files. For example:\n"
215     " Assuming a directory of:\n"
216     "  FreeRTOSCustomPort/\n"
217     "    CMakeLists.txt\n"
218     "    port.c\n"
219     "    portmacro.h\n"
220     " Where FreeRTOSCustomPort/CMakeLists.txt is a modified version of:\n"
221     "   add_library(freertos_kernel_port OBJECT)\n"
222     "   target_sources(freertos_kernel_port\n"
223     "     PRIVATE\n"
224     "       port.c\n"
225     "       portmacro.h)\n"
226     "   add_library(freertos_kernel_port_headers INTERFACE)\n"
227     "     target_include_directories(freertos_kernel_port_headers INTERFACE \n"
228     "      .)\n"
229     "   target_link_libraries(freertos_kernel_port\n"
230     "     PRIVATE\n"
231     "       freertos_kernel_port_headers\n"
232     "       freertos_kernel_include)")
233 endif()
234
235 add_library(freertos_kernel STATIC)
236
237 ########################################################################
238 add_subdirectory(include)
239 add_subdirectory(portable)
240
241 target_sources(freertos_kernel PRIVATE
242     croutine.c
243     event_groups.c
244     list.c
245     queue.c
246     stream_buffer.c
247     tasks.c
248     timers.c
249 )
250
251 if (DEFINED FREERTOS_HEAP )
252     # User specified a heap implementation add heap implementation to freertos_kernel.
253     target_sources(freertos_kernel PRIVATE
254         # If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
255         $<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>
256     )
257 endif()
258
259
260 target_link_libraries(freertos_kernel
261     PUBLIC
262         freertos_kernel_include
263         freertos_kernel_port_headers
264     PRIVATE
265         freertos_kernel_port
266
267 )
268
269 ########################################################################