This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding header and source files to nRF Connect SDK Project

Hello all,

I am working on a custom application that requires gps, https post requests, SPI, and CAN, and I am having trouble adding source and header files to my project. Following the tutorial on the nRF Connect SDK documentation page, I am trying to add a new file to CMakeLists.txt by right clicking on Project 'app/libapp.a' , but sometimes the option to add a new file isn't available. Depending on which project you start with, there is no option to add new files to Cmake, which is strange.

I eventually found an example that allowed me to actually add files to CMake (at_client), but am now getting multiple errors and multiple stages of building. How can I add .h and .c files to CMakeLists.txt?

I have searched through devzone looking at examples but don't see a clear step by step manual for adding .c and .h files to an nRF Connect SDK project. Some examples say to add to the 'src' folder, but nowhere do I see a src folder. On most other IDEs I just create new folders for my header and source files and just add them there, but this doesn't seem to link correctly. Any help would be appreciated, thank you.

-Kyle Garland

Parents
  • Unfortunately, editing CMakeLists.txt and even reloading project after that doesn't work. Your modification of SES generates .emProject file only once, when user executes command "Open nRF Connect SDK project". After that any changes to CMakeLists.txt will not update build.emProject and new files will not be included into build.

    So to add new .c file I have run this command again, select board, select folder in combo box (which seems always points to obscure wrong folder), check "clear build folder" and wait until whole enchilada will be regenerated again. 

    Is it that hard to reinterpret CMake file when it is changed and update Segger project file? That what other IDEs based on CMake do.

    Regards,

    Sergei

  • An easier way to reload the project is to:

    • Save CMakeLists.txt
    • Edit the configuration (Project->Configure nRF Connect SDK Project)
    • Click the Configure button

    After that, my new c file appears in the project list.  A little clumsy, but works.

Reply Children
No Data
Related