summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-07-14 18:16:46 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-07-14 18:16:46 (GMT)
commit3d1c12b802c3dd3a0284f5f10aec3b98ab6d3a78 (patch)
tree7f54a15847997cffa6979fb9267263a01029cd48
parentb23b1800a586b0afb316f92d9bde82896c804ef5 (diff)
downloadCMake-3d1c12b802c3dd3a0284f5f10aec3b98ab6d3a78.zip
CMake-3d1c12b802c3dd3a0284f5f10aec3b98ab6d3a78.tar.gz
CMake-3d1c12b802c3dd3a0284f5f10aec3b98ab6d3a78.tar.bz2
ENH: remove INCLUDE_EXTERNAL_MSPROJECT name hack, and use target properties instead, fix VXExternalInclude test for VS10
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx16
-rw-r--r--Source/cmGlobalVisualStudio6Generator.h2
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx68
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx13
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h2
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx31
-rw-r--r--Source/cmLocalGenerator.cxx13
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx3
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx4
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx12
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx37
-rw-r--r--Tests/VSExternalInclude/CMakeLists.txt9
15 files changed, 78 insertions, 140 deletions
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 846b1b7..0013d4b 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -247,14 +247,14 @@ void cmGlobalVisualStudio6Generator
}
}
// Write the project into the DSW file
- if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
+ cmTarget* target = &l->second;
+ const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
+ if(expath)
{
- cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- std::string project = cmds[0][0];
- std::string location = cmds[0][1];
+ std::string project = target->GetName();
+ std::string location = expath;
this->WriteExternalProject(fout, project.c_str(),
- location.c_str(), cc.GetDepends());
+ location.c_str(), target->GetUtilities());
}
else
{
@@ -451,7 +451,7 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
- const std::vector<std::string>& dependencies)
+ const std::set<cmStdString>& dependencies)
{
fout << "#########################################################"
"######################\n\n";
@@ -462,7 +462,7 @@ void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
fout << "{{{\n";
- std::vector<std::string>::const_iterator i, end;
+ std::set<cmStdString>::const_iterator i, end;
// write dependencies.
i = dependencies.begin();
end = dependencies.end();
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index 935ee60..ab023a3 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -96,7 +96,7 @@ private:
const char* name, const char* path, cmTarget &t);
void WriteExternalProject(std::ostream& fout,
const char* name, const char* path,
- const std::vector<std::string>& dependencies);
+ const std::set<cmStdString>& dependencies);
void WriteDSWFooter(std::ostream& fout);
};
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 7c2752c..509bf32 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -254,7 +254,7 @@ void cmGlobalVisualStudio71Generator
::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
- const std::vector<std::string>& depends)
+ const std::set<cmStdString>& depends)
{
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
<< name << "\", \""
@@ -267,7 +267,7 @@ void cmGlobalVisualStudio71Generator
if(!depends.empty())
{
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
- std::vector<std::string>::const_iterator it;
+ std::set<cmStdString>::const_iterator it;
for(it = depends.begin(); it != depends.end(); ++it)
{
if(it->size() > 0)
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 9a2bcdb..ed847e1 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -72,7 +72,7 @@ protected:
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
- const std::vector<std::string>& depends);
+ const std::set<cmStdString>& depends);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 1a5a5b8..4a09f39 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -250,12 +250,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
projectTargets.begin(); tt != projectTargets.end(); ++tt)
{
cmTarget* target = *tt;
- if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
+ const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
+ if(expath)
{
- cmCustomCommand cc = target->GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- std::string project = cmds[0][0];
- this->WriteProjectConfigurations(fout, project.c_str(),
+ this->WriteProjectConfigurations(fout, target->GetName(),
true);
}
else
@@ -286,14 +284,13 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
{
cmTarget* target = *tt;
// handle external vc project files
- if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
- {
- cmCustomCommand cc = target->GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- std::string project = cmds[0][0];
- std::string location = cmds[0][1];
+ const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
+ if(expath)
+ {
+ std::string project = target->GetName();
+ std::string location = expath;
this->WriteExternalProject(fout, project.c_str(),
- location.c_str(), cc.GetDepends());
+ location.c_str(), target->GetUtilities());
}
else
{
@@ -340,45 +337,18 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
projectTargets.begin(); tt != projectTargets.end(); ++tt)
{
cmTarget* target = *tt;
- cmMakefile* mf = target->GetMakefile();
- if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
- {
- cmCustomCommand cc = target->GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- std::string name = cmds[0][0];
- std::vector<std::string> depends = cc.GetDepends();
- std::vector<std::string>::iterator iter;
- int depcount = 0;
- for(iter = depends.begin(); iter != depends.end(); ++iter)
- {
- std::string guid = this->GetGUID(iter->c_str());
- if(guid.size() == 0)
- {
- std::string m = "Target: ";
- m += target->GetName();
- m += " depends on unknown target: ";
- m += iter->c_str();
- cmSystemTools::Error(m.c_str());
- }
-
- fout << "\t\t{" << this->GetGUID(name.c_str())
- << "}." << depcount << " = {" << guid.c_str() << "}\n";
- depcount++;
- }
- }
- else
- {
- const char *vcprojName =
- target->GetProperty("GENERATOR_FILE_NAME");
- if (vcprojName)
- {
- std::string dir = mf->GetStartDirectory();
- this->WriteProjectDepends(fout, vcprojName,
- dir.c_str(), *target);
- }
+ cmMakefile* mf = target->GetMakefile();
+ const char *vcprojName =
+ target->GetProperty("GENERATOR_FILE_NAME");
+ if (vcprojName)
+ {
+ std::string dir = mf->GetStartDirectory();
+ this->WriteProjectDepends(fout, vcprojName,
+ dir.c_str(), *target);
}
}
}
+
// Write a SLN file to the stream
void cmGlobalVisualStudio7Generator
::WriteSLNFile(std::ostream& fout,
@@ -562,7 +532,7 @@ void cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
- const std::vector<std::string>&)
+ const std::set<cmStdString>&)
{
std::string d = cmSystemTools::ConvertToOutputPath(location);
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index c2930db..0e2670e 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -142,7 +142,7 @@ protected:
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
- const std::vector<std::string>&
+ const std::set<cmStdString>&
dependencies);
std::string ConvertToSolutionPath(const char* path);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index e204681..43e3a81 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -376,19 +376,6 @@ const char*
cmGlobalVisualStudioGenerator::GetUtilityForTarget(cmTarget& target,
const char* name)
{
- // Handle the external MS project special case.
- if(strncmp(name, "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
- {
- // Note from Ken:
- // kind of weird removing the first 27 letters. my
- // recommendatsions: use cmCustomCommand::GetCommand() to get the
- // project name or get rid of the target name starting with
- // "INCLUDE_EXTERNAL_MSPROJECT_" and use another indicator/flag
- // somewhere. These external project names shouldn't conflict
- // with cmake target names anyways.
- return name+27;
- }
-
// Possibly depend on an intermediate utility target to avoid
// linking.
if(target.GetType() == cmTarget::STATIC_LIBRARY ||
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index ce03049..408118a 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -66,11 +66,11 @@ public:
// return true if target is fortran only
bool TargetIsFortranOnly(cmTarget& t);
+ const char* GetUtilityForTarget(cmTarget& target, const char*);
protected:
virtual void CreateGUID(const char*) {}
void FixUtilityDepends();
- const char* GetUtilityForTarget(cmTarget& target, const char*);
// Does this VS version link targets to each other if there are
// dependencies in the SLN file? This was done for VS versions
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index 2ab46c8..a4de3c0 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -30,37 +30,18 @@ bool cmIncludeExternalMSProjectCommand
#ifdef _WIN32
if(this->Makefile->GetDefinition("WIN32"))
{
- std::string location = args[1];
-
- std::vector<std::string> depends;
- if (args.size() > 2)
- {
- for (unsigned int i=2; i<args.size(); ++i)
- {
- depends.push_back(args[i]);
- }
- }
-
- // Hack together a utility target storing enough information
- // to reproduce the target inclusion.
- std::string utility_name("INCLUDE_EXTERNAL_MSPROJECT");
- utility_name += "_";
- utility_name += args[0];
std::string path = args[1];
cmSystemTools::ConvertToUnixSlashes(path);
// Create a target instance for this utility.
cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY,
- utility_name.c_str());
+ args[0].c_str());
+ target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
- std::vector<std::string> no_outputs;
- cmCustomCommandLines commandLines;
- cmCustomCommandLine commandLine;
- commandLine.push_back(args[0]);
- commandLine.push_back(path);
- commandLines.push_back(commandLine);
- cmCustomCommand cc(no_outputs, depends, commandLines, 0, 0);
- target->GetPostBuildCommands().push_back(cc);
+ for (unsigned int i=2; i<args.size(); ++i)
+ {
+ target->AddUtility(args[i].c_str());
+ }
}
#endif
return true;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index c6fd8db..67fa280 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -193,17 +193,12 @@ void cmLocalGenerator::TraceDependencies()
cmTargets& targets = this->Makefile->GetTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
{
- // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
- // so don't build a projectfile for it
- if (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
+ const char* projectFilename = 0;
+ if (this->IsMakefileGenerator == false) // only use of this variable
{
- const char* projectFilename = 0;
- if (this->IsMakefileGenerator == false) // only use of this variable
- {
- projectFilename = t->second.GetName();
- }
- t->second.TraceDependencies(projectFilename);
+ projectFilename = t->second.GetName();
}
+ t->second.TraceDependencies(projectFilename);
}
}
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index d8f35f1..44318f4 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -31,7 +31,7 @@ class cmVS10XMLParser : public cmXMLParser
{
if(this->DoGUID )
{
- this->GUID.assign(data, length);
+ this->GUID.assign(data+1, length-2);
this->DoGUID = false;
}
}
@@ -112,7 +112,6 @@ void cmLocalVisualStudio10Generator
::ReadAndStoreExternalGUID(const char* name,
const char* path)
{
-
cmVS10XMLParser parser;
parser.ParseFile(path);
std::string guidStoreName = name;
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index c2b5a7c..ca8d55a 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -200,7 +200,9 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
}
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it
- if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
+ const char* path =
+ l->second.GetProperty("EXTERNAL_MSPROJECT");
+ if(!path)
{
// check to see if the dsp is going into a sub-directory
std::string::size_type pos = l->first.rfind('/');
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index e0baa18..8655090 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -159,7 +159,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles()
{
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it
- if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
+ if(!l->second.GetProperty("EXTERNAL_MSPROJECT"))
{
this->CreateSingleVCProj(l->first.c_str(),l->second);
}
@@ -1976,13 +1976,11 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass()
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{
- if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
+ const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT");
+ if(path)
{
- cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- std::string project_name = cmds[0][0];
- this->ReadAndStoreExternalGUID(project_name.c_str(),
- cmds[0][1].c_str());
+ this->ReadAndStoreExternalGUID(
+ l->second.GetName(), path);
}
else
{
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9a89150..19c02da 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -38,20 +38,9 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
this->LocalGenerator =
(cmLocalVisualStudio7Generator*)
this->Makefile->GetLocalGenerator();
- const char* name = this->Target->GetName();
- if (strncmp(name, "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
- {
- cmCustomCommand cc = this->Target->GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- this->Name = cmds[0][0];
- this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
- }
- else
- {
- this->Name = name;
- this->GlobalGenerator->CreateGUID(this->Name.c_str());
- this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
- }
+ this->Name = this->Target->GetName();
+ this->GlobalGenerator->CreateGUID(this->Name.c_str());
+ this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
this->Platform = "|Win32";
this->ComputeObjectNames();
this->BuildFileStream = 0;
@@ -114,7 +103,12 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
void cmVisualStudio10TargetGenerator::Generate()
-{
+{
+ // do not generate external ms projects
+ if(this->Target->GetProperty("EXTERNAL_MSPROJECT"))
+ {
+ return;
+ }
// Tell the global generator the name of the project file
this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
@@ -1227,6 +1221,11 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
void cmVisualStudio10TargetGenerator::WriteProjectReferences()
{
+ // for static libs do not list references
+ if (this->Target->GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ return;
+ }
cmGlobalGenerator::TargetDependSet& depends
= this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
this->WriteString("<ItemGroup>\n", 1);
@@ -1238,12 +1237,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
cmMakefile* mf = dt->GetMakefile();
std::string name = dt->GetName();
std::string path;
- if (strncmp(name.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
+ const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
+ if(p)
{
- cmCustomCommand cc = dt->GetPostBuildCommands()[0];
- const cmCustomCommandLines& cmds = cc.GetCommandLines();
- path = cmds[0][1];
- name = cmds[0][0].c_str();
+ path = p;
}
else
{
diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt
index 4814cc8..931e636 100644
--- a/Tests/VSExternalInclude/CMakeLists.txt
+++ b/Tests/VSExternalInclude/CMakeLists.txt
@@ -40,4 +40,13 @@ ADD_EXECUTABLE(VSExternalInclude ${SOURCES})
# target depends on lib2
ADD_DEPENDENCIES(VSExternalInclude lib2)
+# VS 10 vcxproj files have depends in them
+# Since lib1 and lib2 do not depend on each other
+# then the vcxproj files do not depend on each other
+# and the sln file can no longer be the only source
+# of that depend. So, for VS 10 make the executable
+# depend on lib1 and lib2
+IF(MSVC10)
+ ADD_DEPENDENCIES(VSExternalInclude lib1)
+ENDIF()