{"id":13797874,"url":"https://github.com/Polidea/cmake-nRF5x","last_synced_at":"2025-05-13T04:32:38.846Z","repository":{"id":47636049,"uuid":"90249334","full_name":"Polidea/cmake-nRF5x","owner":"Polidea","description":"cmake script for nRF5 series SoC","archived":false,"fork":false,"pushed_at":"2021-08-20T10:40:04.000Z","size":1196,"stargazers_count":126,"open_issues_count":23,"forks_count":40,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-12T13:13:09.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Polidea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-04T10:09:06.000Z","updated_at":"2024-10-25T08:27:31.000Z","dependencies_parsed_at":"2022-09-02T12:44:05.901Z","dependency_job_id":null,"html_url":"https://github.com/Polidea/cmake-nRF5x","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2Fcmake-nRF5x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2Fcmake-nRF5x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2Fcmake-nRF5x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2Fcmake-nRF5x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Polidea","download_url":"https://codeload.github.com/Polidea/cmake-nRF5x/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225176635,"owners_count":17433022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:00:35.507Z","updated_at":"2024-11-18T12:31:49.079Z","avatar_url":"https://github.com/Polidea.png","language":"C","funding_links":[],"categories":["Build systems"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg\n    alt=\"nRF5 CMake\"\n    src=\"ci/logo.png\"\n    height=\"250\"\n    style=\"margin-top: 20px; margin-bottom: 20px;\"\n  /\u003e\n\u003c/p\u003e\n\n# nRF5 CMake\n\nThis repository provides platform-agnostic CMake files that can be used to build\ncustom nRF5 projects. Our goal is to cover the most used libraries and examples\nstarting from nRF5 SDK version 15.3.0.\n\n## How to use\n\nCopy all CMake files from the `./cmake` folder located in this repository to\nyour project location and create a basic `CMakeLists.txt` file:\n\n```cmake\ncmake_minimum_required(VERSION 3.14)\nproject(blinky LANGUAGES C ASM)\n\ninclude(\"nrf5\")\nadd_executable(${CMAKE_PROJECT_NAME}\n  \"${NRF5_SDK_PATH}/examples/peripheral/blinky/main.c\"\n)\n\nnrf5_target(${CMAKE_PROJECT_NAME})\ntarget_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE\n  nrf5_nrfx_common\n  nrf5_delay\n  nrf5_boards\n)\n```\n\nThe above example compiles source from the SDK but the user is expected to copy\n`main.c` and modify it instead. Below you can look at a very basic bash script,\nwhich builds and flashes blinky example.\n\n```bash\n#!/bin/bash\n\n# Generate project inside ./build folder.\ncmake \\\n    -S . \\\n    -B build \\\n    -DCMAKE_TOOLCHAIN_FILE=\"./cmake/arm-none-eabi.cmake\" \\\n    -DTOOLCHAIN_PREFIX=\"/Users/przemyslawlenart/git/nrf5-cmake/ci/toolchains/gcc\" \\\n    -DNRF5_SDK_PATH=\"/Users/przemyslawlenart/git/nrf5-cmake/ci/sdks/16.0.0\" \\\n    -DNRF5_BOARD=\"pca10056\" \\\n    -DNRF5_SOFTDEVICE_VARIANT=\"s140\"\n\n# Build project\ncmake --build build\n\n# Erase all\ncmake --build build --target erase_all\n\n# Flash SoftDevice (if used)\ncmake --build build --target flash_softdevice\n\n# Flash progarm\ncmake --build build --target flash\n```\n\nYou can find more examples in the repo's [`./ci/examples/`](./ci/examples) folder.\nMake sure to check all available cached variables, which are documented below\nand read [Contributing readme](./ci/README.md) file if you plan to automate SDK\nand tool downloads.\n\n## Configuration\n\nCMake files are configured with cached variables. A lot of them are optional and\ncan be deduced from other ones or SDK itself. Specify `-DNAME=VALUE` during\nproject generation to pass them.\n\n### `CMAKE_TOOLCHAIN_FILE` (file path, requred)\n\nSpecifies a file path to the toolchain file which points to the ARM compiler\nutilities. Currently, only GCC toolchain is supported and `arm-none-eabi.cmake`\nfile is included in `./cmake` folder, which you should copy to your project.\n\n### `TOOLCHAIN_PREFIX` (directory path, optional)\n\nPath to the directory containing GCC toolchain. If not specified, version\ninstalled globally is used.\n\n### `NRF5_SDK_PATH` (directory path, required)\n\nSpecifies a path to the nRF5 SDK, which should be used during compilation. Root\ndirectory should include folders like `examples`, `components` etc.\n\n### `NRF5_SDK_VERSION` (version string, optional)\n\nYou can explicily specify SDK version (e.g. `\"16.0.0\"`). When this cached\nvariable is not provided, version is deduced from the SDK file contents.\n\n### `NRF5_BOARD` (board name, optional)\n\nIf you are using the nRF board you can specify it (e.g. `\"pca10056\"`) and the\nvalue of `NRF5_TARGET` will be deduced accordingly. If defined, all\nboard-specific defines (like `-DBOARD_PCA10056`) are included for all source\nfiles during compilation.\n\n### `NRF5_TARGET` (target name, optional)\n\nIf `NRF5_BOARD` is not specified, this variable is required. You can use alias\nvalue like `nrf52840`, but full target name is recommended: `nrf52840_xxaa`.\nCMake file will deduce all chip specific flags during compilation for all\nproject sources (e.g. `\"-mcpu=cortex-m4\"`).\n\n### `NRF5_SOFTDEVICE_VARIANT` (soft device name, required)\n\nThis variable specifies the SoftDevice binary. If the project doesn't require\nSoftDevice you can pass `\"blank\"` value, otherwise set SoftDevice name\n(e.g. `\"s140\"`). Following triple: (`NRF5_SDK_VERSION`, `NRF5_TARGET`,\n`NRF5_SOFTDEVICE_VARIANT`) is then verified to check if the combination is well\nsupported. All SoftDevice related defines are included for all source files\n(e.g. `\"-DNRF_SD_BLE_API_VERSION=7\"`). The `flash_softdevice` target should be\npointing to the correct SoftDevice file.\n\n### `NRF5_SDKCONFIG_PATH` (directory path, optional)\n\nIt is highly recommended to specify a path to custom `\"sdk_config.h\"` file.\nOtherwise, based on the above variables' values, the CMake file tries to find\nthe best matching file from the SDK. If you want to create a custom target which\ndepends on the config file, link `nrf5_config` dependency. All builtin libraries\nare doing it by default.\n\n### `NRF5_APPCONFIG_PATH` (directory path, optional)\n\nIf your project is using `app_config.h` you can provide include directory\npointing to this file.\n\n### `NRF5_LINKER_SCRIPT` (file path, optional)\n\nIt is highly recommended to specify a path to custom linker file. Otherwise,\nbased on the above variables' values, the CMake file tries to find the best\nmatching file from the SDK.\n\n### `NRF5_NRFJPROG` (executable file, optional)\n\nPath to the `nrfjprog` executable used by targets flashing programs. If not\nspecified, globally installed binary is used.\n\n### `NRF5_STACK_SIZE` (size in bytes, optional)\n\nDefines `__STACK_SIZE` compile definition accordingly. If not passed, the\nstartup file (.S) will take care of setting up default stack boundaries for\nthe specified target.\n\n### `NRF5_HEAP_SIZE` (size in bytes, optional)\n\nDefines `__HEAP_SIZE` compile definition accordingly. If not passed, the\nstartup file (.S) will take care of setting up default heap boundaries for\nthe specified target.\n\n### `NRF_JLINK_SN` (SEGGER J-Link serial number, optional)\n\nTells `nrfjprog` utility which SEGGER J-Link debugger to use based on its serial\nnumber. Particularily useful when working with multiple J-Links connected to the\nPC at the same time. If not specified, user may be prompted which J-Link to use\nwhen running commands like flashing and erasing.\n\n**Important:** You must clear CMake cache and re-run CMake in order to change it.\n\n## Contributing\n\nThe project is developed in a semi-automated way and thoroughly tested with CI\nby compiling both SDK provided examples and libraries. You can find more\ninformation about the project's setup, structure, scripts, etc. in\n[`./ci/README.md`](./ci/README.md) file.\n\n[Thank you!](https://github.com/Polidea/cmake-nRF5x/graphs/contributors)\n\n## License\n\n    MIT License\n\n    Copyright (c) 2020 Polidea\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n\n## Maintained by [Polidea](https://www.polidea.com/services/iot/)\n\n[![Polidea](https://raw.githubusercontent.com/Polidea/RxAndroidBle/master/site/polidea_logo.png \"Tailored software services including concept, design, development and testing\")](http://www.polidea.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolidea%2Fcmake-nRF5x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPolidea%2Fcmake-nRF5x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolidea%2Fcmake-nRF5x/lists"}