Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No CMakePredefinedTargets when using solution folders

When using VS solution folders in CMake using:

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(MyProject PROPERTIES FOLDER "MyProjects")

I'm also automatically enabling a CMakePredefinedTargets folder:

enter image description here

Is there a way to avoid this behaviour?

Resetting PREDEFINED_TARGETS_FOLDER can rename the folder but not remove it. Setting the FOLDER property for INSTALL, etc. does not seem to be valid either.

Thanks.

like image 864
maranov Avatar asked Oct 30 '22 07:10

maranov


1 Answers

Edit: After looking into the CMake code I was pretty sure you could set PREDEFINED_TARGETS_FOLDER to "". I've tested it and with CMake 3.3.2 and VS2015 using

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "")

the predefined targets are at root level again.

And, yes if the global USE_FOLDERS property if ON then the predefined targets are hard-wired to always be grouped in the PREDEFINED_TARGETS_FOLDER folder. So setting the FOLDER property of e.g. INSTALL won't help.

As a reference see cmGlobalVisualStudioGenerator.cxx where this behavior was explicitly deactivated for the ALL_BUILD target:

#if 0
    // Can't activate this code because we want ALL_BUILD
    // selected as the default "startup project" when first
    // opened in Visual Studio... And if it's nested in a
    // folder, then that doesn't happen.
    //
    // Organize in the "predefined targets" folder:
    //
    if (this->UseFolderProperty())
    {
        allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
    }     
#endif
like image 53
Florian Avatar answered Nov 12 '22 22:11

Florian