diff options
author | Brad King <brad.king@kitware.com> | 2016-03-09 14:42:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-03-09 14:42:18 (GMT) |
commit | b42866a34a742f89a35382d17d58070c73486d92 (patch) | |
tree | 5728aef86df7ff0d6a677875b442d12147da2e46 /Source | |
parent | cd9ba3ec453d547b15ab761e20793a1a17bbbd8d (diff) | |
download | CMake-b42866a34a742f89a35382d17d58070c73486d92.zip CMake-b42866a34a742f89a35382d17d58070c73486d92.tar.gz CMake-b42866a34a742f89a35382d17d58070c73486d92.tar.bz2 |
Drop Visual Studio 6 generator
This generator has been deprecated since CMake 3.3. Remove it.
Update documentation, modules, and tests to drop content specific
to this generator.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 5 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio6Generator.cxx | 451 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio6Generator.h | 113 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 2002 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.h | 105 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 28 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 298 | ||||
-rw-r--r-- | Source/cmTarget.h | 64 | ||||
-rw-r--r-- | Source/cmake.cxx | 4 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 7 |
14 files changed, 1 insertions, 3084 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ab70568..6129293 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -452,8 +452,6 @@ if (WIN32) cmGlobalNMakeMakefileGenerator.h cmGlobalJOMMakefileGenerator.cxx cmGlobalJOMMakefileGenerator.h - cmGlobalVisualStudio6Generator.cxx - cmGlobalVisualStudio6Generator.h cmGlobalVisualStudio71Generator.cxx cmGlobalVisualStudio71Generator.h cmGlobalVisualStudio7Generator.cxx @@ -481,8 +479,6 @@ if (WIN32) cmIDEFlagTable.h cmIDEOptions.cxx cmIDEOptions.h - cmLocalVisualStudio6Generator.cxx - cmLocalVisualStudio6Generator.h cmLocalVisualStudio7Generator.cxx cmLocalVisualStudio7Generator.h cmLocalVisualStudioGenerator.cxx diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 6e819d3..14c7d67 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -241,11 +241,6 @@ public: */ virtual void FindMakeProgram(cmMakefile*); -#if defined(_WIN32) && !defined(__CYGWIN__) - /** Is this the Visual Studio 6 generator? */ - bool IsForVS6() const { return this->GetName() == "Visual Studio 6"; } -#endif - ///! Find a target by name by searching the local generators. cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bb5f921..83422b7 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -642,7 +642,6 @@ void cmGlobalNinjaGenerator // cmGlobalUnixMakefileGenerator3 // cmGlobalGhsMultiGenerator // cmGlobalVisualStudio10Generator -// cmGlobalVisualStudio6Generator // cmGlobalVisualStudio7Generator // cmGlobalXCodeGenerator // Called by: diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx deleted file mode 100644 index 5866c0e..0000000 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ /dev/null @@ -1,451 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmGlobalVisualStudio6Generator.h" -#include "cmLocalVisualStudio6Generator.h" -#include "cmMakefile.h" -#include "cmake.h" -#include "cmGeneratedFileStream.h" -#include <cmsys/FStream.hxx> - -// Utility function to make a valid VS6 *.dsp filename out -// of a CMake target name: -// -std::string GetVS6TargetName(const std::string& targetName) -{ - std::string name(targetName); - - // Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames... - // Replace them with underscores. - // - cmSystemTools::ReplaceString(name, "-", "_"); - - return name; -} - -cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator(cmake* cm) - : cmGlobalVisualStudioGenerator(cm) -{ - this->MSDevCommandInitialized = false; - this->Version = VS6; -} - -void cmGlobalVisualStudio6Generator -::EnableLanguage(std::vector<std::string>const& lang, - cmMakefile *mf, - bool optional) -{ - mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); - mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - this->GenerateConfigurations(mf); - this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); -} - -void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) -{ - std::string fname= mf->GetRequiredDefinition("CMAKE_ROOT"); - const char* def= mf->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); - if(def) - { - fname = def; - } - else - { - fname += "/Templates"; - } - fname += "/CMakeVisualStudio6Configurations.cmake"; - if(!mf->ReadDependentFile(fname.c_str())) - { - cmSystemTools::Error("Cannot open ", fname.c_str(), - ". Please copy this file from the main " - "CMake/Templates directory and edit it for " - "your build configurations."); - } - else if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::Error("CMAKE_CONFIGURATION_TYPES not set by ", - fname.c_str(), - ". Please copy this file from the main " - "CMake/Templates directory and edit it for " - "your build configurations."); - } -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio6Generator::FindMakeProgram(cmMakefile* mf) -{ - this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf); - mf->AddDefinition("CMAKE_VS_MSDEV_COMMAND", - this->GetMSDevCommand().c_str()); -} - -//---------------------------------------------------------------------------- -std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand() -{ - if(!this->MSDevCommandInitialized) - { - this->MSDevCommandInitialized = true; - this->MSDevCommand = this->FindMSDevCommand(); - } - return this->MSDevCommand; -} - -//---------------------------------------------------------------------------- -std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() -{ - std::string vscmd; - std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir"; - if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, - cmSystemTools::KeyWOW64_32)) - { - cmSystemTools::ConvertToUnixSlashes(vscmd); - vscmd += "/MSDev98/Bin/"; - } - vscmd += "msdev.exe"; - return vscmd; -} - -//---------------------------------------------------------------------------- -void -cmGlobalVisualStudio6Generator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& /*projectDir*/, - const std::string& targetName, - const std::string& config, - bool /*fast*/, bool /*verbose*/, - std::vector<std::string> const& makeOptions - ) -{ - // now build the test - makeCommand.push_back( - this->SelectMakeProgram(makeProgram, this->GetMSDevCommand()) - ); - - makeCommand.push_back(std::string(projectName)+".dsw"); - makeCommand.push_back("/MAKE"); - std::string targetArg; - bool clean = false; - std::string realTarget = targetName; - if ( realTarget == "clean" ) - { - clean = true; - realTarget = "ALL_BUILD"; - } - if (!realTarget.empty()) - { - targetArg += realTarget; - } - else - { - targetArg += "ALL_BUILD"; - } - targetArg += " - "; - if(!config.empty()) - { - targetArg += config; - } - else - { - targetArg += "Debug"; - } - makeCommand.push_back(targetArg); - if(clean) - { - makeCommand.push_back("/CLEAN"); - } - else - { - makeCommand.push_back("/BUILD"); - } - makeCommand.insert(makeCommand.end(), - makeOptions.begin(), makeOptions.end()); -} - -///! Create a local generator appropriate to this Global Generator -cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf) -{ - return new cmLocalVisualStudio6Generator(this, mf); -} - - -void cmGlobalVisualStudio6Generator::Generate() -{ - // first do the superclass method - this->cmGlobalVisualStudioGenerator::Generate(); - - // Now write out the DSW - this->OutputDSWFile(); - - if (!this->CMakeInstance->GetIsInTryCompile()) - { - const char* cmakeWarnVS6 = - this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS6"); - if (!cmakeWarnVS6 || !cmSystemTools::IsOff(cmakeWarnVS6)) - { - this->CMakeInstance->IssueMessage( - cmake::WARNING, - "The \"Visual Studio 6\" generator is deprecated " - "and will be removed in a future version of CMake." - "\n" - "Add CMAKE_WARN_VS6=OFF to the cache to disable this warning." - ); - } - } -} - -// Write a DSW file to the stream -void cmGlobalVisualStudio6Generator -::WriteDSWFile(std::ostream& fout,cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators) -{ - // Write out the header for a DSW file - this->WriteDSWHeader(fout); - - // Collect all targets under this root generator and the transitive - // closure of their dependencies. - TargetDependSet projectTargets; - TargetDependSet originalTargets; - this->GetTargetSets(projectTargets, originalTargets, root, generators); - OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD"); - - for(OrderedTargetDependSet::const_iterator - tt = orderedProjectTargets.begin(); - tt != orderedProjectTargets.end(); ++tt) - { - cmGeneratorTarget const* target = *tt; - if(target->GetType() == cmState::INTERFACE_LIBRARY) - { - continue; - } - // Write the project into the DSW file - 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(), target->GetUtilities()); - } - else - { - std::string dspname = GetVS6TargetName(target->GetName()); - std::string dir = - target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT); - this->WriteProject(fout, dspname.c_str(), dir.c_str(), target); - } - } - - // Write the footer for the DSW file - this->WriteDSWFooter(fout); -} - -void cmGlobalVisualStudio6Generator -::OutputDSWFile(cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators) -{ - if(generators.empty()) - { - return; - } - std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory(); - fname += "/"; - fname += root->GetProjectName(); - fname += ".dsw"; - cmsys::ofstream fout(fname.c_str()); - if(!fout) - { - cmSystemTools::Error("Error can not open DSW file for write: ", - fname.c_str()); - cmSystemTools::ReportLastSystemError(""); - return; - } - this->WriteDSWFile(fout, root, generators); -} - -// output the DSW file -void cmGlobalVisualStudio6Generator::OutputDSWFile() -{ - std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; - for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { - this->OutputDSWFile(it->second[0], it->second); - } -} - -// Write a dsp file into the DSW file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, - const std::string& dspname, - const char* dir, - const cmGeneratorTarget *target) -{ - fout << "#########################################################" - "######################\n\n"; - fout << "Project: \"" << dspname << "\"=" - << dir << "\\" << dspname << ".dsp - Package Owner=<4>\n\n"; - fout << "Package=<5>\n{{{\n}}}\n\n"; - fout << "Package=<4>\n"; - fout << "{{{\n"; - VSDependSet const& depends = this->VSTargetDepends[target]; - for(VSDependSet::const_iterator di = depends.begin(); - di != depends.end(); ++di) - { - const char* name = di->c_str(); - fout << "Begin Project Dependency\n"; - fout << "Project_Dep_Name " << GetVS6TargetName(name) << "\n"; - fout << "End Project Dependency\n"; - } - fout << "}}}\n\n"; - - UtilityDependsMap::iterator ui = this->UtilityDepends.find(target); - if(ui != this->UtilityDepends.end()) - { - const char* uname = ui->second.c_str(); - fout << "Project: \"" << uname << "\"=" - << dir << "\\" << uname << ".dsp - Package Owner=<4>\n\n"; - fout << - "Package=<5>\n{{{\n}}}\n\n" - "Package=<4>\n" - "{{{\n" - "Begin Project Dependency\n" - "Project_Dep_Name " << dspname << "\n" - "End Project Dependency\n" - "}}}\n\n"; - ; - } -} - - -// Write a dsp file into the DSW file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, - const std::string& name, - const char* location, - const std::set<std::string>& dependencies) -{ - 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::set<std::string>::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 " << GetVS6TargetName(*i) << "\n"; - fout << "End Project Dependency\n"; - } - fout << "}}}\n\n"; -} - - - -// Standard end of dsw file -void cmGlobalVisualStudio6Generator::WriteDSWFooter(std::ostream& fout) -{ - fout << "######################################################" - "#########################\n\n"; - fout << "Global:\n\n"; - fout << "Package=<5>\n{{{\n}}}\n\n"; - fout << "Package=<3>\n{{{\n}}}\n\n"; - fout << "#####################################################" - "##########################\n\n"; -} - - -// ouput standard header for dsw file -void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) -{ - fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n"; - fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n"; -} - -//---------------------------------------------------------------------------- -std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend( - const cmGeneratorTarget *target) -{ - std::string pname = target->GetName(); - pname += "_UTILITY"; - pname = GetVS6TargetName(pname.c_str()); - std::string fname = - target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fname += "/"; - fname += pname; - fname += ".dsp"; - cmGeneratedFileStream fout(fname.c_str()); - fout.SetCopyIfDifferent(true); - fout << - "# Microsoft Developer Studio Project File - Name=\"" - << pname << "\" - Package Owner=<4>\n" - "# Microsoft Developer Studio Generated Build File, Format Version 6.00\n" - "# ** DO NOT EDIT **\n" - "\n" - "# TARGTYPE \"Win32 (x86) Generic Project\" 0x010a\n" - "\n" - "CFG=" << pname << " - Win32 Debug\n" - "!MESSAGE \"" << pname << " - Win32 Debug\"" - " (based on \"Win32 (x86) Generic Project\")\n" - "!MESSAGE \"" << pname << " - Win32 Release\" " - "(based on \"Win32 (x86) Generic Project\")\n" - "!MESSAGE \"" << pname << " - Win32 MinSizeRel\" " - "(based on \"Win32 (x86) Generic Project\")\n" - "!MESSAGE \"" << pname << " - Win32 RelWithDebInfo\" " - "(based on \"Win32 (x86) Generic Project\")\n" - "\n" - "# Begin Project\n" - "# Begin Target\n" - "# Name \"" << pname << " - Win32 Debug\"\n" - "# Name \"" << pname << " - Win32 Release\"\n" - "# Name \"" << pname << " - Win32 MinSizeRel\"\n" - "# Name \"" << pname << " - Win32 RelWithDebInfo\"\n" - "# End Target\n" - "# End Project\n" - ; - return pname; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio6Generator -::GetDocumentation(cmDocumentationEntry& entry) -{ - entry.Name = cmGlobalVisualStudio6Generator::GetActualName(); - entry.Brief = "Deprecated. Generates Visual Studio 6 project files."; -} - -//---------------------------------------------------------------------------- -void -cmGlobalVisualStudio6Generator -::AppendDirectoryForConfig(const std::string& prefix, - const std::string& config, - const std::string& suffix, - std::string& dir) -{ - if(!config.empty()) - { - dir += prefix; - dir += config; - dir += suffix; - } -} diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h deleted file mode 100644 index ae2988e..0000000 --- a/Source/cmGlobalVisualStudio6Generator.h +++ /dev/null @@ -1,113 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmGlobalVisualStudio6Generator_h -#define cmGlobalVisualStudio6Generator_h - -#include "cmGlobalVisualStudioGenerator.h" -#include "cmGlobalGeneratorFactory.h" - -/** \class cmGlobalVisualStudio6Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio6Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator -{ -public: - cmGlobalVisualStudio6Generator(cmake* cm); - static cmGlobalGeneratorFactory* NewFactory() { - return new cmGlobalGeneratorSimpleFactory - <cmGlobalVisualStudio6Generator>(); } - - ///! Get the name for the generator. - virtual std::string GetName() const { - return cmGlobalVisualStudio6Generator::GetActualName();} - static std::string GetActualName() {return "Visual Studio 6";} - - /** Get the documentation entry for this generator. */ - static void GetDocumentation(cmDocumentationEntry& entry); - - /** - * Utilized by the generator factory to determine if this generator - * supports toolsets. - */ - static bool SupportsToolset() { return false; } - - ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); - - /** - * Try to determine system information such as shared library - * extension, pthreads, byte order etc. - */ - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); - - /** - * Try running cmake and building a file. This is used for dynalically - * loaded commands, not as part of the usual build process. - */ - virtual void GenerateBuildCommand( - std::vector<std::string>& makeCommand, - const std::string& makeProgram, - const std::string& projectName, - const std::string& projectDir, - const std::string& targetName, - const std::string& config, - bool fast, bool verbose, - std::vector<std::string> const& makeOptions = std::vector<std::string>() - ); - - /** - * Generate the DSW workspace file. - */ - virtual void OutputDSWFile(); - virtual void OutputDSWFile(cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators); - virtual void WriteDSWFile(std::ostream& fout, - cmLocalGenerator* root, - std::vector<cmLocalGenerator*>& generators); - - /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const std::string& prefix, - const std::string& config, - const std::string& suffix, - std::string& dir); - - ///! What is the configurations directory variable called? - virtual const char* GetCMakeCFGIntDir() const { return "$(IntDir)"; } - - virtual void FindMakeProgram(cmMakefile*); - -protected: - virtual void Generate(); - virtual const char* GetIDEVersion() { return "6.0"; } -private: - virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); } - void GenerateConfigurations(cmMakefile* mf); - void WriteDSWFile(std::ostream& fout); - void WriteDSWHeader(std::ostream& fout); - void WriteProject(std::ostream& fout, - const std::string& name, const char* path, - cmGeneratorTarget const* t); - void WriteExternalProject(std::ostream& fout, - const std::string& name, const char* path, - const std::set<std::string>& dependencies); - void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target); - std::string MSDevCommand; - bool MSDevCommandInitialized; - std::string const& GetMSDevCommand(); - std::string FindMSDevCommand(); -}; - -#endif diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index f827f26..ac9111e 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -26,7 +26,6 @@ public: /** Known versions of Visual Studio. */ enum VSVersion { - VS6 = 60, VS7 = 70, VS71 = 71, VS8 = 80, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6a6359a..1be39a9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2455,7 +2455,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, else { // Make the definition appear properly on the command line. Use - // -DNAME="value" instead of -D"NAME=value" to help VS6 parser. + // -DNAME="value" instead of -D"NAME=value" for historical reasons. std::string::size_type eq = defineIt->find("="); def += defineIt->substr(0, eq); if(eq != defineIt->npos) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx deleted file mode 100644 index cdacb9e..0000000 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ /dev/null @@ -1,2002 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmGlobalGenerator.h" -#include "cmLocalVisualStudio6Generator.h" -#include "cmMakefile.h" -#include "cmSystemTools.h" -#include "cmSourceFile.h" -#include "cmGeneratorTarget.h" -#include "cmCustomCommandGenerator.h" -#include "cmake.h" - -#include "cmComputeLinkInformation.h" - -#include <cmsys/RegularExpression.hxx> -#include <cmsys/FStream.hxx> - -cmLocalVisualStudio6Generator -::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf): - cmLocalVisualStudioGenerator(gg, mf) -{ -} - -cmLocalVisualStudio6Generator::~cmLocalVisualStudio6Generator() -{ -} - -//---------------------------------------------------------------------------- -// Helper class to write build events. -class cmLocalVisualStudio6Generator::EventWriter -{ -public: - EventWriter(cmLocalVisualStudio6Generator* lg, - const std::string& config, std::string& code): - LG(lg), Config(config), Code(code), First(true) {} - void Start(const char* event) - { - this->First = true; - this->Event = event; - } - void Finish() - { - this->Code += (this->First? "" : "\n"); - } - void Write(std::vector<cmCustomCommand> const& ccs) - { - for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin(); - ci != ccs.end(); ++ci) - { - this->Write(*ci); - } - } - void Write(cmCustomCommand const& cc) - { - cmCustomCommandGenerator ccg(cc, this->Config, this->LG); - if(this->First) - { - this->Code += this->Event + "_Cmds="; - this->First = false; - } - else - { - this->Code += "\\\n\t"; - } - this->Code += this->LG->ConstructScript(ccg, "\\\n\t"); - } -private: - cmLocalVisualStudio6Generator* LG; - std::string Config; - std::string& Code; - bool First; - std::string Event; -}; - -void cmLocalVisualStudio6Generator::AddCMakeListsRules() -{ - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); - l != tgts.end(); ++l) - { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY - || (*l)->GetType() == cmState::GLOBAL_TARGET) - { - continue; - } - - // Add a rule to regenerate the build system when the target - // specification source changes. - const char* suppRegenRule = - this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); - if (!cmSystemTools::IsOn(suppRegenRule)) - { - this->AddDSPBuildRule(*l); - } - } -} - -void cmLocalVisualStudio6Generator::Generate() -{ - this->OutputDSPFile(); -} - -void cmLocalVisualStudio6Generator::OutputDSPFile() -{ - // If not an in source build, then create the output directory - if(strcmp(this->GetCurrentBinaryDirectory(), - this->GetSourceDirectory()) != 0) - { - if(!cmSystemTools::MakeDirectory - (this->GetCurrentBinaryDirectory())) - { - cmSystemTools::Error("Error creating directory ", - this->GetCurrentBinaryDirectory()); - } - } - - // Create the DSP or set of DSP's for libraries and executables - - std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); - for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); - l != tgts.end(); ++l) - { - switch((*l)->GetType()) - { - case cmState::STATIC_LIBRARY: - case cmState::OBJECT_LIBRARY: - this->SetBuildType(STATIC_LIBRARY, - (*l)->GetName().c_str(), *l); - break; - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - this->SetBuildType(DLL, - (*l)->GetName().c_str(), *l); - break; - case cmState::EXECUTABLE: - this->SetBuildType(EXECUTABLE, - (*l)->GetName().c_str(), *l); - break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - this->SetBuildType(UTILITY, - (*l)->GetName().c_str(), *l); - break; - case cmState::INTERFACE_LIBRARY: - continue; - default: - cmSystemTools::Error("Bad target type: ", (*l)->GetName().c_str()); - break; - } - // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace - // so don't build a projectfile for it - const char* path = - (*l)->GetProperty("EXTERNAL_MSPROJECT"); - if(!path) - { - // check to see if the dsp is going into a sub-directory - std::string::size_type pos = (*l)->GetName().rfind('/'); - if(pos != std::string::npos) - { - std::string dir = this->GetCurrentBinaryDirectory(); - dir += "/"; - dir += (*l)->GetName().substr(0, pos); - if(!cmSystemTools::MakeDirectory(dir.c_str())) - { - cmSystemTools::Error("Error creating directory: ", dir.c_str()); - } - } - this->CreateSingleDSP((*l)->GetName().c_str(), *l); - } - } -} - -// Utility function to make a valid VS6 *.dsp filename out -// of a CMake target name: -// -extern std::string GetVS6TargetName(const std::string& targetName); - -void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname, - cmGeneratorTarget* target) -{ - // add to the list of projects - std::string pname = GetVS6TargetName(lname); - - // create the dsp.cmake file - std::string fname; - fname = this->GetCurrentBinaryDirectory(); - fname += "/"; - fname += pname; - fname += ".dsp"; - // save the name of the real dsp file - std::string realDSP = fname; - fname += ".cmake"; - cmsys::ofstream fout(fname.c_str()); - if(!fout) - { - cmSystemTools::Error("Error Writing ", fname.c_str()); - cmSystemTools::ReportLastSystemError(""); - } - this->WriteDSPFile(fout,pname.c_str(),target); - fout.close(); - // if the dsp file has changed, then write it. - cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str()); -} - - -void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmGeneratorTarget *tgt) -{ - std::string dspname = GetVS6TargetName(tgt->GetName()); - dspname += ".dsp.cmake"; - cmCustomCommandLine commandLine; - commandLine.push_back(cmSystemTools::GetCMakeCommand()); - std::string makefileIn = this->GetCurrentSourceDirectory(); - makefileIn += "/"; - makefileIn += "CMakeLists.txt"; - if(!cmSystemTools::FileExists(makefileIn.c_str())) - { - return; - } - std::string comment = "Building Custom Rule "; - comment += makefileIn; - std::string args; - args = "-H"; - args += this->GetSourceDirectory(); - commandLine.push_back(args); - args = "-B"; - args += this->GetBinaryDirectory(); - commandLine.push_back(args); - - std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); - - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); - const char* no_working_directory = 0; - this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles, - makefileIn.c_str(), commandLines, - comment.c_str(), - no_working_directory, true); - if(this->Makefile->GetSource(makefileIn.c_str())) - { - tgt->AddSource(makefileIn); - } - else - { - cmSystemTools::Error("Error adding rule for ", makefileIn.c_str()); - } -} - - -void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, - const std::string& libName, - cmGeneratorTarget *target) -{ - // For utility targets need custom command since pre- and post- - // build does not do anything in Visual Studio 6. In order for the - // rules to run in the correct order as custom commands, we need - // special care for dependencies. The first rule must depend on all - // the dependencies of all the rules. The later rules must each - // depend only on the previous rule. - if ((target->GetType() == cmState::UTILITY || - target->GetType() == cmState::GLOBAL_TARGET) && - (!target->GetPreBuildCommands().empty() || - !target->GetPostBuildCommands().empty())) - { - // Accumulate the dependencies of all the commands. - std::vector<std::string> depends; - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPreBuildCommands().begin(); - cr != target->GetPreBuildCommands().end(); ++cr) - { - depends.insert(depends.end(), - cr->GetDepends().begin(), cr->GetDepends().end()); - } - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPostBuildCommands().begin(); - cr != target->GetPostBuildCommands().end(); ++cr) - { - depends.insert(depends.end(), - cr->GetDepends().begin(), cr->GetDepends().end()); - } - - // Add the pre- and post-build commands in order. - int count = 1; - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPreBuildCommands().begin(); - cr != target->GetPreBuildCommands().end(); ++cr) - { - this->AddUtilityCommandHack(target, count++, depends, *cr); - } - for (std::vector<cmCustomCommand>::const_iterator cr = - target->GetPostBuildCommands().begin(); - cr != target->GetPostBuildCommands().end(); ++cr) - { - this->AddUtilityCommandHack(target, count++, depends, *cr); - } - } - - // We may be modifying the source groups temporarily, so make a copy. - std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - - // get the classes from the source lists then add them to the groups - std::vector<cmSourceFile*> classes; - if (!target->GetConfigCommonSourceFiles(classes)) - { - return; - } - - // now all of the source files have been properly assigned to the target - // now stick them into source groups using the reg expressions - for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); - i != classes.end(); i++) - { - if (!(*i)->GetObjectLibrary().empty()) - { - continue; - } - - // Add the file to the list of sources. - std::string source = (*i)->GetFullPath(); - cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup->AssignSource(*i); - // while we are at it, if it is a .rule file then for visual studio 6 we - // must generate it - if ((*i)->GetPropertyAsBool("__CMAKE_RULE")) - { - if(!cmSystemTools::FileExists(source.c_str())) - { - cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); - // Make sure the path exists for the file - std::string path = cmSystemTools::GetFilenamePath(source); - cmSystemTools::MakeDirectory(path.c_str()); -#if defined(_WIN32) || defined(__CYGWIN__) - cmsys::ofstream sourceFout(source.c_str(), - std::ios::binary | std::ios::out - | std::ios::trunc); -#else - cmsys::ofstream sourceFout(source.c_str(), - std::ios::out | std::ios::trunc); -#endif - if(sourceFout) - { - sourceFout.write("# generated from CMake",22); - sourceFout.flush(); - sourceFout.close(); - } - } - } - } - - // Write the DSP file's header. - this->WriteDSPHeader(fout, libName, target, sourceGroups); - - - // Loop through every source group. - for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin(); - sg != sourceGroups.end(); ++sg) - { - this->WriteGroup(&(*sg), target, fout, libName); - } - - // Write the DSP file's footer. - this->WriteDSPFooter(fout); -} - -void cmLocalVisualStudio6Generator -::WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target, - std::ostream &fout, const std::string& libName) -{ - const std::vector<const cmSourceFile *> &sourceFiles = - sg->GetSourceFiles(); - // If the group is empty, don't write it at all. - - if(sourceFiles.empty() && sg->GetGroupChildren().empty()) - { - return; - } - - // If the group has a name, write the header. - std::string name = sg->GetName(); - if(name != "") - { - this->WriteDSPBeginGroup(fout, name.c_str(), ""); - } - - // Loop through each source in the source group. - for(std::vector<const cmSourceFile *>::const_iterator sf = - sourceFiles.begin(); sf != sourceFiles.end(); ++sf) - { - if (!(*sf)->GetObjectLibrary().empty()) - { - continue; - } - - std::string source = (*sf)->GetFullPath(); - const cmCustomCommand *command = - (*sf)->GetCustomCommand(); - std::string compileFlags; - std::vector<std::string> depends; - std::string objectNameDir; - if(target->HasExplicitObjectName(*sf)) - { - objectNameDir = - cmSystemTools::GetFilenamePath(target->GetObjectName(*sf)); - } - - // Add per-source file flags. - if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS")) - { - compileFlags += cflags; - } - - const std::string& lang = this->GetSourceFileLanguage(*(*sf)); - if(lang == "CXX") - { - // force a C++ file type - compileFlags += " /TP "; - } - else if(lang == "C") - { - // force to c file type - compileFlags += " /TC "; - } - - // Add per-source and per-configuration preprocessor definitions. - std::map<std::string, std::string> cdmap; - - { - std::set<std::string> targetCompileDefinitions; - - this->AppendDefines(targetCompileDefinitions, - (*sf)->GetProperty("COMPILE_DEFINITIONS")); - this->JoinDefines(targetCompileDefinitions, compileFlags, lang); - } - - if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG")) - { - std::set<std::string> debugCompileDefinitions; - this->AppendDefines(debugCompileDefinitions, cdefs); - this->JoinDefines(debugCompileDefinitions, cdmap["DEBUG"], lang); - } - if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE")) - { - std::set<std::string> releaseCompileDefinitions; - this->AppendDefines(releaseCompileDefinitions, cdefs); - this->JoinDefines(releaseCompileDefinitions, cdmap["RELEASE"], lang); - } - if(const char* cdefs = - (*sf)->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL")) - { - std::set<std::string> minsizerelCompileDefinitions; - this->AppendDefines(minsizerelCompileDefinitions, cdefs); - this->JoinDefines(minsizerelCompileDefinitions, cdmap["MINSIZEREL"], - lang); - } - if(const char* cdefs = - (*sf)->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO")) - { - std::set<std::string> relwithdebinfoCompileDefinitions; - this->AppendDefines(relwithdebinfoCompileDefinitions, cdefs); - this->JoinDefines(relwithdebinfoCompileDefinitions, - cdmap["RELWITHDEBINFO"], lang); - } - - bool excludedFromBuild = - (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY")); - - // Check for extra object-file dependencies. - const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS"); - if(dependsValue) - { - cmSystemTools::ExpandListArgument(dependsValue, depends); - } - if (GetVS6TargetName(source) != libName || - target->GetType() == cmState::UTILITY || - target->GetType() == cmState::GLOBAL_TARGET) - { - fout << "# Begin Source File\n\n"; - - // Tell MS-Dev what the source is. If the compiler knows how to - // build it, then it will. - fout << "SOURCE=" << - this->ConvertToOutputFormat(source.c_str(), SHELL) << "\n\n"; - if(!depends.empty()) - { - // Write out the dependencies for the rule. - fout << "USERDEP__HACK="; - for(std::vector<std::string>::const_iterator d = depends.begin(); - d != depends.end(); ++d) - { - fout << "\\\n\t" << - this->ConvertToOutputFormat(d->c_str(), SHELL); - } - fout << "\n"; - } - if (command) - { - const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; - this->WriteCustomRule(fout, source.c_str(), *command, flags); - } - else if(!compileFlags.empty() || !objectNameDir.empty() || - excludedFromBuild || !cdmap.empty()) - { - for(std::vector<std::string>::iterator i - = this->Configurations.begin(); - i != this->Configurations.end(); ++i) - { - // Strip the subdirectory name out of the configuration name. - std::string config = this->GetConfigName(*i); - if (i == this->Configurations.begin()) - { - fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; - } - else - { - fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; - } - if(excludedFromBuild) - { - fout << "# PROP Exclude_From_Build 1\n"; - } - if(!compileFlags.empty()) - { - fout << "\n# ADD CPP " << compileFlags << "\n\n"; - } - std::map<std::string, std::string>::iterator cdi = - cdmap.find(cmSystemTools::UpperCase(config)); - if(cdi != cdmap.end() && !cdi->second.empty()) - { - fout << "\n# ADD CPP " << cdi->second << "\n\n"; - } - if(!objectNameDir.empty()) - { - // Setup an alternate object file directory. - fout << "\n# PROP Intermediate_Dir \"" - << config << "/" << objectNameDir << "\"\n\n"; - } - } - fout << "!ENDIF\n\n"; - } - fout << "# End Source File\n"; - } - } - - std::vector<cmSourceGroup> const& children = sg->GetGroupChildren(); - - for(unsigned int i=0;i<children.size();++i) - { - this->WriteGroup(&children[i], target, fout, libName); - } - - - - - // If the group has a name, write the footer. - if(name != "") - { - this->WriteDSPEndGroup(fout); - } - -} - - -void -cmLocalVisualStudio6Generator -::AddUtilityCommandHack(cmGeneratorTarget *target, int count, - std::vector<std::string>& depends, - const cmCustomCommand& origCommand) -{ - // Create a fake output that forces the rule to run. - char* output = new char[(strlen(this->GetCurrentBinaryDirectory()) - + target->GetName().size() + 30)]; - sprintf(output,"%s/%s_force_%i", this->GetCurrentBinaryDirectory(), - target->GetName().c_str(), count); - const char* comment = origCommand.GetComment(); - if(!comment && origCommand.GetOutputs().empty()) - { - comment = "<hack>"; - } - - // Add the rule with the given dependencies and commands. - std::string no_main_dependency = ""; - if(cmSourceFile* outsf = - this->Makefile->AddCustomCommandToOutput( - output, depends, no_main_dependency, - origCommand.GetCommandLines(), comment, - origCommand.GetWorkingDirectory().c_str())) - { - target->AddSource(outsf->GetFullPath()); - } - - // Replace the dependencies with the output of this rule so that the - // next rule added will run after this one. - depends.clear(); - depends.push_back(output); - - // Free the fake output name. - delete [] output; -} - -void -cmLocalVisualStudio6Generator -::WriteCustomRule(std::ostream& fout, - const char* source, - const cmCustomCommand& command, - const char* flags) -{ - // Write the rule for each configuration. - std::vector<std::string>::iterator i; - for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) - { - std::string config = this->GetConfigName(*i); - cmCustomCommandGenerator ccg(command, config, this); - std::string comment = - this->ConstructComment(ccg, "Building Custom Rule $(InputPath)"); - if(comment == "<hack>") - { - comment = ""; - } - - std::string script = - this->ConstructScript(ccg, "\\\n\t"); - - if (i == this->Configurations.begin()) - { - fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl; - } - else - { - fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; - } - if(flags) - { - fout << "\n# ADD CPP " << flags << "\n\n"; - } - // Write out the dependencies for the rule. - fout << "USERDEP__HACK="; - for(std::vector<std::string>::const_iterator d = - ccg.GetDepends().begin(); - d != ccg.GetDepends().end(); - ++d) - { - // Lookup the real name of the dependency in case it is a CMake target. - std::string dep; - if(this->GetRealDependency(d->c_str(), config.c_str(), dep)) - { - fout << "\\\n\t" << - this->ConvertToOutputFormat(dep.c_str(), SHELL); - } - } - fout << "\n"; - - fout << "# PROP Ignore_Default_Tool 1\n"; - fout << "# Begin Custom Build -"; - if(!comment.empty()) - { - fout << " " << comment.c_str(); - } - fout << "\n\n"; - if(ccg.GetOutputs().empty()) - { - fout << source - << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; - fout << script.c_str() << "\n\n"; - } - else - { - for(std::vector<std::string>::const_iterator o = - ccg.GetOutputs().begin(); - o != ccg.GetOutputs().end(); - ++o) - { - // Write a rule for every output generated by this command. - fout << this->ConvertToOutputFormat(o->c_str(), SHELL) - << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; - fout << script.c_str() << "\n\n"; - } - } - fout << "# End Custom Build\n\n"; - } - - fout << "!ENDIF\n\n"; -} - - -void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout, - const char* group, - const char* filter) -{ - fout << "# Begin Group \"" << group << "\"\n" - "# PROP Default_Filter \"" << filter << "\"\n"; -} - - -void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout) -{ - fout << "# End Group\n"; -} - - - - -void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, - const std::string& libName, - cmGeneratorTarget *target) -{ - std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); - const char *def= - this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); - - if( def) - { - root = def; - } - else - { - root += "/Templates"; - } - - switch(b) - { - case WIN32_EXECUTABLE: - break; - case STATIC_LIBRARY: - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/staticLibFooter.dsptemplate"; - break; - case DLL: - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/DLLHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/DLLFooter.dsptemplate"; - break; - case EXECUTABLE: - if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") ) - { - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/EXEWinHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/EXEFooter.dsptemplate"; - } - else - { - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/EXEHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/EXEFooter.dsptemplate"; - } - break; - case UTILITY: - this->DSPHeaderTemplate = root; - this->DSPHeaderTemplate += "/UtilityHeader.dsptemplate"; - this->DSPFooterTemplate = root; - this->DSPFooterTemplate += "/UtilityFooter.dsptemplate"; - break; - } - - // once the build type is set, determine what configurations are - // possible - cmsys::ifstream fin(this->DSPHeaderTemplate.c_str()); - - cmsys::RegularExpression reg("# Name "); - if(!fin) - { - cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); - } - - // reset this->Configurations - this->Configurations.erase(this->Configurations.begin(), - this->Configurations.end()); - - // now add all the configurations possible - std::string vs6name = GetVS6TargetName(libName); - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str()); - if (reg.find(line)) - { - this->Configurations.push_back(line.substr(reg.end())); - } - } -} - -//---------------------------------------------------------------------------- -cmsys::auto_ptr<cmCustomCommand> -cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmGeneratorTarget* target, - const std::string& config) -{ - cmsys::auto_ptr<cmCustomCommand> pcc; - - // VS6 forgets to create the output directory for archives if it - // differs from the intermediate directory. - if(target->GetType() != cmState::STATIC_LIBRARY) { return pcc; } - - std::string outDir = target->GetDirectory(config, false); - - // Add a pre-link event to create the directory. - cmCustomCommandLine command; - command.push_back(cmSystemTools::GetCMakeCommand()); - command.push_back("-E"); - command.push_back("make_directory"); - command.push_back(outDir); - std::vector<std::string> no_output; - std::vector<std::string> no_byproducts; - std::vector<std::string> no_depends; - cmCustomCommandLines commands; - commands.push_back(command); - pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, - no_depends, commands, 0, 0)); - pcc->SetEscapeOldStyle(false); - pcc->SetEscapeAllowMakeVars(true); - return pcc; -} - -// look for custom rules on a target and collect them together -std::string -cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target, - const std::string& configName, - const std::string& /* libName */) -{ - if (target->GetType() >= cmState::UTILITY ) - { - return ""; - } - - std::string customRuleCode = "# Begin Special Build Tool\n"; - EventWriter event(this, configName, customRuleCode); - - // Write the pre-build and pre-link together (VS6 does not support both). - event.Start("PreLink"); - event.Write(target->GetPreBuildCommands()); - event.Write(target->GetPreLinkCommands()); - cmsys::auto_ptr<cmCustomCommand> pcc( - this->MaybeCreateImplibDir(target, configName, false)); - if(pcc.get()) - { - event.Write(*pcc); - } - pcc = this->MaybeCreateOutputDir(target, configName); - if(pcc.get()) - { - event.Write(*pcc); - } - event.Finish(); - - // Write the post-build rules. - event.Start("PostBuild"); - event.Write(target->GetPostBuildCommands()); - event.Finish(); - - customRuleCode += "# End Special Build Tool\n"; - return customRuleCode; -} - - -inline std::string removeQuotes(const std::string& s) -{ - if(s[0] == '\"' && s[s.size()-1] == '\"') - { - return s.substr(1, s.size()-2); - } - return s; -} - - -std::string -cmLocalVisualStudio6Generator::GetTargetIncludeOptions( - cmGeneratorTarget *target, - const std::string& config) -{ - std::string includeOptions; - - // Setup /I and /LIBPATH options for the resulting DSP file. VS 6 - // truncates long include paths so make it as short as possible if - // the length threatens this problem. - unsigned int maxIncludeLength = 3000; - bool useShortPath = false; - - for(int j=0; j < 2; ++j) - { - std::vector<std::string> includes; - this->GetIncludeDirectories(includes, target, "C", config); - - std::vector<std::string>::iterator i; - for(i = includes.begin(); i != includes.end(); ++i) - { - std::string tmp = - this->ConvertToOutputFormat(i->c_str(), SHELL); - if(useShortPath) - { - cmSystemTools::GetShortPath(tmp.c_str(), tmp); - } - includeOptions += " /I "; - - // quote if not already quoted - if (tmp[0] != '"') - { - includeOptions += "\""; - includeOptions += tmp; - includeOptions += "\""; - } - else - { - includeOptions += tmp; - } - } - - if(j == 0 && includeOptions.size() > maxIncludeLength) - { - includeOptions = ""; - useShortPath = true; - } - else - { - break; - } - } - - return includeOptions; -} - - -// Code in blocks surrounded by a test for this definition is needed -// only for compatibility with user project's replacement DSP -// templates. The CMake templates no longer use them. -#define CM_USE_OLD_VS6 - -void cmLocalVisualStudio6Generator -::WriteDSPHeader(std::ostream& fout, - const std::string& libName, cmGeneratorTarget* target, - std::vector<cmSourceGroup> &) -{ - bool targetBuilds = (target->GetType() >= cmState::EXECUTABLE && - target->GetType() <= cmState::MODULE_LIBRARY); -#ifdef CM_USE_OLD_VS6 - // Lookup the library and executable output directories. - std::string libPath; - if(this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) - { - libPath = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); - } - std::string exePath; - if(this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - } - - // Make sure there are trailing slashes. - if(!libPath.empty()) - { - if(libPath[libPath.size()-1] != '/') - { - libPath += "/"; - } - } - if(!exePath.empty()) - { - if(exePath[exePath.size()-1] != '/') - { - exePath += "/"; - } - } - - std::set<std::string> pathEmitted; - - // determine the link directories - std::string libOptions; - std::string libDebugOptions; - std::string libOptimizedOptions; - - std::string libMultiLineOptions; - std::string libMultiLineOptionsForDebug; - std::string libMultiLineDebugOptions; - std::string libMultiLineOptimizedOptions; - - if(!libPath.empty()) - { - std::string lpath = - this->ConvertToOutputFormat(libPath.c_str(), SHELL); - if(lpath.empty()) - { - lpath = "."; - } - std::string lpathIntDir = libPath + "$(INTDIR)"; - lpathIntDir = - this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL); - if(pathEmitted.insert(lpath).second) - { - libOptions += " /LIBPATH:"; - libOptions += lpathIntDir; - libOptions += " "; - libOptions += " /LIBPATH:"; - libOptions += lpath; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptions += lpathIntDir; - libMultiLineOptions += " "; - libMultiLineOptions += " /LIBPATH:"; - libMultiLineOptions += lpath; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptionsForDebug += lpathIntDir; - libMultiLineOptionsForDebug += " "; - libMultiLineOptionsForDebug += " /LIBPATH:"; - libMultiLineOptionsForDebug += lpath; - libMultiLineOptionsForDebug += " \n"; - } - } - if(!exePath.empty()) - { - std::string lpath = - this->ConvertToOutputFormat(exePath.c_str(), SHELL); - if(lpath.empty()) - { - lpath = "."; - } - std::string lpathIntDir = exePath + "$(INTDIR)"; - lpathIntDir = - this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL); - - if(pathEmitted.insert(lpath).second) - { - libOptions += " /LIBPATH:"; - libOptions += lpathIntDir; - libOptions += " "; - libOptions += " /LIBPATH:"; - libOptions += lpath; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptions += lpathIntDir; - libMultiLineOptions += " "; - libMultiLineOptions += " /LIBPATH:"; - libMultiLineOptions += lpath; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptionsForDebug += lpathIntDir; - libMultiLineOptionsForDebug += " "; - libMultiLineOptionsForDebug += " /LIBPATH:"; - libMultiLineOptionsForDebug += lpath; - libMultiLineOptionsForDebug += " \n"; - } - } - std::vector<std::string>::const_iterator i; - const std::vector<std::string>& libdirs = - target->GetLinkDirectories(); - for(i = libdirs.begin(); i != libdirs.end(); ++i) - { - std::string path = *i; - if(path[path.size()-1] != '/') - { - path += "/"; - } - std::string lpath = - this->ConvertToOutputFormat(path.c_str(), SHELL); - if(lpath.empty()) - { - lpath = "."; - } - std::string lpathIntDir = path + "$(INTDIR)"; - lpathIntDir = - this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL); - if(pathEmitted.insert(lpath).second) - { - libOptions += " /LIBPATH:"; - libOptions += lpathIntDir; - libOptions += " "; - libOptions += " /LIBPATH:"; - libOptions += lpath; - libOptions += " "; - - libMultiLineOptions += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptions += lpathIntDir; - libMultiLineOptions += " "; - libMultiLineOptions += " /LIBPATH:"; - libMultiLineOptions += lpath; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:"; - libMultiLineOptionsForDebug += lpathIntDir; - libMultiLineOptionsForDebug += " "; - libMultiLineOptionsForDebug += " /LIBPATH:"; - libMultiLineOptionsForDebug += lpath; - libMultiLineOptionsForDebug += " \n"; - } - } - // find link libraries - const cmTarget::LinkLibraryVectorType& libs = - target->Target->GetLinkLibrariesForVS6(); - cmTarget::LinkLibraryVectorType::const_iterator j; - for(j = libs.begin(); j != libs.end(); ++j) - { - // add libraries to executables and dlls (but never include - // a library in a library, bad recursion) - // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES - if ((target->GetType() != cmState::SHARED_LIBRARY - && target->GetType() != cmState::STATIC_LIBRARY - && target->GetType() != cmState::MODULE_LIBRARY) || - (target->GetType()==cmState::SHARED_LIBRARY - && libName != GetVS6TargetName(j->first)) || - (target->GetType()==cmState::MODULE_LIBRARY - && libName != GetVS6TargetName(j->first))) - { - // Compute the proper name to use to link this library. - std::string lib; - std::string libDebug; - cmGeneratorTarget* tgt = - this->GlobalGenerator->FindGeneratorTarget(j->first.c_str()); - if(tgt) - { - lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); - libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); - lib += ".lib"; - libDebug += ".lib"; - } - else - { - lib = j->first.c_str(); - libDebug = j->first.c_str(); - if(j->first.find(".lib") == std::string::npos) - { - lib += ".lib"; - libDebug += ".lib"; - } - } - lib = this->ConvertToOutputFormat(lib.c_str(), SHELL); - libDebug = - this->ConvertToOutputFormat(libDebug.c_str(), SHELL); - - if (j->second == GENERAL_LibraryType) - { - libOptions += " "; - libOptions += lib; - libMultiLineOptions += "# ADD LINK32 "; - libMultiLineOptions += lib; - libMultiLineOptions += "\n"; - libMultiLineOptionsForDebug += "# ADD LINK32 "; - libMultiLineOptionsForDebug += libDebug; - libMultiLineOptionsForDebug += "\n"; - } - if (j->second == DEBUG_LibraryType) - { - libDebugOptions += " "; - libDebugOptions += lib; - - libMultiLineDebugOptions += "# ADD LINK32 "; - libMultiLineDebugOptions += libDebug; - libMultiLineDebugOptions += "\n"; - } - if (j->second == OPTIMIZED_LibraryType) - { - libOptimizedOptions += " "; - libOptimizedOptions += lib; - - libMultiLineOptimizedOptions += "# ADD LINK32 "; - libMultiLineOptimizedOptions += lib; - libMultiLineOptimizedOptions += "\n"; - } - } - } -#endif - - // Get include options for this target. - std::string includeOptionsDebug = this->GetTargetIncludeOptions(target, - "DEBUG"); - std::string includeOptionsRelease = this->GetTargetIncludeOptions(target, - "RELEASE"); - std::string includeOptionsRelWithDebInfo = this->GetTargetIncludeOptions( - target, - "RELWITHDEBINFO"); - std::string includeOptionsMinSizeRel = this->GetTargetIncludeOptions(target, - "MINSIZEREL"); - - // Get extra linker options for this target type. - std::string extraLinkOptions; - std::string extraLinkOptionsDebug; - std::string extraLinkOptionsRelease; - std::string extraLinkOptionsMinSizeRel; - std::string extraLinkOptionsRelWithDebInfo; - if(target->GetType() == cmState::EXECUTABLE) - { - extraLinkOptions = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); - extraLinkOptionsDebug = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_DEBUG"); - extraLinkOptionsRelease = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELEASE"); - extraLinkOptionsMinSizeRel = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_MINSIZEREL"); - extraLinkOptionsRelWithDebInfo = this->Makefile-> - GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO"); - } - if(target->GetType() == cmState::SHARED_LIBRARY) - { - extraLinkOptions = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); - extraLinkOptionsDebug = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_DEBUG"); - extraLinkOptionsRelease = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELEASE"); - extraLinkOptionsMinSizeRel = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL"); - extraLinkOptionsRelWithDebInfo = this->Makefile-> - GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO"); - } - if(target->GetType() == cmState::MODULE_LIBRARY) - { - extraLinkOptions = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); - extraLinkOptionsDebug = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_DEBUG"); - extraLinkOptionsRelease = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELEASE"); - extraLinkOptionsMinSizeRel = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL"); - extraLinkOptionsRelWithDebInfo = this->Makefile-> - GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO"); - } - - // Get extra linker options for this target. - if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS")) - { - extraLinkOptions += " "; - extraLinkOptions += targetLinkFlags; - } - - if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_DEBUG")) - { - extraLinkOptionsDebug += " "; - extraLinkOptionsDebug += targetLinkFlags; - } - - if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_RELEASE")) - { - extraLinkOptionsRelease += " "; - extraLinkOptionsRelease += targetLinkFlags; - } - - if(const char* targetLinkFlags = - target->GetProperty("LINK_FLAGS_MINSIZEREL")) - { - extraLinkOptionsMinSizeRel += " "; - extraLinkOptionsMinSizeRel += targetLinkFlags; - } - - if(const char* targetLinkFlags = - target->GetProperty("LINK_FLAGS_RELWITHDEBINFO")) - { - extraLinkOptionsRelWithDebInfo += " "; - extraLinkOptionsRelWithDebInfo += targetLinkFlags; - } - - // Get standard libraries for this language. - if(targetBuilds) - { - // Get the language to use for linking. - std::vector<std::string> configs; - target->Target->GetMakefile()->GetConfigurations(configs); - std::vector<std::string>::const_iterator it = configs.begin(); - const std::string& linkLanguage = target->GetLinkerLanguage(*it); - for ( ; it != configs.end(); ++it) - { - const std::string& configLinkLanguage = target->GetLinkerLanguage(*it); - if (configLinkLanguage != linkLanguage) - { - cmSystemTools::Error - ("Linker language must not vary by configuration for target: ", - target->GetName().c_str()); - } - } - if(linkLanguage.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - target->GetName().c_str()); - return; - } - - // Compute the variable name to lookup standard libraries for this - // language. - std::string standardLibsVar = "CMAKE_"; - standardLibsVar += linkLanguage; - standardLibsVar += "_STANDARD_LIBRARIES"; - - // Add standard libraries. - if(const char* stdLibs = - this->Makefile->GetDefinition(standardLibsVar.c_str())) - { - extraLinkOptions += " "; - extraLinkOptions += stdLibs; - } - } - - // Compute version number information. - std::string targetVersionFlag; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { - int major; - int minor; - target->GetTargetVersion(major, minor); - std::ostringstream targetVersionStream; - targetVersionStream << "/version:" << major << "." << minor; - targetVersionFlag = targetVersionStream.str(); - } - - // Compute the real name of the target. - std::string outputName = - "(OUTPUT_NAME is for libraries and executables only)"; - std::string outputNameDebug = outputName; - std::string outputNameRelease = outputName; - std::string outputNameMinSizeRel = outputName; - std::string outputNameRelWithDebInfo = outputName; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { - outputName = target->GetFullName(); - outputNameDebug = target->GetFullName("Debug"); - outputNameRelease = target->GetFullName("Release"); - outputNameMinSizeRel = target->GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target->GetFullName("RelWithDebInfo"); - } - else if(target->GetType() == cmState::OBJECT_LIBRARY) - { - outputName = target->GetName(); - outputName += ".lib"; - outputNameDebug = outputName; - outputNameRelease = outputName; - outputNameMinSizeRel = outputName; - outputNameRelWithDebInfo = outputName; - } - - // Compute the output directory for the target. - std::string outputDirOld; - std::string outputDirDebug; - std::string outputDirRelease; - std::string outputDirMinSizeRel; - std::string outputDirRelWithDebInfo; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { -#ifdef CM_USE_OLD_VS6 - outputDirOld = - removeQuotes(this->ConvertToOutputFormat - (target->GetDirectory().c_str(), SHELL)); -#endif - outputDirDebug = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("Debug").c_str(), SHELL)); - outputDirRelease = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("Release").c_str(), SHELL)); - outputDirMinSizeRel = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("MinSizeRel").c_str(), SHELL)); - outputDirRelWithDebInfo = - removeQuotes(this->ConvertToOutputFormat( - target->GetDirectory("RelWithDebInfo").c_str(), SHELL)); - } - else if(target->GetType() == cmState::OBJECT_LIBRARY) - { - std::string outputDir = cmake::GetCMakeFilesDirectoryPostSlash(); - outputDirDebug = outputDir + "Debug"; - outputDirRelease = outputDir + "Release"; - outputDirMinSizeRel = outputDir + "MinSizeRel"; - outputDirRelWithDebInfo = outputDir + "RelWithDebInfo"; - } - - // Compute the proper link information for the target. - std::string optionsDebug; - std::string optionsRelease; - std::string optionsMinSizeRel; - std::string optionsRelWithDebInfo; - if(target->GetType() == cmState::EXECUTABLE || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) - { - extraLinkOptionsDebug = - extraLinkOptions + " " + extraLinkOptionsDebug; - extraLinkOptionsRelease = - extraLinkOptions + " " + extraLinkOptionsRelease; - extraLinkOptionsMinSizeRel = - extraLinkOptions + " " + extraLinkOptionsMinSizeRel; - extraLinkOptionsRelWithDebInfo = - extraLinkOptions + " " + extraLinkOptionsRelWithDebInfo; - this->ComputeLinkOptions(target, "Debug", extraLinkOptionsDebug, - optionsDebug); - this->ComputeLinkOptions(target, "Release", extraLinkOptionsRelease, - optionsRelease); - this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptionsMinSizeRel, - optionsMinSizeRel); - this->ComputeLinkOptions(target, "RelWithDebInfo", - extraLinkOptionsRelWithDebInfo, - optionsRelWithDebInfo); - } - - // Compute the path of the import library. - std::string targetImplibFlagDebug; - std::string targetImplibFlagRelease; - std::string targetImplibFlagMinSizeRel; - std::string targetImplibFlagRelWithDebInfo; - if(target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY || - target->GetType() == cmState::EXECUTABLE) - { - std::string fullPathImpDebug = target->GetDirectory("Debug", true); - std::string fullPathImpRelease = target->GetDirectory("Release", true); - std::string fullPathImpMinSizeRel = - target->GetDirectory("MinSizeRel", true); - std::string fullPathImpRelWithDebInfo = - target->GetDirectory("RelWithDebInfo", true); - fullPathImpDebug += "/"; - fullPathImpRelease += "/"; - fullPathImpMinSizeRel += "/"; - fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target->GetFullName("Debug", true); - fullPathImpRelease += target->GetFullName("Release", true); - fullPathImpMinSizeRel += target->GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target->GetFullName("RelWithDebInfo", true); - - targetImplibFlagDebug = "/implib:"; - targetImplibFlagRelease = "/implib:"; - targetImplibFlagMinSizeRel = "/implib:"; - targetImplibFlagRelWithDebInfo = "/implib:"; - targetImplibFlagDebug += - this->ConvertToOutputFormat(fullPathImpDebug.c_str(), SHELL); - targetImplibFlagRelease += - this->ConvertToOutputFormat(fullPathImpRelease.c_str(), SHELL); - targetImplibFlagMinSizeRel += - this->ConvertToOutputFormat(fullPathImpMinSizeRel.c_str(), SHELL); - targetImplibFlagRelWithDebInfo += - this->ConvertToOutputFormat(fullPathImpRelWithDebInfo.c_str(), SHELL); - } - -#ifdef CM_USE_OLD_VS6 - // Compute link information for the target. - if(!extraLinkOptions.empty()) - { - libOptions += " "; - libOptions += extraLinkOptions; - libOptions += " "; - libMultiLineOptions += "# ADD LINK32 "; - libMultiLineOptions += extraLinkOptions; - libMultiLineOptions += " \n"; - libMultiLineOptionsForDebug += "# ADD LINK32 "; - libMultiLineOptionsForDebug += extraLinkOptions; - libMultiLineOptionsForDebug += " \n"; - } -#endif - - // are there any custom rules on the target itself - // only if the target is a lib or exe - std::string customRuleCodeRelease - = this->CreateTargetRules(target, "RELEASE", libName); - std::string customRuleCodeDebug - = this->CreateTargetRules(target, "DEBUG", libName); - std::string customRuleCodeMinSizeRel - = this->CreateTargetRules(target, "MINSIZEREL", libName); - std::string customRuleCodeRelWithDebInfo - = this->CreateTargetRules(target, "RELWITHDEBINFO", libName); - - cmsys::ifstream fin(this->DSPHeaderTemplate.c_str()); - if(!fin) - { - cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); - } - std::string staticLibOptions; - std::string staticLibOptionsDebug; - std::string staticLibOptionsRelease; - std::string staticLibOptionsMinSizeRel; - std::string staticLibOptionsRelWithDebInfo; - if(target->GetType() == cmState::STATIC_LIBRARY ) - { - const char *libflagsGlobal = - this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"); - this->AppendFlags(staticLibOptions, libflagsGlobal); - this->AppendFlags(staticLibOptionsDebug, libflagsGlobal); - this->AppendFlags(staticLibOptionsRelease, libflagsGlobal); - this->AppendFlags(staticLibOptionsMinSizeRel, libflagsGlobal); - this->AppendFlags(staticLibOptionsRelWithDebInfo, libflagsGlobal); - - this->AppendFlags(staticLibOptionsDebug, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_DEBUG")); - this->AppendFlags(staticLibOptionsRelease, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELEASE")); - this->AppendFlags(staticLibOptionsMinSizeRel, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL")); - this->AppendFlags(staticLibOptionsRelWithDebInfo, this->Makefile-> - GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO")); - - const char *libflags = target->GetProperty("STATIC_LIBRARY_FLAGS"); - this->AppendFlags(staticLibOptions, libflags); - this->AppendFlags(staticLibOptionsDebug, libflags); - this->AppendFlags(staticLibOptionsRelease, libflags); - this->AppendFlags(staticLibOptionsMinSizeRel, libflags); - this->AppendFlags(staticLibOptionsRelWithDebInfo, libflags); - - this->AppendFlags(staticLibOptionsDebug, - target->GetProperty("STATIC_LIBRARY_FLAGS_DEBUG")); - this->AppendFlags(staticLibOptionsRelease, - target->GetProperty("STATIC_LIBRARY_FLAGS_RELEASE")); - this->AppendFlags(staticLibOptionsMinSizeRel, - target->GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL")); - this->AppendFlags(staticLibOptionsRelWithDebInfo, - target->GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO")); - - std::string objects; - this->OutputObjects(target, "LIB", objects); - if(!objects.empty()) - { - objects = "\n" + objects; - staticLibOptionsDebug += objects; - staticLibOptionsRelease += objects; - staticLibOptionsMinSizeRel += objects; - staticLibOptionsRelWithDebInfo += objects; - } - } - - // Add the export symbol definition for shared library objects. - std::string exportSymbol; - if(const char* exportMacro = target->GetExportMacro()) - { - exportSymbol = exportMacro; - } - - std::string line; - std::string libnameExports; - if(!exportSymbol.empty()) - { - libnameExports = "/D \""; - libnameExports += exportSymbol; - libnameExports += "\""; - } - while(cmSystemTools::GetLineFromStream(fin, line)) - { - const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); - if(!mfcFlag) - { - mfcFlag = "0"; - } - cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS", - libnameExports.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG", - mfcFlag); - if(target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::OBJECT_LIBRARY) - { - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG", - staticLibOptionsDebug.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELEASE", - staticLibOptionsRelease.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_MINSIZEREL", - staticLibOptionsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELWITHDEBINFO", - staticLibOptionsRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS", - staticLibOptions.c_str()); - } - if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) - { - cmSystemTools::ReplaceString(line, "/nologo", ""); - } - -#ifdef CM_USE_OLD_VS6 - cmSystemTools::ReplaceString(line, "CM_LIBRARIES", - libOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES", - libDebugOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES", - libOptimizedOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG", - libMultiLineOptionsForDebug.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES", - libMultiLineOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES", - libMultiLineDebugOptions.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES", - libMultiLineOptimizedOptions.c_str()); -#endif - - // Substitute the rules for custom command. When specifying just the - // target name for the command the command can be different for - // different configs - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELEASE", - customRuleCodeRelease.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_DEBUG", - customRuleCodeDebug.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_MINSIZEREL", - customRuleCodeMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO", - customRuleCodeRelWithDebInfo.c_str()); - - // Substitute the real output name into the template. - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG", - outputNameDebug.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE", - outputNameRelease.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL", - outputNameMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO", - outputNameRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str()); - - // Substitute the proper link information into the template. - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG", - optionsDebug.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE", - optionsRelease.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL", - optionsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO", - optionsRelWithDebInfo.c_str()); - - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_DEBUG", - includeOptionsDebug.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELEASE", - includeOptionsRelease.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_MINSIZEREL", - includeOptionsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELWITHDEBINFO", - includeOptionsRelWithDebInfo.c_str()); - - cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG", - targetVersionFlag.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG", - targetImplibFlagDebug.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELEASE", - targetImplibFlagRelease.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_MINSIZEREL", - targetImplibFlagMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELWITHDEBINFO", - targetImplibFlagRelWithDebInfo.c_str()); - - std::string vs6name = GetVS6TargetName(libName); - cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str()); - -#ifdef CM_USE_OLD_VS6 - // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH - // are already quoted in the template file, - // we need to remove the quotes here, we still need - // to convert to output path for unix to win32 conversion - cmSystemTools::ReplaceString - (line, "LIBRARY_OUTPUT_PATH", - removeQuotes(this->ConvertToOutputFormat - (libPath.c_str(), SHELL)).c_str()); - cmSystemTools::ReplaceString - (line, "EXECUTABLE_OUTPUT_PATH", - removeQuotes(this->ConvertToOutputFormat - (exePath.c_str(), SHELL)).c_str()); -#endif - - if(targetBuilds || target->GetType() == cmState::OBJECT_LIBRARY) - { - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_DEBUG", - outputDirDebug.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELEASE", - outputDirRelease.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_MINSIZEREL", - outputDirMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELWITHDEBINFO", - outputDirRelWithDebInfo.c_str()); - if(!outputDirOld.empty()) - { - cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY", - outputDirOld.c_str()); - } - } - - cmSystemTools::ReplaceString(line, - "EXTRA_DEFINES", - this->Makefile->GetDefineFlags()); - const char* debugPostfix - = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX"); - cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX", - debugPostfix?debugPostfix:""); - if(target->GetType() >= cmState::EXECUTABLE && - target->GetType() <= cmState::OBJECT_LIBRARY) - { - // store flags for each configuration - std::string flags = " "; - std::string flagsRelease = " "; - std::string flagsMinSizeRel = " "; - std::string flagsDebug = " "; - std::string flagsRelWithDebInfo = " "; - std::vector<std::string> configs; - target->Target->GetMakefile()->GetConfigurations(configs); - std::vector<std::string>::const_iterator it = configs.begin(); - const std::string& linkLanguage = target->GetLinkerLanguage(*it); - for ( ; it != configs.end(); ++it) - { - const std::string& configLinkLanguage = target->GetLinkerLanguage(*it); - if (configLinkLanguage != linkLanguage) - { - cmSystemTools::Error - ("Linker language must not vary by configuration for target: ", - target->GetName().c_str()); - } - } - if(linkLanguage.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - target->GetName().c_str()); - return; - } - // if CXX is on and the target contains cxx code then add the cxx flags - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += linkLanguage; - baseFlagVar += "_FLAGS"; - flags = this->Makefile->GetSafeDefinition(baseFlagVar.c_str()); - - std::string flagVar = baseFlagVar + "_RELEASE"; - flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" "; - - flagVar = baseFlagVar + "_MINSIZEREL"; - flagsMinSizeRel = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsMinSizeRel += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" "; - - flagVar = baseFlagVar + "_DEBUG"; - flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" "; - - flagVar = baseFlagVar + "_RELWITHDEBINFO"; - flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); - flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; - - this->AddCompileOptions(flags, target, linkLanguage, ""); - this->AddCompileOptions(flagsDebug, target, linkLanguage, "Debug"); - this->AddCompileOptions(flagsRelease, target, linkLanguage, "Release"); - this->AddCompileOptions(flagsMinSizeRel, target, linkLanguage, - "MinSizeRel"); - this->AddCompileOptions(flagsRelWithDebInfo, target, linkLanguage, - "RelWithDebInfo"); - - // if _UNICODE and _SBCS are not found, then add -D_MBCS - std::string defs = this->Makefile->GetDefineFlags(); - if(flags.find("D_UNICODE") == flags.npos && - defs.find("D_UNICODE") == flags.npos && - flags.find("D_SBCS") == flags.npos && - defs.find("D_SBCS") == flags.npos) - { - flags += " /D \"_MBCS\""; - } - - // Add per-target and per-configuration preprocessor definitions. - std::set<std::string> definesSet; - std::set<std::string> debugDefinesSet; - std::set<std::string> releaseDefinesSet; - std::set<std::string> minsizeDefinesSet; - std::set<std::string> debugrelDefinesSet; - - this->AddCompileDefinitions(definesSet, target, "", linkLanguage); - this->AddCompileDefinitions(debugDefinesSet, target, - "DEBUG", linkLanguage); - this->AddCompileDefinitions(releaseDefinesSet, target, - "RELEASE", linkLanguage); - this->AddCompileDefinitions(minsizeDefinesSet, target, - "MINSIZEREL", linkLanguage); - this->AddCompileDefinitions(debugrelDefinesSet, target, - "RELWITHDEBINFO", linkLanguage); - - std::string defines = " "; - std::string debugDefines = " "; - std::string releaseDefines = " "; - std::string minsizeDefines = " "; - std::string debugrelDefines = " "; - - this->JoinDefines(definesSet, defines, ""); - this->JoinDefines(debugDefinesSet, debugDefines, ""); - this->JoinDefines(releaseDefinesSet, releaseDefines, ""); - this->JoinDefines(minsizeDefinesSet, minsizeDefines, ""); - this->JoinDefines(debugrelDefinesSet, debugrelDefines, ""); - - flags += defines; - flagsDebug += debugDefines; - flagsRelease += releaseDefines; - flagsMinSizeRel += minsizeDefines; - flagsRelWithDebInfo += debugrelDefines; - - // The template files have CXX FLAGS in them, that need to be replaced. - // There are not separate CXX and C template files, so we use the same - // variable names. The previous code sets up flags* variables to - // contain the correct C or CXX flags - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", - flagsMinSizeRel.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", - flagsDebug.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO", - flagsRelWithDebInfo.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", - flagsRelease.c_str()); - cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str()); - - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_MINSIZEREL", - minsizeDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_DEBUG", - debugDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELWITHDEBINFO", - debugrelDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELEASE", - releaseDefines.c_str()); - cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS", - defines.c_str()); - } - - fout << line.c_str() << std::endl; - } -} - -void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) -{ - cmsys::ifstream fin(this->DSPFooterTemplate.c_str()); - if(!fin) - { - cmSystemTools::Error("Error Reading ", - this->DSPFooterTemplate.c_str()); - } - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - fout << line << std::endl; - } -} - -//---------------------------------------------------------------------------- -void cmLocalVisualStudio6Generator -::ComputeLinkOptions(cmGeneratorTarget *target, - const std::string& configName, - const std::string extraOptions, - std::string& options) -{ - // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target->GetLinkInformation(configName); - if(!pcli) - { - return; - } - cmComputeLinkInformation& cli = *pcli; - typedef cmComputeLinkInformation::ItemVector ItemVector; - ItemVector const& linkLibs = cli.GetItems(); - std::vector<std::string> const& linkDirs = cli.GetDirectories(); - - this->OutputObjects(target, "LINK", options); - - // Build the link options code. - for(std::vector<std::string>::const_iterator d = linkDirs.begin(); - d != linkDirs.end(); ++d) - { - std::string dir = *d; - if(!dir.empty()) - { - if(dir[dir.size()-1] != '/') - { - dir += "/"; - } - dir += "$(IntDir)"; - options += "# ADD LINK32 /LIBPATH:"; - options += this->ConvertToOutputFormat(dir.c_str(), SHELL); - options += " /LIBPATH:"; - options += this->ConvertToOutputFormat(d->c_str(), SHELL); - options += "\n"; - } - } - for(ItemVector::const_iterator l = linkLibs.begin(); - l != linkLibs.end(); ++l) - { - options += "# ADD LINK32 "; - if(l->IsPath) - { - options += - this->ConvertToOutputFormat(l->Value.c_str(), SHELL); - } - else if (!l->Target - || l->Target->GetType() != cmState::INTERFACE_LIBRARY) - { - options += l->Value; - } - options += "\n"; - } - - // Add extra options if any. - if(!extraOptions.empty()) - { - options += "# ADD LINK32 "; - options += extraOptions; - options += "\n"; - } -} - -//---------------------------------------------------------------------------- -void cmLocalVisualStudio6Generator -::OutputObjects(cmGeneratorTarget* target, const char* tool, - std::string& options) -{ - // VS 6 does not support per-config source locations so we - // list object library content on the link line instead. - std::vector<std::string> objs; - target->UseObjectLibraries(objs, ""); - for(std::vector<std::string>::const_iterator - oi = objs.begin(); oi != objs.end(); ++oi) - { - options += "# ADD "; - options += tool; - options += "32 "; - options += this->ConvertToOutputFormat(oi->c_str(), SHELL); - options += "\n"; - } -} - -std::string -cmLocalVisualStudio6Generator -::GetTargetDirectory(cmGeneratorTarget const*) const -{ - // No per-target directory for this generator (yet). - return ""; -} - -//---------------------------------------------------------------------------- -std::string -cmLocalVisualStudio6Generator -::ComputeLongestObjectDirectory(cmGeneratorTarget const*) const -{ - // Compute the maximum length configuration name. - std::string config_max; - for(std::vector<std::string>::const_iterator - i = this->Configurations.begin(); - i != this->Configurations.end(); ++i) - { - // Strip the subdirectory name out of the configuration name. - std::string config = this->GetConfigName(*i); - if(config.size() > config_max.size()) - { - config_max = config; - } - } - - // Compute the maximum length full path to the intermediate - // files directory for any configuration. This is used to construct - // object file names that do not produce paths that are too long. - std::string dir_max; - dir_max += this->GetCurrentBinaryDirectory(); - dir_max += "/"; - dir_max += config_max; - dir_max += "/"; - return dir_max; -} - -std::string -cmLocalVisualStudio6Generator -::GetConfigName(std::string const& configuration) const -{ - // Strip the subdirectory name out of the configuration name. - std::string config = configuration; - std::string::size_type pos = config.find_last_of(" "); - config = config.substr(pos+1, std::string::npos); - config = config.substr(0, config.size()-1); - return config; -} - -//---------------------------------------------------------------------------- -bool -cmLocalVisualStudio6Generator -::CheckDefinition(std::string const& define) const -{ - // Perform the standard check first. - if(!this->cmLocalGenerator::CheckDefinition(define)) - { - return false; - } - - // Now do the VS6-specific check. - if(define.find_first_of(" ") != define.npos && - define.find_first_of("\"$;") != define.npos) - { - std::ostringstream e; - e << "WARNING: The VS6 IDE does not support preprocessor definition " - << "values with spaces and '\"', '$', or ';'.\n" - << "CMake is dropping a preprocessor definition: " << define << "\n" - << "Consider defining the macro in a (configured) header file.\n"; - cmSystemTools::Message(e.str().c_str()); - return false; - } - - // Assume it is supported. - return true; -} diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h deleted file mode 100644 index dab32a5..0000000 --- a/Source/cmLocalVisualStudio6Generator.h +++ /dev/null @@ -1,105 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmLocalVisualStudio6Generator_h -#define cmLocalVisualStudio6Generator_h - -#include "cmLocalVisualStudioGenerator.h" - -class cmSourceFile; -class cmSourceGroup; -class cmCustomCommand; - -/** \class cmLocalVisualStudio6Generator - * \brief Write a LocalUnix makefiles. - * - * cmLocalVisualStudio6Generator produces a LocalUnix makefile from its - * member this->Makefile. - */ -class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator -{ -public: - ///! Set cache only and recurse to false by default. - cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf); - - virtual ~cmLocalVisualStudio6Generator(); - - virtual void AddCMakeListsRules(); - - /** - * Generate the makefile for this directory. - */ - virtual void Generate(); - - void OutputDSPFile(); - - enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY}; - - /** - * Specify the type of the build: static, dll, or executable. - */ - void SetBuildType(BuildType, const std::string& libName, cmGeneratorTarget*); - - virtual - std::string GetTargetDirectory(cmGeneratorTarget const* target) const; - virtual std::string - ComputeLongestObjectDirectory(cmGeneratorTarget const*) const; -private: - std::string DSPHeaderTemplate; - std::string DSPFooterTemplate; - - void CreateSingleDSP(const std::string& lname, cmGeneratorTarget* tgt); - void WriteDSPFile(std::ostream& fout, const std::string& libName, - cmGeneratorTarget* tgt); - void WriteDSPBeginGroup(std::ostream& fout, - const char* group, - const char* filter); - void WriteDSPEndGroup(std::ostream& fout); - - void WriteDSPHeader(std::ostream& fout, const std::string& libName, - cmGeneratorTarget* tgt, std::vector<cmSourceGroup> &sgs); - - void WriteDSPFooter(std::ostream& fout); - void AddDSPBuildRule(cmGeneratorTarget* tgt); - void WriteCustomRule(std::ostream& fout, - const char* source, - const cmCustomCommand& command, - const char* flags); - void AddUtilityCommandHack(cmGeneratorTarget* target, int count, - std::vector<std::string>& depends, - const cmCustomCommand& origCommand); - void WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target, - std::ostream &fout, const std::string& libName); - class EventWriter; - friend class EventWriter; - cmsys::auto_ptr<cmCustomCommand> - MaybeCreateOutputDir(cmGeneratorTarget *target, const std::string& config); - std::string CreateTargetRules(cmGeneratorTarget* target, - const std::string& configName, - const std::string& libName); - void ComputeLinkOptions(cmGeneratorTarget* target, - const std::string& configName, - const std::string extraOptions, - std::string& options); - void OutputObjects(cmGeneratorTarget* target, const char* tool, - std::string& options); - std::string GetTargetIncludeOptions(cmGeneratorTarget* target, - const std::string& config); - std::vector<std::string> Configurations; - - std::string GetConfigName(std::string const& configuration) const; - - // Special definition check for VS6. - virtual bool CheckDefinition(std::string const& define) const; -}; - -#endif - diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 950b247..8f59e2c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -733,26 +733,6 @@ void cmMakefile::ConfigureFinalPass() "with CMake 2.4 or later. For compatibility with older versions please " "use any CMake 2.8.x release or lower."); } -#if defined(_WIN32) && !defined(__CYGWIN__) - // Do old-style link dependency analysis only for CM_USE_OLD_VS6. - if(this->GetGlobalGenerator()->IsForVS6()) - { - for (cmTargets::iterator l = this->Targets.begin(); - l != this->Targets.end(); l++) - { - if (l->second.GetType() == cmState::INTERFACE_LIBRARY) - { - continue; - } - // Erase any cached link information that might have been comptued - // on-demand during the configuration. This ensures that build - // system generation uses up-to-date information even if other cache - // invalidation code in this source file is buggy. - - l->second.AnalyzeLibDependenciesForVS6(*this); - } - } -#endif } //---------------------------------------------------------------------------- @@ -1334,14 +1314,6 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) return false; } - // VS6 IDE does not support definition values with spaces in - // combination with '"', '$', or ';'. - if((this->GetGlobalGenerator()->GetName() == "Visual Studio 6") && - (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos)) - { - return false; - } - // Definitions with non-trivial values require a policy check. static cmsys::RegularExpression trivial("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$"); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1986e5f..576189f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -55,9 +55,6 @@ public: cmTarget::cmTarget() { this->Makefile = 0; -#if defined(_WIN32) && !defined(__CYGWIN__) - this->LinkLibrariesForVS6Analyzed = false; -#endif this->HaveInstallRule = false; this->DLLPlatform = false; this->IsAndroid = false; @@ -699,9 +696,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, cmTarget::LibraryID tmp; tmp.first = lib; tmp.second = llt; -#if defined(_WIN32) && !defined(__CYGWIN__) - this->LinkLibrariesForVS6.push_back( tmp ); -#endif this->OriginalLinkLibraries.push_back(tmp); // Add the explicit dependency information for this target. This is @@ -811,298 +805,6 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces); } -#if defined(_WIN32) && !defined(__CYGWIN__) -//---------------------------------------------------------------------------- -void -cmTarget::AnalyzeLibDependenciesForVS6( const cmMakefile& mf ) -{ - // There are two key parts of the dependency analysis: (1) - // determining the libraries in the link line, and (2) constructing - // the dependency graph for those libraries. - // - // The latter is done using the cache entries that record the - // dependencies of each library. - // - // The former is a more thorny issue, since it is not clear how to - // determine if two libraries listed on the link line refer to the a - // single library or not. For example, consider the link "libraries" - // /usr/lib/libtiff.so -ltiff - // Is this one library or two? The solution implemented here is the - // simplest (and probably the only practical) one: two libraries are - // the same if their "link strings" are identical. Thus, the two - // libraries above are considered distinct. This also means that for - // dependency analysis to be effective, the CMake user must specify - // libraries build by his project without using any linker flags or - // file extensions. That is, - // LINK_LIBRARIES( One Two ) - // instead of - // LINK_LIBRARIES( -lOne ${binarypath}/libTwo.a ) - // The former is probably what most users would do, but it never - // hurts to document the assumptions. :-) Therefore, in the analysis - // code, the "canonical name" of a library is simply its name as - // given to a LINK_LIBRARIES command. - // - // Also, we will leave the original link line intact; we will just add any - // dependencies that were missing. - // - // There is a problem with recursive external libraries - // (i.e. libraries with no dependency information that are - // recursively dependent). We must make sure that the we emit one of - // the libraries twice to satisfy the recursion, but we shouldn't - // emit it more times than necessary. In particular, we must make - // sure that handling this improbable case doesn't cost us when - // dealing with the common case of non-recursive libraries. The - // solution is to assume that the recursion is satisfied at one node - // of the dependency tree. To illustrate, assume libA and libB are - // extrenal and mutually dependent. Suppose libX depends on - // libA, and libY on libA and libX. Then - // TARGET_LINK_LIBRARIES( Y X A B A ) - // TARGET_LINK_LIBRARIES( X A B A ) - // TARGET_LINK_LIBRARIES( Exec Y ) - // would result in "-lY -lX -lA -lB -lA". This is the correct way to - // specify the dependencies, since the mutual dependency of A and B - // is resolved *every time libA is specified*. - // - // Something like - // TARGET_LINK_LIBRARIES( Y X A B A ) - // TARGET_LINK_LIBRARIES( X A B ) - // TARGET_LINK_LIBRARIES( Exec Y ) - // would result in "-lY -lX -lA -lB", and the mutual dependency - // information is lost. This is because in some case (Y), the mutual - // dependency of A and B is listed, while in another other case (X), - // it is not. Depending on which line actually emits A, the mutual - // dependency may or may not be on the final link line. We can't - // handle this pathalogical case cleanly without emitting extra - // libraries for the normal cases. Besides, the dependency - // information for X is wrong anyway: if we build an executable - // depending on X alone, we would not have the mutual dependency on - // A and B resolved. - // - // IMPROVEMENTS: - // -- The current algorithm will not always pick the "optimal" link line - // when recursive dependencies are present. It will instead break the - // cycles at an aribtrary point. The majority of projects won't have - // cyclic dependencies, so this is probably not a big deal. Note that - // the link line is always correct, just not necessary optimal. - - { - // Expand variables in link library names. This is for backwards - // compatibility with very early CMake versions and should - // eventually be removed. This code was moved here from the end of - // old source list processing code which was called just before this - // method. - for(LinkLibraryVectorType::iterator p = this->LinkLibrariesForVS6.begin(); - p != this->LinkLibrariesForVS6.end(); ++p) - { - this->Makefile->ExpandVariablesInString(p->first, true, true); - } - } - - // The dependency map. - DependencyMap dep_map; - - // 1. Build the dependency graph - // - for(LinkLibraryVectorType::reverse_iterator lib - = this->LinkLibrariesForVS6.rbegin(); - lib != this->LinkLibrariesForVS6.rend(); ++lib) - { - this->GatherDependenciesForVS6( mf, *lib, dep_map); - } - - // 2. Remove any dependencies that are already satisfied in the original - // link line. - // - for(LinkLibraryVectorType::iterator lib = this->LinkLibrariesForVS6.begin(); - lib != this->LinkLibrariesForVS6.end(); ++lib) - { - for( LinkLibraryVectorType::iterator lib2 = lib; - lib2 != this->LinkLibrariesForVS6.end(); ++lib2) - { - this->DeleteDependencyForVS6( dep_map, *lib, *lib2); - } - } - - - // 3. Create the new link line by simply emitting any dependencies that are - // missing. Start from the back and keep adding. - // - std::set<DependencyMap::key_type> done, visited; - std::vector<DependencyMap::key_type> newLinkLibrariesForVS6; - for(LinkLibraryVectorType::reverse_iterator lib = - this->LinkLibrariesForVS6.rbegin(); - lib != this->LinkLibrariesForVS6.rend(); ++lib) - { - // skip zero size library entries, this may happen - // if a variable expands to nothing. - if (!lib->first.empty()) - { - this->EmitForVS6( *lib, dep_map, done, visited, newLinkLibrariesForVS6 ); - } - } - - // 4. Add the new libraries to the link line. - // - for( std::vector<DependencyMap::key_type>::reverse_iterator k = - newLinkLibrariesForVS6.rbegin(); - k != newLinkLibrariesForVS6.rend(); ++k ) - { - // get the llt from the dep_map - this->LinkLibrariesForVS6.push_back( std::make_pair(k->first,k->second) ); - } - this->LinkLibrariesForVS6Analyzed = true; -} - -//---------------------------------------------------------------------------- -void cmTarget::InsertDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep) -{ - depMap[lib].push_back(dep); -} - -//---------------------------------------------------------------------------- -void cmTarget::DeleteDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep) -{ - // Make sure there is an entry in the map for lib. If so, delete all - // dependencies to dep. There may be repeated entries because of - // external libraries that are specified multiple times. - DependencyMap::iterator map_itr = depMap.find( lib ); - if( map_itr != depMap.end() ) - { - DependencyList& depList = map_itr->second; - DependencyList::iterator begin = - std::remove(depList.begin(), depList.end(), dep); - depList.erase(begin, depList.end()); - } -} - -//---------------------------------------------------------------------------- -void cmTarget::EmitForVS6(const LibraryID lib, - const DependencyMap& dep_map, - std::set<LibraryID>& emitted, - std::set<LibraryID>& visited, - DependencyList& link_line ) -{ - // It's already been emitted - if( emitted.find(lib) != emitted.end() ) - { - return; - } - - // Emit the dependencies only if this library node hasn't been - // visited before. If it has, then we have a cycle. The recursion - // that got us here should take care of everything. - - if( visited.insert(lib).second ) - { - if( dep_map.find(lib) != dep_map.end() ) // does it have dependencies? - { - const DependencyList& dep_on = dep_map.find( lib )->second; - DependencyList::const_reverse_iterator i; - - // To cater for recursive external libraries, we must emit - // duplicates on this link line *unless* they were emitted by - // some other node, in which case we assume that the recursion - // was resolved then. We making the simplifying assumption that - // any duplicates on a single link line are on purpose, and must - // be preserved. - - // This variable will keep track of the libraries that were - // emitted directly from the current node, and not from a - // recursive call. This way, if we come across a library that - // has already been emitted, we repeat it iff it has been - // emitted here. - std::set<DependencyMap::key_type> emitted_here; - for( i = dep_on.rbegin(); i != dep_on.rend(); ++i ) - { - if( emitted_here.find(*i) != emitted_here.end() ) - { - // a repeat. Must emit. - emitted.insert(*i); - link_line.push_back( *i ); - } - else - { - // Emit only if no-one else has - if( emitted.find(*i) == emitted.end() ) - { - // emit dependencies - this->EmitForVS6( *i, dep_map, emitted, visited, link_line ); - // emit self - emitted.insert(*i); - emitted_here.insert(*i); - link_line.push_back( *i ); - } - } - } - } - } -} - -//---------------------------------------------------------------------------- -void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf, - const LibraryID& lib, - DependencyMap& dep_map) -{ - // If the library is already in the dependency map, then it has - // already been fully processed. - if( dep_map.find(lib) != dep_map.end() ) - { - return; - } - - const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" ); - if( deps && strcmp(deps,"") != 0 ) - { - // Make sure this library is in the map, even if it has an empty - // set of dependencies. This distinguishes the case of explicitly - // no dependencies with that of unspecified dependencies. - dep_map[lib]; - - // Parse the dependency information, which is a set of - // type, library pairs separated by ";". There is always a trailing ";". - cmTargetLinkLibraryType llt = GENERAL_LibraryType; - std::string depline = deps; - std::string::size_type start = 0; - std::string::size_type end; - end = depline.find( ";", start ); - while( end != std::string::npos ) - { - std::string l = depline.substr( start, end-start ); - if(!l.empty()) - { - if (l == "debug") - { - llt = DEBUG_LibraryType; - } - else if (l == "optimized") - { - llt = OPTIMIZED_LibraryType; - } - else if (l == "general") - { - llt = GENERAL_LibraryType; - } - else - { - LibraryID lib2(l,llt); - this->InsertDependencyForVS6( dep_map, lib, lib2); - this->GatherDependenciesForVS6( mf, lib2, dep_map); - llt = GENERAL_LibraryType; - } - } - start = end+1; // skip the ; - end = depline.find( ";", start ); - } - // cannot depend on itself - this->DeleteDependencyForVS6( dep_map, lib, lib); - } -} -#endif - //---------------------------------------------------------------------------- static bool whiteListedInterfaceProperty(const std::string& prop) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 97b0871..4e97c2c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -245,13 +245,6 @@ public: cmStringRange GetLinkImplementationEntries() const; cmBacktraceRange GetLinkImplementationBacktraces() const; -#if defined(_WIN32) && !defined(__CYGWIN__) - const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { - return this->LinkLibrariesForVS6;} - - void AnalyzeLibDependenciesForVS6( const cmMakefile& mf ); -#endif - struct StrictTargetComparison { bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; @@ -259,57 +252,6 @@ public: private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; -#if defined(_WIN32) && !defined(__CYGWIN__) - /** - * A list of direct dependencies. Use in conjunction with DependencyMap. - */ - typedef std::vector< LibraryID > DependencyList; - - /** - * This map holds the dependency graph. map[x] returns a set of - * direct dependencies of x. Note that the direct depenencies are - * ordered. This is necessary to handle direct dependencies that - * themselves have no dependency information. - */ - typedef std::map< LibraryID, DependencyList > DependencyMap; - - /** - * Inserts \a dep at the end of the dependency list of \a lib. - */ - void InsertDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep); - - /* - * Deletes \a dep from the dependency list of \a lib. - */ - void DeleteDependencyForVS6( DependencyMap& depMap, - const LibraryID& lib, - const LibraryID& dep); - - /** - * Emits the library \a lib and all its dependencies into link_line. - * \a emitted keeps track of the libraries that have been emitted to - * avoid duplicates--it is more efficient than searching - * link_line. \a visited is used detect cycles. Note that \a - * link_line is in reverse order, in that the dependencies of a - * library are listed before the library itself. - */ - void EmitForVS6( const LibraryID lib, - const DependencyMap& dep_map, - std::set<LibraryID>& emitted, - std::set<LibraryID>& visited, - DependencyList& link_line); - - /** - * Finds the dependencies for \a lib and inserts them into \a - * dep_map. - */ - void GatherDependenciesForVS6( const cmMakefile& mf, - const LibraryID& lib, - DependencyMap& dep_map); -#endif - const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; @@ -338,9 +280,6 @@ private: std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands; LinkLibraryVectorType PrevLinkedLibraries; LinkLibraryVectorType OriginalLinkLibraries; -#if defined(_WIN32) && !defined(__CYGWIN__) - LinkLibraryVectorType LinkLibrariesForVS6; -#endif cmMakefile* Makefile; cmTargetInternalPointer Internal; cmState::TargetType TargetTypeValue; @@ -351,9 +290,6 @@ private: bool IsImportedTarget; bool ImportedGloballyVisible; bool BuildInterfaceIncludesAppended; -#if defined(_WIN32) && !defined(__CYGWIN__) - bool LinkLibrariesForVS6Analyzed; -#endif std::string ProcessSourceItemCMP0049(const std::string& s); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8f6b952..c197dae 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -51,7 +51,6 @@ // include the generator #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) -# include "cmGlobalVisualStudio6Generator.h" # include "cmGlobalVisualStudio7Generator.h" # include "cmGlobalVisualStudio71Generator.h" # include "cmGlobalVisualStudio8Generator.h" @@ -1429,7 +1428,6 @@ int cmake::ActualConfigure() const char* GeneratorName; }; VSRegistryEntryName version[] = { - {"6.0", "Visual Studio 6"}, {"7.0", "Visual Studio 7"}, {"7.1", "Visual Studio 7 .NET 2003"}, {"8.0", "Visual Studio 8 2005"}, @@ -1839,8 +1837,6 @@ void cmake::AddDefaultGenerators() this->Generators.push_back( cmGlobalVisualStudio7Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio6Generator::NewFactory()); - this->Generators.push_back( cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back( cmGlobalNMakeMakefileGenerator::NewFactory()); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index c60b962..600cc1a 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -461,13 +461,6 @@ static int do_build(int ac, char const* const* av) return 1; } - // Hack for vs6 that passes ".\Debug" as "$(IntDir)" value: - // - if (cmSystemTools::StringStartsWith(config.c_str(), ".\\")) - { - config = config.substr(2); - } - cmake cm; return cm.Build(dir, target, config, nativeOptions, clean); #endif |