I am trying to build a large C++ framework in VS Code using CMake Tools and C/C++ Extensions in Visual Studio Code. I am browsing stackoverflow/github issues/any google suggestion and it looks like I am not the first person to encounter this, but I can not figure out for the life of me what am I doing wrong.
Here is the problem. I want to setup VS Code in a way to be able to build the framework (it is C++) right from VS Code using the built-in tools/extensions. Here is the process I was using up until now (in standard terminal in Linux) and it also works in terminal run in VS Code:
cd /path-to-project-main-folder
source scripts/env.sh
cmake .
make -j 10
Now the problem is that when I set up VS Code, open the folder where the framework is, VS Code recognizes it is cmake project and gives me the opportunity to build it. Problem is that when I try to build it, it does not set up the environment first and therefore uses wrong cmake (not the sourced one but the default one build in server) and also wrong libraries and some of them are not even recognized. The problem is in the first line:
source scripts/env.sh
where the environment variables are set and also PATH
s to some libraries and programs. This line is not ran by VS Code before cmake and build.
Does anyone know a solution on how to configure CMake Tools extension to run:
source scripts/env.sh
line before running cmake and then make?
I was looking into some solutions using tasks.json, settings.json files or creating my own kit. But no solution worked for me or I did not completely undestand the solution:
https://github.com/microsoft/vscode-cmake-tools/blob/HEAD/docs/tasks.md
VSCode: Set environment variables via script and man pages of CMake Tools, VS Code,...
VScode remote development: How can I run a build task to source environment variables before running the real build task? ---> but I use cmake
VSCode, how to source environment variable files like setup.bash?