Is it possible to resolve the target build folder from a different extension?
Brief Issue Summary
I would like to access the path of a build target from a different extension.
A bit like ${command:cmake.launchTargetDirectory} from launch.json.
I have tried to invoke the command cmake.launchTargetDirectory via vscode.commands.executeCommand but it returns null.
Is this possible?
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
You should be able to invoke the CMake commands programmatically.
If you have not run a build, cmake.getLaunchTargetDirectory will provide the path without validating if the path exists or not.
vscode.commands.executeCommand('cmake.getLaunchTargetDirectory'); //The full path to the target executable's directory. The existence of the directory is not validated.
However, if you want to invoke the launchTargetDirectory command, the build command has to run first.
// or
vscode.commands.executeCommand('cmake.build');
vscode.commands.executeCommand('cmake.launchTargetDirectory'); //The full path to the target executable's directory. If cmake.buildBeforeRun is true, invoking this substitution will also start a build.
I understand now. I was using this on a project without an executable and CMake is indeed complaining that no executable has been added.
To give a more "functional" approach, would it be meaningful to allow an optional argument so that I can select which target (either an executable or a library) I want to know the path of?