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

CMakeLists.txt, Kconfig, proj.conf, sample.yaml

Hi

I'm trying to understand the files outside the main program. The files that are at the samples path. Like "CMakeLists.txt, Kconfig, proj.conf, sample.yaml etc". So from what I know, they are all necessary to the program to be built. But I have some doubts about how they are initialized and in what order. I think it starts when we press at segger "Open nRF Connect SDK Project" and we select the "CMakeLists.txt" file. This file will start the application  and define the dependencies. If I open this file, there's some includes that I'm a little bit confuse about what they do, and there's 

#NORDIC SDK APP START
target_sources(app PRIVATE src/main.c)
# NORDIC SDK APP END 

I was researching and from what I understood the above settings, an existing library target named app is configured to include the source file src/main.c. The PRIVATE keyword indicates that we are modifying the internals of how the library is being built. 

At proj.conf I notice that there are some configs necessaries to the program and related to the #includes or #defines at the main.c.

But I don't understand how it is called and how the other files that I mentioned upper works/are called. Can someone help me please providing more detailed info about all the 4 files?

Thank you in advance.With my best

Parents Reply Children
  • So for what I understood is:

    Every Nordic example comes with mandatory files, are they: "CMakeLists.txt, Kconfig, prj.conf and sample.yaml" and also a file src with main.c and some other headers (if necessary).

    Each one of that mandatory files has one different and specific task.

    When the program is being built, the CMakeLists uses the Kconfig and all *.conf existent to generate the build files witch Ninja uses to build the program. The gcc compiler creates the executables after that.

    It is correct until now??

    The one doubt about that is how the CMakeLists know how to call the Kconfig and *.conf files. How this work. Because I didn't found any path or any include of that files.

    So, another thing:

    ->scr: it has the main and headers;

    -->CMakeLists: includes "($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)" but I don't know what this include do.

    It has also 

    # NORDIC SDK APP START
    target_sources(app PRIVATE src/main.c)
    # NORDIC SDK APP END

    and this one opens the main.c inside src.

    --->Kconfig: will include "$ZEPHYR_BASE/Kconfig.zephyr" but I dont know also what this include includes. The other definitions inside configures the hole application.

    ---->prj.conf: another file of configuration witch has also the definitions about the application. But whats the difference between this file and the Kconfig.

    ----->sample.yaml: I dont know what it does. 

    If you can complete what I'm I missing it would be great.

    Thank you

  • I believe by following the two tutorials I refer to you will get an understanding.

    Kenneth

  • I read the tutorials that you posted and I understood some of the doubts that I had. Some others I didn't.

    Can you at least help me with this two questions:

    Kconfig and prj.conf both are configurations files right?  Whats the main difference between them. Couldn't they be the same file?

    and what *.yaml file is about

    Thank you and sorry again

  • kconfig are working on the build folder, so if you recompile the project, then changes are lost. I recommend to add changes to the prj.conf file if you want to keep them.

    For yaml (yet another markup language) I think you need to refer to the https://docs.zephyrproject.org/latest/guides/dts/index.html 

Related