esynr3z / cmake-nrf52

CMake scripts for NRF52

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmake-nrf52

Minimalistic CMake script for easy NRF52 projects creation.

Current workflow was inspired by Polidea/cmake-nRF5x.

Tested with nRF5 SDK 15.3.0.

Dependencies

Note: last two are optional. OpenOCD can be used as alternative.

Project

  1. Clone this repo (or add as submodule) to the root directory of your your project

  2. Select an example in cmake-nrf52/examples to start with.

  3. Copy the contents of the example folder to project root.

  4. Fix paths in Global configuration section of CMakeLists.txt.

  5. Optionally add additional SDK libraries with CMake macros nrf52_add_xxx.

  6. 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

Build

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.

Flash

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

About

CMake scripts for NRF52


Languages

Language:CMake 100.0%