vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Is it possible to resolve the target build folder from a different extension?

Open audetto opened this issue 3 years ago • 2 comments

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

audetto avatar Sep 07 '22 10:09 audetto

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.

elahehrashedi avatar Sep 07 '22 20:09 elahehrashedi

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?

audetto avatar Sep 09 '22 07:09 audetto