diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-05-01 20:55:32 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-05-01 20:55:32 (GMT) |
commit | 96ec40943cc1f96d8789fff62c6416a91c01f066 (patch) | |
tree | 1a5dc61afab89b36a15d9fd886c771104e029783 /Source/cmDSPMakefile.cxx | |
parent | 13d4fd06f09ad1beaab01d714c246dbee2568373 (diff) | |
download | CMake-96ec40943cc1f96d8789fff62c6416a91c01f066.zip CMake-96ec40943cc1f96d8789fff62c6416a91c01f066.tar.gz CMake-96ec40943cc1f96d8789fff62c6416a91c01f066.tar.bz2 |
ENH: implement ADD_TARGET command, and add an ALL_BUILD target
Diffstat (limited to 'Source/cmDSPMakefile.cxx')
-rw-r--r-- | Source/cmDSPMakefile.cxx | 83 |
1 files changed, 73 insertions, 10 deletions
diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx index 6ff4a53..78bcb9e 100644 --- a/Source/cmDSPMakefile.cxx +++ b/Source/cmDSPMakefile.cxx @@ -92,13 +92,17 @@ void cmDSPMakefile::OutputDSPFile() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.IsALibrary()) + switch(l->second.GetType()) { - this->SetBuildType(m_LibraryBuildType, l->first.c_str()); - } - else - { - this->SetBuildType(EXECUTABLE,l->first.c_str()); + case cmTarget::LIBRARY: + this->SetBuildType(m_LibraryBuildType, l->first.c_str()); + break; + case cmTarget::EXECUTABLE: + this->SetBuildType(EXECUTABLE,l->first.c_str()); + break; + case cmTarget::UTILITY: + this->SetBuildType(UTILITY, l->first.c_str()); + break; } this->CreateSingleDSP(l->first.c_str(),l->second); } @@ -121,6 +125,39 @@ void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target) this->WriteDSPFile(fout,lname,target); } + +void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout) +{ + std::string dspname = *(m_CreatedProjectNames.end()-1); + dspname += ".dsp"; + std::string makefileIn = "\""; + makefileIn += m_Makefile->GetStartDirectory(); + makefileIn += "/"; + makefileIn += "CMakeLists.txt\""; + std::string dsprule = "\""; + dsprule += m_Makefile->GetHomeDirectory(); + dsprule += "/CMake/Source/CMakeSetupCMD\" "; + dsprule += makefileIn; + dsprule += " -DSP -H\""; + dsprule += m_Makefile->GetHomeDirectory(); + dsprule += "\" -S\""; + dsprule += m_Makefile->GetStartDirectory(); + dsprule += "\" -O\""; + dsprule += m_Makefile->GetStartOutputDirectory(); + dsprule += "\" -B\""; + dsprule += m_Makefile->GetHomeOutputDirectory(); + dsprule += "\""; + + std::set<std::string> depends; + std::set<std::string> outputs; + outputs.insert(outputs.begin(), dspname); + fout << "# Begin Source File\n\n"; + fout << "SOURCE=" << makefileIn.c_str() << "\n\n"; + this->WriteCustomRule(fout, makefileIn.c_str(), dsprule.c_str(), depends, outputs); + fout << "# End Source File\n"; +} + + void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup) { std::string dspname = *(m_CreatedProjectNames.end()-1); @@ -230,7 +267,7 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, // Tell MS-Dev what the source is. If the compiler knows how to // build it, then it will. - fout << "SOURCE=" << source << "\n\n"; + fout << "SOURCE=" << source.c_str() << "\n\n"; // Loop through every custom command generating code from the // current source. @@ -239,8 +276,21 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, { std::string command = c->first; const cmSourceGroup::CommandFiles& commandFiles = c->second; - this->WriteCustomRule(fout, command.c_str(), commandFiles.m_Depends, + this->WriteCustomRule(fout, source.c_str(), command.c_str(), commandFiles.m_Depends, commandFiles.m_Outputs); + // Create a dummy file with the name of the source if it does + // not exist + if(commandFiles.m_Outputs.size() == 0) + { + std::string dummyFile = m_Makefile->GetStartOutputDirectory(); + dummyFile += "/"; + dummyFile += source; + if(!cmSystemTools::FileExists(dummyFile.c_str())) + { + std::ofstream fout(dummyFile.c_str()); + fout << "Dummy file created by cmake as unused source for utility command.\n"; + } + } } fout << "# End Source File\n"; @@ -259,6 +309,7 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, void cmDSPMakefile::WriteCustomRule(std::ostream& fout, + const char* source, const char* command, const std::set<std::string>& depends, const std::set<std::string>& outputs) @@ -274,7 +325,8 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout, { fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl; } - + fout << "# Begin Custom Build\n\n"; + // Write out the dependencies (this seems to be the only way to // get VC6 to actually take these dependencies into account. fout << "USERDEP__HACK= "; @@ -286,6 +338,11 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout, fout << "\n"; fout << "# Begin Custom Build\n\n"; + if(outputs.size() == 0) + { + fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\""; + fout << "\n " << command << "\n\n"; + } // Write a rule for every output generated by this command. for(std::set<std::string>::const_iterator output = outputs.begin(); @@ -348,6 +405,12 @@ void cmDSPMakefile::SetBuildType(BuildType b, const char *libName) m_DSPFooterTemplate = m_Makefile->GetHomeDirectory(); m_DSPFooterTemplate += "/CMake/Source/EXEFooter.dsptemplate"; break; + case UTILITY: + m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory(); + m_DSPHeaderTemplate += "/CMake/Source/UtilityHeader.dsptemplate"; + m_DSPFooterTemplate = m_Makefile->GetHomeDirectory(); + m_DSPFooterTemplate += "/CMake/Source/UtilityFooter.dsptemplate"; + break; } // once the build type is set, determine what configurations are @@ -400,7 +463,7 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName, { // add libraries to executables and dlls (but never include // a library in a library, bad recursion) - if (!target.IsALibrary() || + if (!target.GetType() == cmTarget::LIBRARY || (m_LibraryBuildType == DLL && libName != j->first)) { if (j->second == cmTarget::GENERAL) |