How to hide goals in Visual Studio from CMake

I am creating .sln with CMake. I want to use Google Test and use this code to add new tests:

add_executable(my_test test/my_test.cpp) target_link_libraries(my_test gtest gmock_main) add_test(NAME my_test COMMAND my_test) 

It works fine, but when I open my .sln, I have all the goals that appear in the solution explorer: libraries, unit tests, etc.

Is there any way to hide this target?

+5
source share
1 answer

You cannot do this explicitly only in cmake (ATM), but here is one way to hide several targets more efficiently: just put them in the same folder (in cmake) and then hide the folder (in visual studio).

Suppose you have cmake objects called Mm, Nn, and Pp that you want to hide in Visual Studio. You have to say cmake to allow "folders" and just set a property called FOLDER like that

 set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_target_properties(Mm Nn Pp PROPERTIES FOLDER nameOfTheFolder) 

and then right-click on the nameOfTheFolder folder in the solution and hide it in the folder.

If you want to see the hidden folders again, right-click on the solution and then open the folders (this is at least the same as in Visual Studio 2010).

+2
source

Source: https://habr.com/ru/post/1258099/


All Articles