From 6112e7fc160e611e2b7e299dec5b67dacc3e4c49 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 8 May 2003 16:59:27 -0400 Subject: add support for vs 71 --- Source/CMakeLists.txt | 1 + Source/cmGlobalVisualStudio71Generator.cxx | 286 +++++++++++++++++++++++++++++ Source/cmGlobalVisualStudio71Generator.h | 52 ++++++ Source/cmGlobalVisualStudio7Generator.cxx | 22 +-- Source/cmGlobalVisualStudio7Generator.h | 24 +-- Source/cmLocalVisualStudio7Generator.cxx | 15 +- Source/cmLocalVisualStudio7Generator.h | 28 +-- Source/cmake.cxx | 7 + 8 files changed, 374 insertions(+), 61 deletions(-) create mode 100644 Source/cmGlobalVisualStudio71Generator.cxx create mode 100644 Source/cmGlobalVisualStudio71Generator.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ad46956..bbfaf53 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -72,6 +72,7 @@ IF (WIN32) cmGlobalNMakeMakefileGenerator.cxx cmGlobalVisualStudio6Generator.cxx cmLocalVisualStudio6Generator.cxx + cmGlobalVisualStudio71Generator.cxx cmGlobalVisualStudio7Generator.cxx cmLocalVisualStudio7Generator.cxx cmGlobalBorlandMakefileGenerator.h diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx new file mode 100644 index 0000000..8fc1a08 --- /dev/null +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -0,0 +1,286 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "cmGlobalVisualStudio71Generator.h" +#include "cmLocalVisualStudio7Generator.h" +#include "cmMakefile.h" +#include "cmake.h" +#include "windows.h" + + +cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() +{ + m_FindMakeProgramFile = "CMakeVS71FindMake.cmake"; +} + + + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator() +{ + cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; + lg->SetVersion71(); + lg->SetGlobalGenerator(this); + return lg; +} + + + +// Write a SLN file to the stream +void cmGlobalVisualStudio71Generator::WriteSLNFile(std::ostream& fout) +{ + // Write out the header for a SLN file + this->WriteSLNHeader(fout); + + // Get the home directory with the trailing slash + std::string homedir = m_CMakeInstance->GetHomeDirectory(); + homedir += "/"; + + // For each cmMakefile, create a VCProj for it, and + // add it to this SLN file + unsigned int i; + for(i = 0; i < m_LocalGenerators.size(); ++i) + { + cmMakefile* mf = m_LocalGenerators[i]->GetMakefile(); + + // Get the source directory from the makefile + std::string dir = mf->GetStartDirectory(); + // remove the home directory and / from the source directory + // this gives a relative path + cmSystemTools::ReplaceString(dir, homedir.c_str(), ""); + + // Get the list of create dsp files names from the cmVCProjWriter, more + // than one dsp could have been created per input CMakeLists.txt file + // for each target + std::vector dspnames = + static_cast(m_LocalGenerators[i]) + ->GetCreatedProjectNames(); + cmTargets &tgts = m_LocalGenerators[i]->GetMakefile()->GetTargets(); + cmTargets::iterator l = tgts.begin(); + for(std::vector::iterator si = dspnames.begin(); + l != tgts.end(); ++l) + { + // special handling for the current makefile + if(mf == m_LocalGenerators[0]->GetMakefile()) + { + dir = "."; // no subdirectory for project generated + // if this is the special ALL_BUILD utility, then + // make it depend on every other non UTILITY project. + // This is done by adding the names to the GetUtilities + // vector on the makefile + if(l->first == "ALL_BUILD") + { + unsigned int j; + for(j = 0; j < m_LocalGenerators.size(); ++j) + { + const cmTargets &atgts = + m_LocalGenerators[j]->GetMakefile()->GetTargets(); + for(cmTargets::const_iterator al = atgts.begin(); + al != atgts.end(); ++al) + { + if (al->second.IsInAll()) + { + if (al->second.GetType() == cmTarget::UTILITY) + { + l->second.AddUtility(al->first.c_str()); + } + else + { + l->second.AddLinkLibrary(al->first,cmTarget::GENERAL); + } + } + } + } + } + } + // Write the project into the SLN file + if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0) + { + cmCustomCommand cc = l->second.GetCustomCommands()[0]; + + // dodgy use of the cmCustomCommand's members to store the + // arguments from the INCLUDE_EXTERNAL_MSPROJECT command + std::vector stuff = cc.GetDepends(); + std::vector depends = cc.GetOutputs(); + this->WriteExternalProject(fout, stuff[0].c_str(), + stuff[1].c_str(), depends); + ++si; + } + else + { + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)) + { + this->WriteProject(fout, si->c_str(), dir.c_str(),l->second); + ++si; + } + } + } + } + fout << "Global\n" + << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; + + for(std::vector::iterator i = m_Configurations.begin(); + i != m_Configurations.end(); ++i) + { + fout << "\t\t" << *i << " = " << *i << "\n"; + } + fout << "\tEndGlobalSection\n"; + fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n"; + // loop over again and compute the depends + for(i = 0; i < m_LocalGenerators.size(); ++i) + { + cmMakefile* mf = m_LocalGenerators[i]->GetMakefile(); + cmLocalVisualStudio7Generator* pg = + static_cast(m_LocalGenerators[i]); + // Get the list of create dsp files names from the cmVCProjWriter, more + // than one dsp could have been created per input CMakeLists.txt file + // for each target + std::vector dspnames = + pg->GetCreatedProjectNames(); + cmTargets &tgts = pg->GetMakefile()->GetTargets(); + cmTargets::iterator l = tgts.begin(); + std::string dir = mf->GetStartDirectory(); + for(std::vector::iterator si = dspnames.begin(); + l != tgts.end(); ++l) + { + if ((l->second.GetType() != cmTarget::INSTALL_FILES) + && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)) + { + this->WriteProjectConfigurations(fout, si->c_str(), l->second.IsInAll()); + ++si; + } + } + } + fout << "\tEndGlobalSection\n"; + + // Write the footer for the SLN file + this->WriteSLNFooter(fout); +} + + +// Write a dsp file into the SLN file, +// Note, that dependencies from executables to +// the libraries it uses are also done here +void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, + const char* dspname, + const char* dir, + const cmTarget& t) +{ + std::string d = cmSystemTools::ConvertToOutputPath(dir); + fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + << dspname << "\", \"" + << d << "\\" << dspname << ".vcproj\", \"{" + << this->CreateGUID(dspname) << "}\"\n"; + fout << "\tProjectSection(ProjectDependencies) = postProject\n"; + this->WriteProjectDepends(fout, dspname, dir, t); + fout << "\tEndProjectSection\n"; + + fout <<"EndProject\n"; +} + + + +// Write a dsp file into the SLN file, +// Note, that dependencies from executables to +// the libraries it uses are also done here +void cmGlobalVisualStudio71Generator::WriteProjectDepends(std::ostream& fout, + const char* dspname, + const char* , + const cmTarget& target + ) +{ + int depcount = 0; + // insert Begin Project Dependency Project_Dep_Name project stuff here + if (target.GetType() != cmTarget::STATIC_LIBRARY) + { + cmTarget::LinkLibraries::const_iterator j, jend; + j = target.GetLinkLibraries().begin(); + jend = target.GetLinkLibraries().end(); + for(;j!= jend; ++j) + { + if(j->first != dspname) + { + // is the library part of this SLN ? If so add dependency + std::string libPath = j->first + "_CMAKE_PATH"; + const char* cacheValue + = m_CMakeInstance->GetCacheDefinition(libPath.c_str()); + if(cacheValue) + { + fout << "\t\t{" << this->CreateGUID(j->first.c_str()) << "} = {" + << this->CreateGUID(j->first.c_str()) << "}\n"; + } + } + } + } + + std::set::const_iterator i, end; + // write utility dependencies. + i = target.GetUtilities().begin(); + end = target.GetUtilities().end(); + for(;i!= end; ++i) + { + if(*i != dspname) + { + fout << "\t\t{" << this->CreateGUID(i->c_str()) << "} = {" + << this->CreateGUID(i->c_str()) << "}\n"; + depcount++; + } + } +} + + +// Write a dsp file into the SLN file, +// Note, that dependencies from executables to +// the libraries it uses are also done here +void +cmGlobalVisualStudio71Generator::WriteProjectConfigurations(std::ostream& fout, + const char* name, + bool in_all_build) +{ + std::string guid = this->CreateGUID(name); + for(std::vector::iterator i = m_Configurations.begin(); + i != m_Configurations.end(); ++i) + { + fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n"; + if (in_all_build) + { + fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|Win32\n"; + } + } +} + + + + +// Standard end of dsw file +void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout) +{ + fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" + << "\tEndGlobalSection\n" + << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" + << "\tEndGlobalSection\n" + << "EndGlobal\n"; +} + + +// ouput standard header for dsw file +void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) +{ + fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n"; +} + + diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h new file mode 100644 index 0000000..74ec741 --- /dev/null +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -0,0 +1,52 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmGlobalVisualStudio71Generator_h +#define cmGlobalVisualStudio71Generator_h + +#include "cmGlobalVisualStudio7Generator.h" + + +/** \class cmGlobalVisualStudio71Generator + * \brief Write a Unix makefiles. + * + * cmGlobalVisualStudio71Generator manages UNIX build process for a tree + */ +class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator +{ +public: + cmGlobalVisualStudio71Generator(); + ///! Get the name for the generator. + virtual const char* GetName() { + return cmGlobalVisualStudio71Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 71";} + + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(); + +protected: + virtual void WriteSLNFile(std::ostream& fout); + virtual void WriteProject(std::ostream& fout, + const char* name, const char* path, + const cmTarget &t); + virtual void WriteProjectDepends(std::ostream& fout, + const char* name, const char* path, + const cmTarget &t); + virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); + virtual void WriteSLNFooter(std::ostream& fout); + virtual void WriteSLNHeader(std::ostream& fout); +}; +#endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0180f14..037e34a 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -530,27 +530,7 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& , const char* , const std::vector& ) { - cmSystemTools::Error("WriteExternalProject not implemented"); -// fout << "#########################################################" -// "######################\n\n"; -// fout << "Project: \"" << name << "\"=" -// << location << " - Package Owner=<4>\n\n"; -// fout << "Package=<5>\n{{{\n}}}\n\n"; -// fout << "Package=<4>\n"; -// fout << "{{{\n"; - - -// std::vector::const_iterator i, end; -// // write dependencies. -// i = dependencies.begin(); -// end = dependencies.end(); -// for(;i!= end; ++i) -// { -// fout << "Begin Project Dependency\n"; -// fout << "Project_Dep_Name " << *i << "\n"; -// fout << "End Project Dependency\n"; -// } -// fout << "}}}\n\n"; + cmSystemTools::Error("WriteExternalProject not implemented for Visual Studio 7"); } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 2fa8ca6..c703bea 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -76,22 +76,24 @@ public: */ std::vector *GetConfigurations(); -private: - void SetupTests(); - void GenerateConfigurations(cmMakefile* mf); - void WriteSLNFile(std::ostream& fout); - void WriteSLNHeader(std::ostream& fout); - void WriteProject(std::ostream& fout, - const char* name, const char* path, - const cmTarget &t); - void WriteProjectDepends(std::ostream& fout, +protected: + virtual void WriteSLNFile(std::ostream& fout); + virtual void WriteProject(std::ostream& fout, + const char* name, const char* path, + const cmTarget &t); + virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, const cmTarget &t); - void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); + virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); + virtual void WriteSLNFooter(std::ostream& fout); + virtual void WriteSLNHeader(std::ostream& fout); + + void SetupTests(); + void GenerateConfigurations(cmMakefile* mf); + void WriteExternalProject(std::ostream& fout, const char* name, const char* path, const std::vector& dependencies); - void WriteSLNFooter(std::ostream& fout); std::string CreateGUID(const char* name); std::vector m_Configurations; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 50e6842..ee7225b 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -24,6 +24,7 @@ cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator() { + m_Version71 = false; } cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() @@ -995,9 +996,17 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, { fout << "\n" << "\n" diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index b1ebe43..9469c5f 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -64,6 +64,7 @@ public: { return m_CreatedProjectNames; } + void SetVersion71() {m_Version71 = true;} private: void OutputVCProjFile(); @@ -121,32 +122,7 @@ private: std::string m_LibraryOutputPath; std::string m_ExecutableOutputPath; std::string m_ModuleDefinitionFile; - - /* - std::string m_DSPHeaderTemplate; - std::string m_DSPFooterTemplate; - void WriteDSPBeginGroup(std::ostream& fout, - const char* group, - const char* filter); - void WriteDSPEndGroup(std::ostream& fout); - - - void WriteCustomRule(std::ostream& fout, - const char* source, - const char* command, - const std::set& depends, - const std::set& outputs, - const char* flags); - - std::string CreateTargetRules(const cmTarget &target, - const char *libName); - std::string CombineCommands(const cmSourceGroup::Commands &commands, - cmSourceGroup::CommandFiles &totalCommand, - const char *source); - - std::string m_IncludeOptions; - std::vector m_Configurations; - */ + bool m_Version71; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 035c80f..813a39d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -27,6 +27,7 @@ #if defined(_WIN32) && !defined(__CYGWIN__) #include "cmGlobalVisualStudio6Generator.h" #include "cmGlobalVisualStudio7Generator.h" +#include "cmGlobalVisualStudio71Generator.h" #include "cmGlobalBorlandMakefileGenerator.h" #include "cmGlobalNMakeMakefileGenerator.h" #include "cmWin32ProcessExecution.h" @@ -652,6 +653,7 @@ void cmake::GetRegisteredGenerators(std::vector& names) #if defined(_WIN32) && !defined(__CYGWIN__) names.push_back(cmGlobalVisualStudio6Generator::GetActualName()); names.push_back(cmGlobalVisualStudio7Generator::GetActualName()); + names.push_back(cmGlobalVisualStudio71Generator::GetActualName()); names.push_back(cmGlobalBorlandMakefileGenerator::GetActualName()); names.push_back(cmGlobalNMakeMakefileGenerator::GetActualName()); #else @@ -681,6 +683,11 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) ret = new cmGlobalVisualStudio7Generator; ret->SetCMakeInstance(this); } + if (!strcmp(name,cmGlobalVisualStudio71Generator::GetActualName())) + { + ret = new cmGlobalVisualStudio71Generator; + ret->SetCMakeInstance(this); + } if (!strcmp(name,cmGlobalBorlandMakefileGenerator::GetActualName())) { ret = new cmGlobalBorlandMakefileGenerator; -- cgit v0.12