Friday, October 29, 2021

[SOLVED] How to build a target added with CMAKEs `add_custom_target()`?

Issue

I have a CMake file which I'm opening in vs2017 with open folder menu. In that CMake I added a custom target with add_custom_target() command but I'm not able to find an action to build it. All menus and pop-ups have only my main target added with add_executable(). But if I add ALL option to add_custom_target() it builds.


Solution

When you use Visual Studio 2017 "Open Folder" feature on a CMake based project, there is at the moment no possibility to just build one of CMake project's custom target.

But this is known issue, see Visual Studio: Developer Community: cmake custom targets not supported

And the good news is, that a fix is coming soon (Version > 15.5.6):

The fix for this is now in our latest Visual Studio Preview release. If you'd like to try out the fix, you can access the preview build here: https://www.visualstudio.com/vs/preview



Answered By - Florian