https://github.com/github0null/cmake_embedded_project_template
cmake embedded project template
https://github.com/github0null/cmake_embedded_project_template
armcc cmake cortex gcc mcu ninja stm32 vscode
Last synced: 7 months ago
JSON representation
cmake embedded project template
- Host: GitHub
- URL: https://github.com/github0null/cmake_embedded_project_template
- Owner: github0null
- Created: 2022-02-14T07:32:14.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-05T12:56:03.000Z (over 3 years ago)
- Last Synced: 2025-01-25T22:23:02.099Z (9 months ago)
- Topics: armcc, cmake, cortex, gcc, mcu, ninja, stm32, vscode
- Language: C
- Homepage:
- Size: 1.56 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CMake embedded project template
## Requirements
- cmake >= 3.20
- ninja
- toolchain: `arm-none-eabi` or `armcc`> **Recommendation**: Use this template with VsCode and `ms-vscode.cmake-tools` extensions
***
## Build Test Project
- **Build arm-none-eabi gcc test project**
Write `CMakeLists.txt` with following contents:
```cmake
cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)# Set up compiler and mcu arch
set(COMPILER_TYPE "arm-none-eabi") # options: 'armcc' or 'arm-none-eabi'
set(MCU_ARCH_TYPE "cortex_m7") # options: 'cortex_m0', 'cortex_m3' ...
set(MCU_MFPU_TYPE "default") # options: 'sp', 'dp', 'none', 'default'# Include toolchain config
include(${CMAKE_SOURCE_DIR}/cmake/toolchain/${COMPILER_TYPE}/${MCU_ARCH_TYPE}.cmake)# Set up project name
set(PRJ_NAME "cmake_project_demo")# Set up the project
project(${PRJ_NAME}
VERSION "0.1.0"
LANGUAGES C ASM CXX)# Build test project
add_subdirectory(test/gcc_test)
```then, execute the following commands to build project:
```shell
cmake -B ./build -G Ninja
cmake --build ./build --target all -j 14
```- **Build armcc test project**
Write `CMakeLists.txt` with following contents (**Please set `TOOLCHAIN_DIR` for armcc before build**):
```cmake
cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)# Set up compiler and mcu arch
set(COMPILER_TYPE "armcc") # options: 'armcc' or 'arm-none-eabi'
set(MCU_ARCH_TYPE "cortex_m3") # options: 'cortex_m0', 'cortex_m3' ...
set(MCU_MFPU_TYPE "default") # options: 'sp', 'dp', 'none', 'default'
set(TOOLCHAIN_DIR "D:/Keil/ARM/ARMCC/bin") # toolchain root folder for armcc
# other armcc options
#option(USE_MICRO_LIB "Enable MicroLib" ON)# Include toolchain config
include(${CMAKE_SOURCE_DIR}/cmake/toolchain/${COMPILER_TYPE}/${MCU_ARCH_TYPE}.cmake)# Set up project name
set(PRJ_NAME "cmake_project_demo")# Set up the project
project(${PRJ_NAME}
VERSION "0.1.0"
LANGUAGES C ASM CXX)# Build test project
add_subdirectory(test/armcc_test)
```then, execute the following commands to build project:
```shell
cmake -B ./build -G Ninja
cmake --build ./build --target all -j 14
```