<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CMakePresets to west build arguments</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113292/cmakepresets-to-west-build-arguments</link><description>Dear Nordic support team, 
 We are using the SDK v2.6.1 to build targets for nRF52840 chips, and are using multiple configurations defined in a CMakePreset.json file. 
 It works well with the nRF Connect extension for VS Code. 
 However for CI / CD needs</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 27 Aug 2024 15:50:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113292/cmakepresets-to-west-build-arguments" /><item><title>RE: CMakePresets to west build arguments</title><link>https://devzone.nordicsemi.com/thread/500046?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 15:50:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b58dd46e-4538-42f9-b13e-34b3e84ac8d4</guid><dc:creator>fr_adv</dc:creator><description>&lt;p&gt;Works like a charm, thank you.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Aur&amp;eacute;lien&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CMakePresets to west build arguments</title><link>https://devzone.nordicsemi.com/thread/499742?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 12:08:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:003bcf49-1350-4402-994d-3ff3d23ce00d</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can add BOARD_ROOT to the CMakeLists.txt or the build command.&lt;/p&gt;
&lt;p&gt;With west build:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;west build -b my_custom_board -- -DBOARD_ROOT=&amp;quot;board_root_path&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In CMakeLists.txt you must make sure to add the BOARD_ROOT before find_package:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;list(APPEND BOARD_ROOT board_root_path)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that the board root is the directory that includes the boards directory. In your example with main_folder/boards/arm/hw01, the board root will be main_folder.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CMakePresets to west build arguments</title><link>https://devzone.nordicsemi.com/thread/499566?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2024 12:41:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e58fc7d0-4330-42e0-a9c0-22d2822d4ec8</guid><dc:creator>fr_adv</dc:creator><description>&lt;p&gt;Thank you for the reply,&amp;nbsp;it seems very promising, but I need some additional help for this issue&lt;/p&gt;
&lt;p&gt;My arborescency looks like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;main_folder
    |_ project_1
        |_ CMakeLists.txt
        |_ CMakePresets.json
        |_ source files
    |_ project_2
        |_ CMakeLists.txt
        |_ CMakePresets.json
        |_ source files
    |_ boards / arm
        |_ hw01
            |_ board.cmake 
            |_ hw01_defconfig
            |_ hw01-pinctrl.dtsi
            |_ Kconfig.board
            |_ [...]
        |_ hw02
        |_ hw03

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the VSCode config, the boards we defines can be found in the different projects thanks to the following parameter:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    &amp;quot;nrf-connect.boardRoots&amp;quot;: [
        &amp;quot;${workspaceFolder}/boards&amp;quot;,
        &amp;quot;${workspaceFolder}/project_1/boards&amp;quot;,
        &amp;quot;${workspaceFolder}/project_2/boards&amp;quot;,
    ],&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But when I go to main_project/project_1 and I enter the west command it cannot fine the defined boards :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CMake Error at /home/aurelien/ncs/v2.6.1/zephyr/cmake/modules/boards.cmake:167 (message):
  Invalid BOARD; see above.
Call Stack (most recent call first):
  /home/aurelien/ncs/v2.6.1/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  /home/aurelien/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/aurelien/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:18 (find_package)

-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /snap/bin/cmake -DWEST_PYTHON=/home/aurelien/ncs/toolchains/2be090971e/usr/local/bin/python3.9 -B/home/aurelien/main_project/project_1/build_hw03 -GNinja --preset build_hw03 -S/home/aurelien/main_project/project_1&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;How can I add the path to the boards directory in the shell environment so west is able to find it ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that the &amp;quot;board&amp;quot; is set in the CMakePresets, for instance :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="json"&gt;{
            &amp;quot;name&amp;quot;: &amp;quot;build_hw02&amp;quot;,
            &amp;quot;displayName&amp;quot;: &amp;quot;Build for hw02&amp;quot;,
            &amp;quot;generator&amp;quot;: &amp;quot;Ninja&amp;quot;,
            &amp;quot;binaryDir&amp;quot;: &amp;quot;${sourceDir}/build_hw02&amp;quot;,
            &amp;quot;cacheVariables&amp;quot;: {
                &amp;quot;NCS_TOOLCHAIN_VERSION&amp;quot;: &amp;quot;NONE&amp;quot;,
                &amp;quot;BOARD&amp;quot;: &amp;quot;hw02&amp;quot;,
                &amp;quot;CONF_FILE&amp;quot;: &amp;quot;${sourceDir}/prj.conf&amp;quot;,
                &amp;quot;_CMAKE_PRESET_NAME&amp;quot;: &amp;quot;${presetName}&amp;quot;
            }
        },&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Many thanks for your precious support.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Aur&amp;eacute;lien&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CMakePresets to west build arguments</title><link>https://devzone.nordicsemi.com/thread/495048?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2024 14:02:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3346e4e4-8ebd-46fc-a88f-cf7c30bba833</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Aurélien,&lt;/p&gt;
&lt;p&gt;You can build using a preset by adding the --preset flag to the build command:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;west build -d ${targetDir} -- --preset ${presetName}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For example, if you have a build directory called build_dir and the following preset with the name my_preset:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;{
    &amp;quot;version&amp;quot;: 2,
    &amp;quot;cmakeMinimumRequired&amp;quot;: {
        &amp;quot;major&amp;quot;: 3,
        &amp;quot;minor&amp;quot;: 20
    },
    &amp;quot;configurePresets&amp;quot;: [
        {
            &amp;quot;name&amp;quot;: &amp;quot;my_preset&amp;quot;,
            &amp;quot;displayName&amp;quot;: &amp;quot;Build for nRF7002 DK nRF5340 application MCU&amp;quot;,
            &amp;quot;generator&amp;quot;: &amp;quot;Ninja&amp;quot;,
            &amp;quot;binaryDir&amp;quot;: &amp;quot;${sourceDir}/build_dir&amp;quot;,
            &amp;quot;cacheVariables&amp;quot;: {
                &amp;quot;NCS_TOOLCHAIN_VERSION&amp;quot;: &amp;quot;NONE&amp;quot;,
                &amp;quot;BOARD&amp;quot;: &amp;quot;nrf7002dk_nrf5340_cpuapp&amp;quot;,
                &amp;quot;CACHED_CONF_FILE&amp;quot;: &amp;quot;${sourceDir}/prj.conf&amp;quot;
            }
        }
    ]
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then you can use the following command to build on command line using the preset:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;west build -d build_dir -- --preset my_preset&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Make sure that the build directory in the preset (binaryDir) matches the build directory provided in the west build command.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>