<?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>Use CMakeLists file to check the nRF Connect SDK version</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111248/use-cmakelists-file-to-check-the-nrf-connect-sdk-version</link><description>Hello, 
 With the CMakeLists file, is it possible to make an error during compilation if the SDK version is not the correct one? 
 Example: I am developing an application which is based on the nRF Connect SDK V2.5.0 and I am pushing my project on Github</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 May 2024 13:43:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111248/use-cmakelists-file-to-check-the-nrf-connect-sdk-version" /><item><title>RE: Use CMakeLists file to check the nRF Connect SDK version</title><link>https://devzone.nordicsemi.com/thread/485155?ContentTypeID=1</link><pubDate>Tue, 21 May 2024 13:43:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40ec5988-c155-4769-b7fc-35e1211eea97</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I recommend creating your application as a workspace application instead of freestanding. With workspace applications, the application has a west manifest file that specifies the nRF Connect SDK version. With this, your colleagues can check which SDK version you are using in the west.yml file, and they can run a west update to get the correct version.&lt;/p&gt;
&lt;p&gt;I recommend looking at the guide for creating a workspace application in &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.1/nrf/create_application.html#creating-an-ncs-application"&gt;Creating an nRF Connect SDK application&lt;/a&gt;. The nRF Connect for VS Code extension sets everything up for you if you follow the steps there.&lt;/p&gt;
&lt;p&gt;But to answer your question, you can set a required nRF Connect SDK version and check the version in the nrf/VERSION file by adding the following to the application&amp;#39;s CMakeLists.txt:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;set(REQUIRED_NRF_VERSION &amp;quot;2.6.1&amp;quot;)

set(NRF_VERSION_FILE &amp;quot;$ENV{ZEPHYR_BASE}/../nrf/VERSION&amp;quot;)
file(STRINGS &amp;quot;${NRF_VERSION_FILE}&amp;quot; NRF_VERSION LIMIT_COUNT 1)

if(NOT NRF_VERSION STREQUAL REQUIRED_NRF_VERSION)
    message(FATAL_ERROR &amp;quot;Incorrect nRF Connect SDK version! Expected version ${REQUIRED_NRF_VERSION}, but found version ${NRF_VERSION}. Stopping the build process.&amp;quot;)
endif()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Simply change REQUIRED_NRF_VERSION to the version you want to use. It will give a CMake error and stop the build if the incorrect version is used:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1716298867765v1.png" alt=" " /&gt;&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>