Merge topic 'vs-project-groups'

fd3249e New USE_FOLDERS property OFF by default. (#3796)
This commit is contained in:
Brad King 2010-10-05 15:31:49 -04:00 committed by CMake Topic Stage
commit dacc47853d
5 changed files with 55 additions and 12 deletions

View File

@ -180,7 +180,22 @@ MACRO(CMAKE_SETUP_TESTING)
ENDMACRO(CMAKE_SETUP_TESTING) ENDMACRO(CMAKE_SETUP_TESTING)
# Provide a way for Visual Studio Express users to turn OFF the new FOLDER
# organization feature. Default to ON for non-Express users. Express users must
# explicitly turn off this option to build CMake in the Express IDE...
#
OPTION(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
MARK_AS_ADVANCED(CMAKE_USE_FOLDERS)
#-----------------------------------------------------------------------
# a macro that only sets the FOLDER target property if it's
# "appropriate"
#-----------------------------------------------------------------------
MACRO(CMAKE_SET_TARGET_FOLDER tgt folder) MACRO(CMAKE_SET_TARGET_FOLDER tgt folder)
IF(CMAKE_USE_FOLDERS)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
# Really, I just want this to be an "if(TARGET ${tgt})" ... # Really, I just want this to be an "if(TARGET ${tgt})" ...
# but I'm not sure that our min req'd., CMake 2.4.5 can handle # but I'm not sure that our min req'd., CMake 2.4.5 can handle
# that... so I'm just activating this for now, with a version # that... so I'm just activating this for now, with a version
@ -190,6 +205,9 @@ MACRO(CMAKE_SET_TARGET_FOLDER tgt folder)
SET_PROPERTY(TARGET "${tgt}" PROPERTY FOLDER "${folder}") SET_PROPERTY(TARGET "${tgt}" PROPERTY FOLDER "${folder}")
ENDIF() ENDIF()
ENDIF() ENDIF()
ELSE()
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS OFF)
ENDIF()
ENDMACRO(CMAKE_SET_TARGET_FOLDER) ENDMACRO(CMAKE_SET_TARGET_FOLDER)

View File

@ -1871,9 +1871,10 @@ bool cmGlobalGenerator::UseFolderProperty()
return cmSystemTools::IsOn(prop); return cmSystemTools::IsOn(prop);
} }
// By default, this feature is ON: // By default, this feature is OFF, since it is not supported in the
// Visual Studio Express editions:
// //
return true; return false;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -323,7 +323,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (cumulativePath.empty()) if (cumulativePath.empty())
{ {
cumulativePath = *iter; cumulativePath = "CMAKE_FOLDER_GUID_" + *iter;
} }
else else
{ {
@ -431,14 +431,22 @@ void cmGlobalVisualStudio7Generator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
{ {
const char *prefix = "CMAKE_FOLDER_GUID_";
const std::string::size_type skip_prefix = strlen(prefix);
std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8"; std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
for(std::map<std::string,std::set<std::string> >::iterator iter = for(std::map<std::string,std::set<std::string> >::iterator iter =
VisualStudioFolders.begin(); iter != VisualStudioFolders.end(); ++iter) VisualStudioFolders.begin(); iter != VisualStudioFolders.end(); ++iter)
{ {
std::string fullName = iter->first; std::string fullName = iter->first;
std::string guid = this->GetGUID(fullName.c_str()); std::string guid = this->GetGUID(fullName.c_str());
std::string nameOnly = cmSystemTools::GetFilenameName(fullName);
cmSystemTools::ReplaceString(fullName, "/", "\\"); cmSystemTools::ReplaceString(fullName, "/", "\\");
if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix))
{
fullName = fullName.substr(skip_prefix);
}
std::string nameOnly = cmSystemTools::GetFilenameName(fullName);
fout << "Project(\"{" << fout << "Project(\"{" <<
guidProjectTypeFolder << "}\") = \"" << guidProjectTypeFolder << "}\") = \"" <<

View File

@ -3504,7 +3504,7 @@ void cmake::DefineProperties(cmake *cm)
cm->DefineProperty cm->DefineProperty
("USE_FOLDERS", cmProperty::GLOBAL, ("USE_FOLDERS", cmProperty::GLOBAL,
"Use the FOLDER target property to organize targets into folders.", "Use the FOLDER target property to organize targets into folders.",
"If not set, CMake treats this property as ON by default. " "If not set, CMake treats this property as OFF by default. "
"CMake generators that are capable of organizing into a " "CMake generators that are capable of organizing into a "
"hierarchy of folders use the values of the FOLDER target " "hierarchy of folders use the values of the FOLDER target "
"property to name those folders. See also the documentation " "property to name those folders. See also the documentation "

View File

@ -7,6 +7,13 @@ find_package(CVS)
find_package(Subversion) find_package(Subversion)
find_package(Git) find_package(Git)
option(ExternalProjectTest_USE_FOLDERS "Enable folder grouping in IDEs." ON)
if(ExternalProjectTest_USE_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
else()
set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
endif()
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER
"CMakePredefinedTargets-in-ExternalProjectTest") "CMakePredefinedTargets-in-ExternalProjectTest")
@ -61,6 +68,15 @@ ExternalProject_Add(${proj}
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
set(proj TargetNameSameAsFolder)
ExternalProject_Add(${proj}
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
DOWNLOAD_COMMAND ""
INSTALL_COMMAND ""
)
set_property(TARGET ${proj} PROPERTY FOLDER "${proj}")
set(proj MinimalNoOpProject) set(proj MinimalNoOpProject)
ExternalProject_Add(${proj} ExternalProject_Add(${proj}
BUILD_COMMAND "" BUILD_COMMAND ""