nikitablack
nikitablack

Reputation: 4663

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

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.

Upvotes: 1

Views: 846

Answers (2)

Jepessen
Jepessen

Reputation: 12445

You can switch from folder view to CMake targets vies in the solution explorer, by clicking on the button "switching between solutions and available views. In the CMake targets list you can see all targets, also the ones created with add_custom_target.

Upvotes: 1

Florian
Florian

Reputation: 43058

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

Upvotes: 1

Related Questions