Skip to content

Commit a3db429

Browse files
committed
Added in documentation on how to consume from a main project. Added default PORT selection for native POSIX and MINGW platforms.
1 parent 855d6d5 commit a3db429

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.15)
22

33
# User is responsible to one mandatory option:
4-
# FREERTOS_PORT
4+
# FREERTOS_PORT, if not specified and native port detected, uses the native compile.
55
#
66
# User is responsible for one library target:
77
# freertos_config ,typcially an INTERFACE library
@@ -49,16 +49,14 @@ endif()
4949
set(FREERTOS_HEAP "4" CACHE STRING "FreeRTOS heap model number. 1 .. 5. Or absolute path to custom heap source file")
5050

5151
# FreeRTOS port option
52-
set(FREERTOS_PORT "" CACHE STRING "FreeRTOS port name")
53-
5452
if(NOT FREERTOS_PORT)
55-
message(FATAL_ERROR " FREERTOS_PORT is not set. Please specify it from top-level CMake file (example):\n"
53+
message(WARNING " FREERTOS_PORT is not set. Please specify it from top-level CMake file (example):\n"
5654
" set(FREERTOS_PORT GCC_ARM_CM4F CACHE STRING \"\")\n"
5755
" or from CMake command line option:\n"
5856
" -DFREERTOS_PORT=GCC_ARM_CM4F\n"
5957
" \n"
6058
" Available port options:\n"
61-
" A_CUSTOM_PORT - Compiler: UserDefined Target: User Defined\n"
59+
" A_CUSTOM_PORT - Compiler: User Defined Target: User Defined\n"
6260
" BCC_16BIT_DOS_FLSH186 - Compiler: BCC Target: 16 bit DOS Flsh186\n"
6361
" BCC_16BIT_DOS_PC - Compiler: BCC Target: 16 bit DOS PC\n"
6462
" CCS_ARM_CM3 - Compiler: CCS Target: ARM Cortex-M3\n"
@@ -203,6 +201,14 @@ if(NOT FREERTOS_PORT)
203201
" CDK_THEAD_CK802 - Compiler: CDK Target: T-head CK802\n"
204202
" XCC_XTENSA - Compiler: XCC Target: Xtensa\n"
205203
" WIZC_PIC18 - Compiler: WizC Target: PIC18")
204+
# Native FREERTOS_PORT for Linux and Windows MINGW builds
205+
if(UNIX)
206+
message(STATUS " Auto-Detected Unix, setting FREERTOS_PORT=GCC_POSIX")
207+
set(FREERTOS_PORT GCC_POSIX CACHE STRING "FreeRTOS port name")
208+
elseif(MINGW)
209+
message(STATUS " Auto-Detected MINGW, setting FREERTOS_PORT=MSVC_MINGW")
210+
set(FREERTOS_PORT MSVC_MINGW CACHE STRING "FreeRTOS port name")
211+
endif()
206212
elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) )
207213
message(FATAL_ERROR " FREERTOS_PORT is set to A_CUSTOM_PORT. Please specify the custom port target with all necessary files. For example:\n"
208214
" Assuming a directory of:\n"

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,53 @@ Additionally, for FreeRTOS kernel feature information refer to the [Developer Do
88
### Getting help
99
If you have any questions or need assistance troubleshooting your FreeRTOS project, we have an active community that can help on the [FreeRTOS Community Support Forum](https://forums.freertos.org).
1010

11-
## Cloning this repository
11+
## To consume FreeRTOS-Kernel
12+
13+
### Consume with CMake
14+
If using CMake, it is recommended to use this repository using FetchContent.
15+
Add the following into your project's main or a subdirectory's `CMakeLists.txt`:
16+
17+
- Define the source and version/tag you want to use:
18+
19+
```cmake
20+
FetchContent_Declare( freertos_kernel
21+
GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
22+
GIT_TAG master #Note: Best practice to use specific git-hash or tagged version
23+
)
24+
```
25+
26+
- Add a freertos_config library (typically an INTERFACE library) The following assumes the directory structure:
27+
- `include/FreeRTOSConfig.h`
28+
```cmake
29+
add_library(freertos_config INTERFACE)
30+
31+
target_include_directories(freertos_config SYSTEM
32+
INTERFACE
33+
include
34+
)
35+
36+
target_compile_definitions(freertos_config
37+
INTERFACE
38+
projCOVERAGE_TEST=0
39+
)
40+
```
41+
42+
- Configure the FreeRTOS-Kernel and make it available
43+
- this particular example supports a native and cross-compiled build option.
44+
45+
```cmake
46+
set( FREERTOS_HEAP "4" CACHE STRING "" FORCE)
47+
# Select the native compile PORT
48+
set( FREERTOS_PORT "GCC_POSIX" CACHE STRING "" FORCE)
49+
# Select the cross-compile PORT
50+
if (CMAKE_CROSSCOMPILING)
51+
set(FREERTOS_PORT "GCC_ARM_CA9" CACHE STRING "" FORCE)
52+
endif()
53+
54+
FetchContent_MakeAvailable(freertos_kernel)
55+
```
56+
57+
### Consuming stand-alone - Cloning this repository
1258

1359
To clone using HTTPS:
1460
```
@@ -36,4 +82,3 @@ FreeRTOS files are formatted using the "uncrustify" tool. The configuration file
3682
### Spelling
3783
*lexicon.txt* contains words that are not traditionally found in an English dictionary. It is used by the spellchecker to verify the various jargon, variable names, and other odd words used in the FreeRTOS code base. If your pull request fails to pass the spelling and you believe this is a mistake, then add the word to *lexicon.txt*.
3884
Note that only the FreeRTOS Kernel source files are checked for proper spelling, the portable section is ignored.
39-

0 commit comments

Comments
 (0)