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

Custom target not added to list when using "CMake: Build a Target"

Open stephenwhittle opened this issue 9 years ago • 6 comments

I'm using a custom target so I can 'make upload' to send my compiled executable to my target hardware, as follows:

add_custom_target(upload DEPENDS blinky
COMMAND ./dfu-util.exe -d 0x1eaf:0003 -a 2 -D $<TARGET_FILE:blinky>.bin
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/flash
COMMENT "Uploading to board...")

The target is added to the makefile without issues, I can use the terminal to manually 'make upload' without problems. However when I try to use the command palette to build a target, I only get "all" and "blinky" (my test executable) as options. Am I missing something here?

stephenwhittle avatar Jun 28 '17 09:06 stephenwhittle

@stephenwhittle Which CMake version do you use?

As a work-around you may create a custom task in VS Code to upload firmware.

ytimenkov avatar Jun 28 '17 09:06 ytimenkov

cmake version 3.9.20170620-g8308 built from source.

Thanks for the workaround. Happy to provide more information or minimal repro project if necessary.

I presume, then, that in theory this should have worked?

stephenwhittle avatar Jun 28 '17 10:06 stephenwhittle

@stephenwhittle Thanks for info.

This is a bug (or rather missing feature) in new CMake Server mode implementation. In older versions (or if you set cmake.useCMakeServer to false) CMake Tools ran make help target to get list of targets available, which gave decent results.

In Server Mode CMake is able to give much more precise metadata about project. However this includes non-buildable targets, like INTERFACE or IMPORTED (as I understand the code ;) ) and CMake Tools try to filter them out. Unfortunately it seems that this logic excludes also custom targets.

I suspect repro should be fairly straight-forward.

ytimenkov avatar Jun 28 '17 11:06 ytimenkov

Hmm... May be the same as #207.

vector-of-bool avatar Jul 15 '17 03:07 vector-of-bool

Is this issue still present in 0.11.x? I believe a fix has been implemented, even though this issue was forgotten.

vector-of-bool avatar Apr 23 '18 06:04 vector-of-bool

This should work. If not then please reopen it.

KoeMai avatar Apr 27 '18 21:04 KoeMai