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