Minimalistic CMake script for easy NRF52 projects creation.
Current workflow was inspired by Polidea/cmake-nRF5x.
Tested with nRF5 SDK 15.3.0.
- Nordic Semiconductor nRF5 SDK - headers, drivers, libraries, examples
- GNU Arm Embedded Toolchain - compiler targeting Arm Cortex-M chips
- Segger JLink - interface software for the JLink family of programmers
- Nordic Semiconductor nRF Command Line Tools - nrfjprog used for programming NRF52
Note: last two are optional. OpenOCD can be used as alternative.
-
Clone this repo (or add as submodule) to the root directory of your your project
-
Select an example in
cmake-nrf52/examples
to start with. -
Copy the contents of the example folder to project root.
-
Fix paths in
Global configuration
section of CMakeLists.txt. -
Optionally add additional SDK libraries with CMake macros
nrf52_add_xxx
. -
Adjust the project - change name, add yours defines, sources and includes
Note: you can add CXX
between C ASM
to add C++ support
Typical project tree:
.
├── CMakeLists.txt
├── cmake-nrf52
│ ├── examples
│ ├── gcc_nrf52.cmake
│ ├── nrf52.cmake
│ └── README.md
├── gcc_nrf52.ld
└── src
└── main.c
Run from project root to build release configuration:
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
Note: possible configurations are Debug, Release, RelWithDebInfo and MinSizeRel.
To program your apllication:
cd build-release
cmake --build . --target NRFJPROG_PROGRAM_HEX
To full erase NRF52 flash:
cd build-release
cmake --build . --target NRFJPROG_ERASE_ALL