Merge topic 'fix-8707-add-vs-globals'

df95772 Add support for Visual Studio project-specific globals (#8707)
This commit is contained in:
David Cole 2011-08-02 15:10:09 -04:00 committed by CMake Topic Stage
commit 86bae62bd1
5 changed files with 39 additions and 6 deletions

View File

@ -1279,7 +1279,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
fout << "\t</Files>\n";
// Write the VCProj file's footer.
this->WriteVCProjFooter(fout);
this->WriteVCProjFooter(fout, target);
}
struct cmLVS7GFileConfig
@ -1880,10 +1880,28 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
}
void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout)
void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout,
cmTarget &target)
{
fout << "\t<Globals>\n"
<< "\t</Globals>\n"
fout << "\t<Globals>\n";
cmPropertyMap const& props = target.GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
{
if(i->first.find("VS_GLOBAL_") == 0)
{
std::string name = i->first.substr(10);
if(name != "")
{
fout << "\t\t<Global\n"
<< "\t\t\tName=\"" << name << "\"\n"
<< "\t\t\tValue=\"" << i->second.GetValue() << "\"\n"
<< "\t\t/>\n";
}
}
}
fout << "\t</Globals>\n"
<< "</VisualStudioProject>\n";
}

View File

@ -84,7 +84,7 @@ private:
void WriteProjectFiles();
void WriteVCProjHeader(std::ostream& fout, const char *libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteVCProjFooter(std::ostream& fout);
void WriteVCProjFooter(std::ostream& fout, cmTarget &target);
void CreateSingleVCProj(const char *lname, cmTarget &tgt);
void WriteVCProjFile(std::ostream& fout, const char *libName,
cmTarget &tgt);

View File

@ -143,6 +143,10 @@ public:
"VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER can be set "
"to add support for source control bindings in a Visual Studio "
"project file.\n"
"VS_GLOBAL_<variable> can be set to add a Visual Studio "
"project-specific global variable. "
"Qt integration works better if VS_GLOBAL_QtVersion is set to "
"the Qt version FindQt4.cmake found. For example, \"4.7.3\"\n"
"The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the "
"old way to specify CMake scripts to run before and after "
"installing a target. They are used only when the old "

View File

@ -960,6 +960,14 @@ void cmTarget::DefineProperties(cmake *cm)
"Visual Studio Source Code Control Project.",
"Can be set to change the visual studio source code control "
"project name property.");
cm->DefineProperty
("VS_GLOBAL_<variable>", cmProperty::TARGET,
"Visual Studio project-specific global variable.",
"Tell the Visual Studio generator to set the global variable "
"'<variable>' to a given value in the generated Visual Studio "
"project. Ignored on other generators. Qt integration works "
"better if VS_GLOBAL_QtVersion is set to the version "
"FindQt4.cmake found. For example, \"4.7.3\"");
#if 0
cm->DefineProperty

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.3.20110118)
cmake_minimum_required(VERSION 2.8.4)
project(VSResource)
string(REPLACE "/INCREMENTAL:YES" ""
@ -35,3 +35,6 @@ else()
endif()
add_executable(VSResource main.cpp test.rc)
set_property(TARGET VSResource
PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val")