-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using "Launch target" doesn't allow reading files from the project root due to weird cwd #4103
Comments
Hi @nonk123 Thank you for your GitHub issue! To solve your issue, could you try the following four methods? Please let us know if you have any concerns! Thank you!
For example, in a typical launch configuration for Visual Studio Code, you might add:
This way, team members just need to run the script, and it handles everything for them.
You can adjust the asset loading code to look for assets relative to the executable's location: cmake
This way, every time you build, the assets folder will be copied to the build directory. |
Hi and thanks for your response! Just to clarify: the project in question is developed on multiple OSes and with different code editors. The issue at hand is only applicable to development with VS Code and this extension. I wouldn't have any issues building and running my project straight after cloning the repository using the command line: cd MyProject
cmake -S . -B build
cmake --build build
./build/MyProject But if I decide to build and run the project from VS Code, I'll need to either:
Solutions 2 and 3 don't quite apply here. Solution 4 is probably the best case scenario, but I'd still prefer to avoid an unnecessary copy for command line builds. But I guess there isn't a "perfect" way to do this if you have to resort to hacks in all cases. |
Brief Issue Summary
Clicking "Launch target" runs the resulting executable with cwd =
build/Debug
. This means it cannot access e.g. theassets
folder in the project root, which is a major inconvenience when multiple people are working on the same project and have to be instructed on copying that directory manually.I haven't been able to find a cross-platform way to automate this besides using a
file(COPY ...)
hack or modifying the extension config, but it just feels wrong. Is there a different solution that works with the stocksettings.json
so anybody could just jump right in?CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: