Custom target not added to list when using "CMake: Build a Target"
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 Which CMake version do you use?
As a work-around you may create a custom task in VS Code to upload firmware.
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 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.
Hmm... May be the same as #207.
Is this issue still present in 0.11.x? I believe a fix has been implemented, even though this issue was forgotten.
This should work. If not then please reopen it.