Issue
I'm right now working on a Project integrating zephyr within a repository using CMake extensions.
The repository has following dir structure:
href="https://i.stack.imgur.com/cTgE2.png" rel="nofollow noreferrer">enter image description here
Now whenever I want to change the source directory, I have to reset the cmake.sourceDirectory manually by writting to the setting.json file.
I wanted to ask, if someone knows an better approach. I was thinking on setting up a workflow where CMake opens a dialogue for me to choose a source dir whenever I click on build.
Thx all for the help!
I searched for on how to introduce vars to settings.json(there is no way?).
I was thinking on creating a task, but well then I don't know exactly on how to get CMake to reopning the browse windows for the sourceDir.
Solution
CMake Tools supports specifying multiple source directories in the cmake.sourceDirectory
setting. It can take a string (path to single source directory), or an array of strings (array of paths to source directories). Ex. "cmake.sourceDirectory": ["${workspaceFolder}/1", "${workspaceFolder}/2"]
. Then you can switch between source directories by using the CMake: Select Active Folder
command in the command palette.
Note also that CMake Tools supports multi-root workspaces if you want to go that route.
Answered By - starball Answer Checked By - David Marino (WPSolving Volunteer)