Skip to content

Commit ef0104e

Browse files
ActoryOun9wxu
andauthored
Move cmake compile options to the example project (#872)
* Move GCC compile option to GCC folder with toolchain option * Add CI flow to build cmake example * Fix CI * formatting && enable Werror * Add useless variable to test CI * revert useless variable * Add comments as examples. * Remove default compile options. * Formatting * Remove compile option in kernel cmake and put the sample in examples/cmake_example --------- Co-authored-by: Joseph Julicher <[email protected]>
1 parent 1c465a0 commit ef0104e

File tree

3 files changed

+60
-42
lines changed

3 files changed

+60
-42
lines changed

.github/workflows/kernel-demos.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@ jobs:
9090
working-directory: FreeRTOS/Demo/Posix_GCC
9191
run: make -j COVERAGE_TEST=1
9292

93+
CMake-Example:
94+
name: CMake Example with Native GCC
95+
runs-on: ubuntu-latest
96+
steps:
97+
# Checkout user pull request changes
98+
- name: Checkout Repository
99+
uses: actions/checkout@v3
100+
101+
- name: Install GCC
102+
shell: bash
103+
run: |
104+
sudo apt-get -y update
105+
sudo apt-get -y install build-essential
106+
107+
- name: Build CMake Example Demo
108+
shell: bash
109+
working-directory: examples/cmake_example
110+
run: |
111+
cmake -S . -B build
112+
cmake --build build
113+
93114
MSP430-GCC:
94115
name: GNU MSP430 Toolchain
95116
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -230,50 +230,8 @@ elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_
230230
" freertos_kernel_include)")
231231
endif()
232232

233-
234233
add_library(freertos_kernel STATIC)
235234

236-
########################################################################
237-
# Overall Compile Options
238-
# Note the compile option strategy is to error on everything and then
239-
# Per library opt-out of things that are warnings/errors.
240-
# This ensures that no matter what strategy for compilation you take, the
241-
# builds will still occur.
242-
#
243-
# Only tested with GNU and Clang.
244-
# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID
245-
# Naming of compilers translation map:
246-
#
247-
# FreeRTOS | CMake
248-
# -------------------
249-
# CCS | ?TBD?
250-
# GCC | GNU, Clang, *Clang Others?
251-
# IAR | IAR
252-
# Keil | ARMCC
253-
# MSVC | MSVC # Note only for MinGW?
254-
# Renesas | ?TBD?
255-
256-
target_compile_options(freertos_kernel PRIVATE
257-
### Gnu/Clang C Options
258-
$<$<COMPILE_LANG_AND_ID:C,GNU>:-fdiagnostics-color=always>
259-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>
260-
261-
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
262-
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
263-
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
264-
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
265-
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
266-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>
267-
268-
# Suppressions required to build clean with clang.
269-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros>
270-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
271-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
272-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
273-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align>
274-
)
275-
276-
277235
########################################################################
278236
add_subdirectory(include)
279237
add_subdirectory(portable)

examples/cmake_example/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,45 @@ set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE)
2121
# Adding the FreeRTOS-Kernel subdirectory
2222
add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel)
2323

24+
########################################################################
25+
# Overall Compile Options
26+
# Note the compile option strategy is to error on everything and then
27+
# Per library opt-out of things that are warnings/errors.
28+
# This ensures that no matter what strategy for compilation you take, the
29+
# builds will still occur.
30+
#
31+
# Only tested with GNU and Clang.
32+
# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID
33+
# Naming of compilers translation map:
34+
#
35+
# FreeRTOS | CMake
36+
# -------------------
37+
# CCS | ?TBD?
38+
# GCC | GNU, Clang, *Clang Others?
39+
# IAR | IAR
40+
# Keil | ARMCC
41+
# MSVC | MSVC # Note only for MinGW?
42+
# Renesas | ?TBD?
43+
44+
target_compile_options(freertos_kernel PRIVATE
45+
### Gnu/Clang C Options
46+
$<$<COMPILE_LANG_AND_ID:C,GNU>:-fdiagnostics-color=always>
47+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>
48+
49+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
50+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
51+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
52+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
53+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
54+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>
55+
56+
# Suppressions required to build clean with clang.
57+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros>
58+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
59+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
60+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
61+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align> )
62+
2463
add_executable(${PROJECT_NAME}
2564
main.c
2665
)

0 commit comments

Comments
 (0)