Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide targets in Visual Studio from CMake

I am generating a .sln with CMake. I want to use Google Test and use that kind of code for adding a 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 targets appearing in the solution explorer: the libraries, the unit tests, etc.

Is there a way to hide these target?

like image 817
Thibaut Mattio Avatar asked Oct 12 '16 18:10

Thibaut Mattio


Video Answer


1 Answers

You can't do it explicitly only in cmake (ATM), but here is one way on how can hide multiple targets more efficiently: Simply put them on in the same "folder" (in cmake) and then hide the folder (in visual studio).

Suppose you have cmake targets called Mm,Nn and Pp that you want to hide in Visual Studio. You need to say to cmake to allow "folders" and Simply set the property called FOLDER like so

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

and then right click on the folder nameOfTheFolderin solution and on hide folder.

If you want to see the hidden folders again, right click on the solution and then Unhide folders (this is at least how it is in visual studio 2010)

like image 173
cantSleepNow Avatar answered Sep 27 '22 21:09

cantSleepNow