I would like to configure correctly project's settings.json file to use CMakeLists.txt file of multiple sub-project.
My approach is given below
The structure of the project is as like as follows.
vscode_build_cmake/
`-- task
|-- add
| |-- CMakeLists.txt
| |-- include
| | `-- foo.h
| `-- src
| |-- foo.cpp
| `-- main.cpp
`-- print
|-- CMakeLists.txt
|-- include
| `-- foo.h
`-- src
|-- foo.cpp
`-- main.cpp
Here, add & print are completely isolated sub-project of the main project task. Each sub-project has their own build recipe which is written in their own CMakeLists.txt file. Usual steps to build sub-project is :
cd task/add
mkdir build
cd build
cmake .. && make
Same steps is for task/print.
Right now I would like to perform this build task using VSCode Cmake tool. What I have found that I only need to make a vscode_build_cmake/.vscode/settings.json file where I can point to the directory of CMakeLists.txt file. I am now working with
{
"cmake.configureOnOpen": false,
"cmake.sourceDirectory": "${workspaceFolder}/task/add"
}
I just press ctrl+shift+p and write in the command box run build task and press Enter. That one do the job for me and I can see build, bin, lib directories inside task/add directory.
But the problem, I am facing now is that if I need to build print sub-project I have to manually edit the settings.json file as like as follows
{
"cmake.configureOnOpen": false,
"cmake.sourceDirectory": "${workspaceFolder}/task/print"
}
After that, I have to delete cache and reconfigure and build task which perform now the build task only for print project. This one is very tedious to me.
My desire is to know
- Is there any way to point out the both
CMakeLists.txtfile ofaddandprintincmake.sourceDirectory? Which can tell me which build task I would like to perform? Eg:
{
"cmake.configureOnOpen": false,
"cmake.sourceDirectory": ["${workspaceFolder}/task/add",
"${workspaceFolder}/task/print"]
}
Or ,
- Is there any way to perform build task of both sub-project.(this one is optional. Previous one is important for my case).