adding a file to an ESP-IDF project under VScode?
adding a file to an ESP-IDF project under VScode?
How do I add a source file to an existing project under Vscode/ESP-IDF?
-
- Posts: 1701
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: adding a file to an ESP-IDF project under VScode?
Build System:
Add all source files (.c,.cpp) to the list of SRCS in idf_component_register(...) in the (main) component's CMakeLists.txt file.
Add all source files (.c,.cpp) to the list of SRCS in idf_component_register(...) in the (main) component's CMakeLists.txt file.
Re: adding a file to an ESP-IDF project under VScode?
It depends upon how your current `CMakeLists.txt` specifies the files.
For example, if it globs them like this:
Then you just need to add the file to the `main` folder and you're good to go. Otherwise, if they source files are explicitly listed, or specified in some other way that would not capture your new file, you need to update the `idf_component_register` argument to capture it.
For example, if it globs them like this:
Code: Select all
file(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/main/*.*)
idf_component_register(SRCS ${app_sources})
Re: adding a file to an ESP-IDF project under VScode?
Actually, when I'm using command line tools, I wouldn't mind editing some CMakeLists.txt, but since I'm working under a GUI based tool (VSCode), I was more thinking of using a menu function "Add File to project" like one is doing in Visual Studio or other GUI based IDEs.MicroController wrote: ↑Mon Apr 08, 2024 2:50 pmBuild System:
Add all source files (.c,.cpp) to the list of SRCS in idf_component_register(...) in the (main) component's CMakeLists.txt file.
Putting everything in main/... is ok so far.
Re: adding a file to an ESP-IDF project under VScode?
it is a little tricky, isn't it?
There is a add component command that uses IDF's repository to get components, IDF native and 3rd party(if listed). If the Library you need is listed, thats probably the simplest/safest. You can use github to get a library too(see project manifest). You can read the details of component manager https://docs.espressif.com/projects/esp ... nager.html:
Once added, those libraries will show up in a folder called "managed_components". As implied, those are managed internally. a full clean & build delete those download fresh copies. If you try to modify those,at all, it will warn you.
opt 2: limited, but easy.
1. in your project folder, make the folder "components".
2. dump the folder containing your library(and its own cmake), in components
3. #inlcude "myLibrary."
ps "components" is a magic name, dont change it.
What everyone else was suggesting ought to work too, sounds like you wanted something simpler.
There is a add component command that uses IDF's repository to get components, IDF native and 3rd party(if listed). If the Library you need is listed, thats probably the simplest/safest. You can use github to get a library too(see project manifest). You can read the details of component manager https://docs.espressif.com/projects/esp ... nager.html:
Once added, those libraries will show up in a folder called "managed_components". As implied, those are managed internally. a full clean & build delete those download fresh copies. If you try to modify those,at all, it will warn you.
opt 2: limited, but easy.
1. in your project folder, make the folder "components".
2. dump the folder containing your library(and its own cmake), in components
3. #inlcude "myLibrary."
ps "components" is a magic name, dont change it.
What everyone else was suggesting ought to work too, sounds like you wanted something simpler.
Who is online
Users browsing this forum: Bing [Bot] and 86 guests