2005-05-05 20:45:53 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator3
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
|
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
|
|
|
|
cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3()
|
|
|
|
{
|
|
|
|
// This type of makefile always requires unix style paths
|
|
|
|
m_ForceUnixPaths = true;
|
|
|
|
m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalUnixMakefileGenerator3
|
|
|
|
::EnableLanguage(std::vector<std::string>const& languages, cmMakefile *mf)
|
|
|
|
{
|
|
|
|
mf->AddDefinition("CMAKE_CFG_INTDIR",".");
|
|
|
|
this->cmGlobalGenerator::EnableLanguage(languages, mf);
|
|
|
|
std::string path;
|
|
|
|
for(std::vector<std::string>::const_iterator l = languages.begin();
|
|
|
|
l != languages.end(); ++l)
|
|
|
|
{
|
|
|
|
const char* lang = l->c_str();
|
|
|
|
std::string langComp = "CMAKE_";
|
|
|
|
langComp += lang;
|
|
|
|
langComp += "_COMPILER";
|
|
|
|
|
|
|
|
if(!mf->GetDefinition(langComp.c_str()))
|
|
|
|
{
|
|
|
|
cmSystemTools::Error(langComp.c_str(), " not set, after EnableLanguage");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const char* cc = mf->GetRequiredDefinition(langComp.c_str());
|
|
|
|
path = cmSystemTools::FindProgram(cc);
|
|
|
|
if(path.size() == 0)
|
|
|
|
{
|
|
|
|
std::string message = "your ";
|
|
|
|
message += lang;
|
|
|
|
message += " compiler: ";
|
|
|
|
if(cc)
|
|
|
|
{
|
|
|
|
message += cc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message += "(NULL)";
|
|
|
|
}
|
|
|
|
message += " was not found in your path. "
|
|
|
|
"For CMake to correctly use try compile commands, the compiler must "
|
|
|
|
"be in your path. Please add the compiler to your PATH environment,"
|
|
|
|
" and re-run CMake.";
|
|
|
|
cmSystemTools::Error(message.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///! Create a local generator appropriate to this Global Generator
|
|
|
|
cmLocalGenerator *cmGlobalUnixMakefileGenerator3::CreateLocalGenerator()
|
|
|
|
{
|
|
|
|
cmLocalGenerator* lg = new cmLocalUnixMakefileGenerator3;
|
|
|
|
lg->SetGlobalGenerator(this);
|
|
|
|
return lg;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmGlobalUnixMakefileGenerator3::GetDocumentation(cmDocumentationEntry& entry) const
|
|
|
|
{
|
|
|
|
entry.name = this->GetName();
|
|
|
|
entry.brief = "Generates standard UNIX makefiles.";
|
|
|
|
entry.full =
|
|
|
|
"A hierarchy of UNIX makefiles is generated into the build tree. Any "
|
|
|
|
"standard UNIX-style make program can build the project through the "
|
|
|
|
"default make target. A \"make install\" target is also provided.";
|
|
|
|
}
|
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmGlobalUnixMakefileGenerator3::Generate()
|
|
|
|
{
|
|
|
|
// first do superclass method
|
|
|
|
this->cmGlobalGenerator::Generate();
|
|
|
|
|
|
|
|
// write the main makefile
|
|
|
|
this->WriteMainMakefile();
|
2005-05-31 19:46:49 +04:00
|
|
|
this->WriteMainMakefile2();
|
2005-05-06 22:49:38 +04:00
|
|
|
this->WriteMainCMakefile();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile()
|
|
|
|
{
|
|
|
|
// Open the output file. This should not be copy-if-different
|
|
|
|
// because the check-build-system step compares the makefile time to
|
|
|
|
// see if the build system must be regenerated.
|
|
|
|
std::string makefileName =
|
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
|
|
makefileName += "/Makefile";
|
|
|
|
cmGeneratedFileStream makefileStream(makefileName.c_str());
|
|
|
|
if(!makefileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get a local generator for some useful methods
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
|
|
|
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(makefileStream);
|
|
|
|
|
|
|
|
// Write the main entry point target. This must be the VERY first
|
|
|
|
// target so that make with no arguments will run it.
|
|
|
|
// Just depend on the all target to drive the build.
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> no_commands;
|
|
|
|
depends.push_back("all");
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
lg->WriteMakeRule(makefileStream,
|
|
|
|
"Default target executed when no arguments are "
|
|
|
|
"given to make.",
|
|
|
|
"default_target",
|
|
|
|
depends,
|
|
|
|
no_commands);
|
|
|
|
|
2005-07-07 00:16:12 +04:00
|
|
|
lg->WriteMakeVariables(makefileStream, cmLocalGenerator::HOME_OUTPUT);
|
2005-05-06 22:49:38 +04:00
|
|
|
|
|
|
|
lg->WriteSpecialTargetsTop(makefileStream);
|
|
|
|
|
|
|
|
this->WriteAllRules(lg,makefileStream);
|
|
|
|
|
2005-06-01 17:25:10 +04:00
|
|
|
// Keep track of targets already listed.
|
|
|
|
std::set<cmStdString> emittedTargets;
|
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
// write the target convenience rules
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
2005-06-01 17:25:10 +04:00
|
|
|
this->WriteConvenienceRules(makefileStream,lg,emittedTargets);
|
2005-05-06 22:49:38 +04:00
|
|
|
}
|
2005-05-09 23:11:51 +04:00
|
|
|
|
2005-06-01 21:24:37 +04:00
|
|
|
// add a help target as long as there isn;t a real target named help
|
|
|
|
if(emittedTargets.insert("help").second)
|
|
|
|
{
|
|
|
|
this->WriteHelpRule(makefileStream);
|
|
|
|
}
|
2005-05-11 20:44:01 +04:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
2005-05-09 23:11:51 +04:00
|
|
|
lg->WriteSpecialTargetsBottom(makefileStream);
|
2005-05-06 22:49:38 +04:00
|
|
|
}
|
|
|
|
|
2005-05-31 19:46:49 +04:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
|
|
|
|
{
|
|
|
|
// Open the output file. This should not be copy-if-different
|
|
|
|
// because the check-build-system step compares the makefile time to
|
|
|
|
// see if the build system must be regenerated.
|
|
|
|
std::string makefileName =
|
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2005-07-29 17:19:25 +04:00
|
|
|
makefileName += "/CMakeFiles/Makefile2";
|
2005-05-31 19:46:49 +04:00
|
|
|
cmGeneratedFileStream makefileStream(makefileName.c_str());
|
|
|
|
if(!makefileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get a local generator for some useful methods
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
|
|
|
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(makefileStream);
|
|
|
|
|
|
|
|
// Write the main entry point target. This must be the VERY first
|
|
|
|
// target so that make with no arguments will run it.
|
|
|
|
// Just depend on the all target to drive the build.
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> no_commands;
|
|
|
|
depends.push_back("all");
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
lg->WriteMakeRule(makefileStream,
|
|
|
|
"Default target executed when no arguments are "
|
|
|
|
"given to make.",
|
|
|
|
"default_target",
|
|
|
|
depends,
|
|
|
|
no_commands);
|
|
|
|
|
|
|
|
// Write and empty all:
|
|
|
|
lg->WriteMakeRule(makefileStream,
|
|
|
|
"The main recursive all target", "all",
|
|
|
|
no_commands, no_commands);
|
|
|
|
|
2005-07-07 00:16:12 +04:00
|
|
|
lg->WriteMakeVariables(makefileStream,cmLocalGenerator::HOME_OUTPUT);
|
2005-05-31 19:46:49 +04:00
|
|
|
|
|
|
|
// write the target convenience rules
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
|
|
|
// are any parents excluded
|
|
|
|
bool exclude = false;
|
|
|
|
cmLocalGenerator *lg3 = lg;
|
|
|
|
while (lg3)
|
|
|
|
{
|
|
|
|
if (lg3->GetExcludeAll())
|
|
|
|
{
|
|
|
|
exclude = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
lg3 = lg3->GetParent();
|
|
|
|
}
|
|
|
|
this->WriteConvenienceRules2(makefileStream,lg,exclude);
|
|
|
|
}
|
|
|
|
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
|
|
lg->WriteSpecialTargetsBottom(makefileStream);
|
|
|
|
}
|
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
|
|
|
|
{
|
|
|
|
// Open the output file. This should not be copy-if-different
|
|
|
|
// because the check-build-system step compares the makefile time to
|
|
|
|
// see if the build system must be regenerated.
|
2005-05-06 22:49:38 +04:00
|
|
|
std::string cmakefileName =
|
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2005-07-29 17:19:25 +04:00
|
|
|
cmakefileName += "/CMakeFiles/Makefile.cmake";
|
2005-05-05 20:45:53 +04:00
|
|
|
cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
|
|
|
|
if(!cmakefileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
|
|
|
|
std::string makefileName =
|
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
|
|
makefileName += "/Makefile";
|
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
// get a local generator for some useful methods
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
|
|
|
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(cmakefileStream);
|
|
|
|
|
2005-05-12 18:49:56 +04:00
|
|
|
// Save the generator name
|
|
|
|
cmakefileStream
|
|
|
|
<< "# The generator used is:\n"
|
|
|
|
<< "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n";
|
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
// for each cmMakefile get its list of dependencies
|
|
|
|
std::vector<std::string> lfiles;
|
2005-05-13 17:54:30 +04:00
|
|
|
for (unsigned int i = 0; i < m_LocalGenerators.size(); ++i)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
|
|
|
|
|
|
|
// Get the list of files contributing to this generation step.
|
|
|
|
lfiles.insert(lfiles.end(),lg->GetMakefile()->GetListFiles().begin(),
|
|
|
|
lg->GetMakefile()->GetListFiles().end());
|
|
|
|
}
|
|
|
|
// Sort the list and remove duplicates.
|
|
|
|
std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
|
|
|
|
std::vector<std::string>::iterator new_end =
|
|
|
|
std::unique(lfiles.begin(),lfiles.end());
|
|
|
|
lfiles.erase(new_end, lfiles.end());
|
|
|
|
|
|
|
|
// reset lg to the first makefile
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
|
|
|
|
|
|
// Build the path to the cache file.
|
|
|
|
std::string cache = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
|
|
cache += "/CMakeCache.txt";
|
|
|
|
|
|
|
|
// Save the list to the cmake file.
|
|
|
|
cmakefileStream
|
|
|
|
<< "# The top level Makefile was generated from the following files:\n"
|
|
|
|
<< "SET(CMAKE_MAKEFILE_DEPENDS\n"
|
2005-06-10 16:41:47 +04:00
|
|
|
<< " \"" << lg->Convert(cache.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
for(std::vector<std::string>::const_iterator i = lfiles.begin();
|
|
|
|
i != lfiles.end(); ++i)
|
|
|
|
{
|
|
|
|
cmakefileStream
|
2005-06-10 16:41:47 +04:00
|
|
|
<< " \"" << lg->Convert(i->c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT).c_str()
|
2005-05-05 20:45:53 +04:00
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
cmakefileStream
|
|
|
|
<< " )\n\n";
|
|
|
|
|
|
|
|
// Build the path to the cache check file.
|
|
|
|
std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2005-07-29 17:19:25 +04:00
|
|
|
check += "/CMakeFiles/cmake.check_cache";
|
2005-05-05 20:45:53 +04:00
|
|
|
|
|
|
|
// Set the corresponding makefile in the cmake file.
|
|
|
|
cmakefileStream
|
|
|
|
<< "# The corresponding makefile is:\n"
|
|
|
|
<< "SET(CMAKE_MAKEFILE_OUTPUTS\n"
|
2005-06-10 16:41:47 +04:00
|
|
|
<< " \"" << lg->Convert(makefileName.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"
|
|
|
|
<< " \"" << lg->Convert(check.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
|
|
|
|
// add in all the directory information files
|
|
|
|
std::string tmpStr;
|
2005-05-13 17:54:30 +04:00
|
|
|
for (unsigned int i = 0; i < m_LocalGenerators.size(); ++i)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
|
|
|
tmpStr = lg->GetMakefile()->GetStartOutputDirectory();
|
2005-07-29 17:19:25 +04:00
|
|
|
tmpStr += "/CMakeFiles/CMakeDirectoryInformation.cmake";
|
2005-05-13 17:54:30 +04:00
|
|
|
cmakefileStream << " \"" <<
|
|
|
|
lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() << "\"\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
cmakefileStream << " )\n\n";
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2005-07-27 17:49:37 +04:00
|
|
|
this->WriteMainCMakefileLanguageRules(cmakefileStream, m_LocalGenerators);
|
2005-05-06 22:49:38 +04:00
|
|
|
}
|
2005-05-05 20:45:53 +04:00
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
void cmGlobalUnixMakefileGenerator3
|
2005-07-27 17:49:37 +04:00
|
|
|
::WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
|
|
|
|
std::vector<cmLocalGenerator *> &lGenerators)
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg;
|
|
|
|
|
2005-07-27 17:49:37 +04:00
|
|
|
// now list all the target info files
|
2005-05-05 20:45:53 +04:00
|
|
|
cmakefileStream
|
|
|
|
<< "# The set of files whose dependency integrity should be checked:\n";
|
|
|
|
cmakefileStream
|
2005-07-27 17:49:37 +04:00
|
|
|
<< "SET(CMAKE_DEPEND_INFO_FILES\n";
|
|
|
|
for (unsigned int i = 0; i < lGenerators.size(); ++i)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
2005-07-27 17:49:37 +04:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(lGenerators[i]);
|
|
|
|
// for all of out targets
|
|
|
|
for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
|
|
|
|
l != lg->GetMakefile()->GetTargets().end(); l++)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
2005-07-27 17:49:37 +04:00
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/DependInfo.cmake";
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(tname);
|
|
|
|
cmakefileStream << " \"" << tname.c_str() << "\"\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
}
|
2005-07-27 17:49:37 +04:00
|
|
|
cmakefileStream << " )\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2005-05-06 22:49:38 +04:00
|
|
|
void cmGlobalUnixMakefileGenerator3
|
|
|
|
::WriteAllRules(cmLocalUnixMakefileGenerator3 *lg,
|
|
|
|
std::ostream& makefileStream)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
2005-05-06 22:49:38 +04:00
|
|
|
// Write section header.
|
|
|
|
lg->WriteDivider(makefileStream);
|
|
|
|
makefileStream
|
|
|
|
<< "# Rules to build dependencies and targets.\n"
|
|
|
|
<< "\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
2005-05-05 20:45:53 +04:00
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
// Check the build system in this directory.
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2005-07-29 17:19:25 +04:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2","all"));
|
2005-05-06 22:49:38 +04:00
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
lg->WriteMakeRule(makefileStream, "The main all target", "all", depends, commands);
|
|
|
|
|
2005-05-18 21:46:00 +04:00
|
|
|
// write the clean
|
2005-05-31 19:46:49 +04:00
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
2005-07-29 17:19:25 +04:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2","clean"));
|
2005-05-24 22:42:23 +04:00
|
|
|
lg->WriteMakeRule(makefileStream, "The main clean target", "clean",
|
2005-05-31 19:46:49 +04:00
|
|
|
depends, commands);
|
2005-06-10 18:45:08 +04:00
|
|
|
|
|
|
|
// write the depend rule, really a recompute depends rule
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
2005-07-29 17:19:25 +04:00
|
|
|
std::string cmakefileName = "CMakeFiles/Makefile.cmake";
|
2005-06-10 18:45:08 +04:00
|
|
|
std::string runRule =
|
|
|
|
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
|
|
|
|
runRule += " --check-build-system ";
|
|
|
|
runRule += lg->Convert(cmakefileName.c_str(),cmLocalGenerator::NONE,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
runRule += " 1";
|
|
|
|
|
|
|
|
commands.push_back(runRule);
|
|
|
|
lg->WriteMakeRule(makefileStream, "clear depends",
|
|
|
|
"depend",
|
|
|
|
depends, commands);
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
2005-05-31 18:16:28 +04:00
|
|
|
::WriteDirectoryRules(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg)
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
2005-05-11 20:44:01 +04:00
|
|
|
std::string localName;
|
|
|
|
std::string makeTargetName;
|
2005-05-31 18:16:28 +04:00
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
depends.push_back("cmake_check_build_system");
|
2005-05-13 22:13:00 +04:00
|
|
|
if (lg->GetParent())
|
|
|
|
{
|
|
|
|
std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
|
2005-05-31 18:16:28 +04:00
|
|
|
|
|
|
|
lg->WriteDivider(ruleFileStream);
|
|
|
|
ruleFileStream
|
|
|
|
<< "# Directory level rules for directory "
|
|
|
|
<< dir << "\n\n";
|
|
|
|
|
2005-05-13 22:13:00 +04:00
|
|
|
localName = dir;
|
2005-05-19 23:00:35 +04:00
|
|
|
localName += "/directorystart";
|
|
|
|
makeTargetName = dir;
|
|
|
|
makeTargetName += "/directory";
|
|
|
|
|
|
|
|
std::vector<std::string> all_tgts;
|
|
|
|
|
|
|
|
// for all of out targets
|
2005-06-22 17:06:46 +04:00
|
|
|
for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
|
2005-05-19 23:00:35 +04:00
|
|
|
l != lg->GetMakefile()->GetTargets().end(); l++)
|
|
|
|
{
|
|
|
|
if((l->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::UTILITY))
|
|
|
|
{
|
|
|
|
// Add this to the list of depends rules in this directory.
|
|
|
|
if(l->second.IsInAll())
|
|
|
|
{
|
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/all";
|
|
|
|
all_tgts.push_back(tname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the directory rule add in the subdirs
|
|
|
|
std::vector<cmLocalGenerator *> subdirs = lg->GetChildren();
|
|
|
|
|
|
|
|
// for each subdir add the directory depend
|
|
|
|
std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
|
|
|
|
for (; sdi != subdirs.end(); ++sdi)
|
|
|
|
{
|
2005-05-19 23:55:31 +04:00
|
|
|
cmLocalUnixMakefileGenerator3 * lg2 =
|
2005-05-19 23:00:35 +04:00
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(*sdi);
|
2005-05-19 23:55:31 +04:00
|
|
|
dir = lg2->GetMakefile()->GetStartOutputDirectory();
|
2005-05-19 23:00:35 +04:00
|
|
|
dir += "/directory";
|
2005-05-19 23:55:31 +04:00
|
|
|
dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
cmLocalGenerator::MAKEFILE);
|
2005-05-19 23:00:35 +04:00
|
|
|
all_tgts.push_back(dir);
|
|
|
|
}
|
2005-05-13 22:13:00 +04:00
|
|
|
|
|
|
|
// write the directory rule
|
|
|
|
commands.clear();
|
2005-05-25 23:09:06 +04:00
|
|
|
commands.push_back
|
2005-07-29 17:19:25 +04:00
|
|
|
(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2",
|
|
|
|
makeTargetName.c_str()));
|
2005-05-31 19:46:49 +04:00
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
|
|
|
|
localName.c_str(), depends, commands);
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
|
|
|
|
makeTargetName.c_str(), all_tgts, commands);
|
|
|
|
}
|
|
|
|
|
|
|
|
// now do the clean targets
|
|
|
|
if (lg->GetParent())
|
|
|
|
{
|
|
|
|
std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
|
|
|
|
makeTargetName = dir;
|
|
|
|
makeTargetName += "/clean";
|
|
|
|
|
|
|
|
std::vector<std::string> all_tgts;
|
|
|
|
|
|
|
|
// for all of out targets
|
2005-06-22 17:06:46 +04:00
|
|
|
for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
|
2005-05-31 19:46:49 +04:00
|
|
|
l != lg->GetMakefile()->GetTargets().end(); l++)
|
|
|
|
{
|
|
|
|
if((l->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::UTILITY))
|
|
|
|
{
|
|
|
|
// Add this to the list of depends rules in this directory.
|
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/clean";
|
|
|
|
all_tgts.push_back(tname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the directory rule add in the subdirs
|
|
|
|
std::vector<cmLocalGenerator *> subdirs = lg->GetChildren();
|
|
|
|
|
|
|
|
// for each subdir add the directory depend
|
|
|
|
std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
|
|
|
|
for (; sdi != subdirs.end(); ++sdi)
|
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 * lg2 =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(*sdi);
|
|
|
|
dir = lg2->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir += "/clean";
|
|
|
|
dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
cmLocalGenerator::MAKEFILE);
|
|
|
|
all_tgts.push_back(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the directory clean rule
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.",
|
|
|
|
makeTargetName.c_str(), all_tgts, commands);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::WriteDirectoryRules2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg)
|
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
std::string localName;
|
|
|
|
std::string makeTargetName;
|
|
|
|
|
|
|
|
depends.push_back("cmake_check_build_system");
|
|
|
|
if (lg->GetParent())
|
|
|
|
{
|
|
|
|
std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
|
|
|
|
|
|
|
|
lg->WriteDivider(ruleFileStream);
|
|
|
|
ruleFileStream
|
|
|
|
<< "# Directory level rules for directory "
|
|
|
|
<< dir << "\n\n";
|
|
|
|
|
|
|
|
localName = dir;
|
|
|
|
localName += "/directorystart";
|
|
|
|
makeTargetName = dir;
|
|
|
|
makeTargetName += "/directory";
|
|
|
|
|
|
|
|
std::vector<std::string> all_tgts;
|
|
|
|
|
|
|
|
// for all of out targets
|
2005-06-22 17:06:46 +04:00
|
|
|
for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
|
2005-05-31 19:46:49 +04:00
|
|
|
l != lg->GetMakefile()->GetTargets().end(); l++)
|
|
|
|
{
|
|
|
|
if((l->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::UTILITY))
|
|
|
|
{
|
|
|
|
// Add this to the list of depends rules in this directory.
|
|
|
|
if(l->second.IsInAll())
|
|
|
|
{
|
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/all";
|
|
|
|
all_tgts.push_back(tname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the directory rule add in the subdirs
|
|
|
|
std::vector<cmLocalGenerator *> subdirs = lg->GetChildren();
|
|
|
|
|
|
|
|
// for each subdir add the directory depend
|
|
|
|
std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
|
|
|
|
for (; sdi != subdirs.end(); ++sdi)
|
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 * lg2 =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(*sdi);
|
|
|
|
dir = lg2->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir += "/directory";
|
|
|
|
dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
cmLocalGenerator::MAKEFILE);
|
|
|
|
all_tgts.push_back(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the directory rule
|
|
|
|
commands.clear();
|
|
|
|
commands.push_back
|
2005-07-29 17:19:25 +04:00
|
|
|
(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2",
|
|
|
|
makeTargetName.c_str()));
|
2005-05-13 22:13:00 +04:00
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
|
|
|
|
localName.c_str(), depends, commands);
|
2005-05-19 23:00:35 +04:00
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory.",
|
|
|
|
makeTargetName.c_str(), all_tgts, commands);
|
2005-05-13 22:13:00 +04:00
|
|
|
}
|
2005-05-25 23:09:06 +04:00
|
|
|
|
|
|
|
// now do the clean targets
|
|
|
|
if (lg->GetParent())
|
|
|
|
{
|
|
|
|
std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir = lg->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,cmLocalGenerator::MAKEFILE);
|
|
|
|
makeTargetName = dir;
|
|
|
|
makeTargetName += "/clean";
|
|
|
|
|
|
|
|
std::vector<std::string> all_tgts;
|
|
|
|
|
|
|
|
// for all of out targets
|
2005-06-22 17:06:46 +04:00
|
|
|
for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
|
2005-05-25 23:09:06 +04:00
|
|
|
l != lg->GetMakefile()->GetTargets().end(); l++)
|
|
|
|
{
|
|
|
|
if((l->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::UTILITY))
|
|
|
|
{
|
|
|
|
// Add this to the list of depends rules in this directory.
|
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/clean";
|
|
|
|
all_tgts.push_back(tname);
|
|
|
|
}
|
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2005-05-25 23:09:06 +04:00
|
|
|
// write the directory rule add in the subdirs
|
|
|
|
std::vector<cmLocalGenerator *> subdirs = lg->GetChildren();
|
|
|
|
|
|
|
|
// for each subdir add the directory depend
|
|
|
|
std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
|
|
|
|
for (; sdi != subdirs.end(); ++sdi)
|
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 * lg2 =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(*sdi);
|
|
|
|
dir = lg2->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
dir += "/clean";
|
|
|
|
dir = lg2->Convert(dir.c_str(),cmLocalGenerator::HOME_OUTPUT,
|
|
|
|
cmLocalGenerator::MAKEFILE);
|
|
|
|
all_tgts.push_back(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
// write the directory clean rule
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for directory clean.",
|
|
|
|
makeTargetName.c_str(), all_tgts, commands);
|
|
|
|
}
|
2005-05-31 18:16:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::WriteConvenienceRules(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg,
|
2005-06-01 17:25:10 +04:00
|
|
|
std::set<cmStdString> &emitted)
|
2005-05-31 19:46:49 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
|
|
|
|
// write the directory level rules for this local gen
|
|
|
|
//this->WriteDirectoryRules(ruleFileStream,lg);
|
|
|
|
|
|
|
|
depends.push_back("cmake_check_build_system");
|
|
|
|
|
|
|
|
// for each target Generate the rule files for each target.
|
2005-06-22 17:06:46 +04:00
|
|
|
cmTargets& targets = lg->GetMakefile()->GetTargets();
|
|
|
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
2005-05-31 19:46:49 +04:00
|
|
|
{
|
|
|
|
if((t->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::UTILITY))
|
|
|
|
{
|
|
|
|
// Don't emit the same rule twice (e.g. two targets with the same
|
|
|
|
// simple name)
|
2005-06-09 17:48:44 +04:00
|
|
|
if(t->second.GetName() &&
|
|
|
|
strlen(t->second.GetName()) &&
|
|
|
|
emitted.insert(t->second.GetName()).second)
|
2005-05-31 19:46:49 +04:00
|
|
|
{
|
|
|
|
// Add a rule to build the target by name.
|
|
|
|
lg->WriteDivider(ruleFileStream);
|
|
|
|
ruleFileStream
|
|
|
|
<< "# Target rules for targets named "
|
|
|
|
<< t->second.GetName() << "\n\n";
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
2005-07-29 17:19:25 +04:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2",
|
2005-05-31 19:46:49 +04:00
|
|
|
t->second.GetName()));
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back("cmake_check_build_system");
|
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Build rule for target.",
|
|
|
|
t->second.GetName(), depends, commands);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::WriteConvenienceRules2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg,
|
|
|
|
bool exclude)
|
2005-05-31 18:16:28 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
std::string localName;
|
|
|
|
std::string makeTargetName;
|
|
|
|
|
|
|
|
// write the directory level rules for this local gen
|
2005-05-31 19:46:49 +04:00
|
|
|
this->WriteDirectoryRules2(ruleFileStream,lg);
|
2005-05-31 18:16:28 +04:00
|
|
|
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2005-05-25 23:09:06 +04:00
|
|
|
|
2005-05-11 20:44:01 +04:00
|
|
|
// for each target Generate the rule files for each target.
|
2005-06-22 17:06:46 +04:00
|
|
|
cmTargets& targets = lg->GetMakefile()->GetTargets();
|
|
|
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
2005-06-09 17:48:44 +04:00
|
|
|
if (((t->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::UTILITY)) &&
|
|
|
|
t->second.GetName() &&
|
|
|
|
strlen(t->second.GetName()))
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
2005-07-27 17:49:37 +04:00
|
|
|
bool needRequiresStep =
|
|
|
|
this->NeedRequiresStep(lg,t->second.GetName());
|
2005-05-06 22:49:38 +04:00
|
|
|
// Add a rule to build the target by name.
|
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
2005-05-19 18:52:59 +04:00
|
|
|
std::string makefileName = localName;
|
|
|
|
makefileName += "/build.make";
|
2005-05-18 21:46:00 +04:00
|
|
|
|
2005-05-31 18:16:28 +04:00
|
|
|
lg->WriteDivider(ruleFileStream);
|
|
|
|
ruleFileStream
|
|
|
|
<< "# Target rules for target "
|
|
|
|
<< localName << "\n\n";
|
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
commands.clear();
|
2005-05-18 21:46:00 +04:00
|
|
|
if (t->second.GetType() != cmTarget::UTILITY)
|
|
|
|
{
|
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/depend";
|
2005-05-19 18:52:59 +04:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(),
|
|
|
|
makeTargetName.c_str()));
|
2005-05-24 19:17:30 +04:00
|
|
|
|
|
|
|
// add requires if we need it for this generator
|
|
|
|
if (needRequiresStep)
|
|
|
|
{
|
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/requires";
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(),
|
|
|
|
makeTargetName.c_str()));
|
|
|
|
}
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/build";
|
2005-05-19 18:52:59 +04:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(),
|
|
|
|
makeTargetName.c_str()));
|
2005-05-06 22:49:38 +04:00
|
|
|
|
|
|
|
// Write the rule.
|
2005-05-18 21:46:00 +04:00
|
|
|
localName += "/all";
|
|
|
|
depends.clear();
|
|
|
|
this->AppendGlobalTargetDepends(depends,t->second);
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
|
2005-05-06 22:49:38 +04:00
|
|
|
localName.c_str(), depends, commands);
|
2005-05-18 21:46:00 +04:00
|
|
|
|
|
|
|
// add the all/all dependency
|
|
|
|
if (!exclude && t->second.IsInAll())
|
|
|
|
{
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
|
2005-05-31 19:46:49 +04:00
|
|
|
"all", depends, commands);
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
2005-05-31 19:46:49 +04:00
|
|
|
|
2005-05-18 21:46:00 +04:00
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
2005-07-29 17:19:25 +04:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall("CMakeFiles/Makefile2",
|
2005-05-31 19:46:49 +04:00
|
|
|
localName.c_str()));
|
2005-05-18 21:46:00 +04:00
|
|
|
depends.clear();
|
|
|
|
depends.push_back("cmake_check_build_system");
|
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
2005-06-22 00:29:47 +04:00
|
|
|
localName += "/rule";
|
2005-05-31 19:46:49 +04:00
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Build rule for subdir invocation for target.",
|
2005-05-18 21:46:00 +04:00
|
|
|
localName.c_str(), depends, commands);
|
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
// Add a target with the canonical name (no prefix, suffix or path).
|
2005-05-18 21:46:00 +04:00
|
|
|
commands.clear();
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
|
|
|
|
t->second.GetName(), depends, commands);
|
2005-05-31 19:46:49 +04:00
|
|
|
|
2005-05-24 22:42:23 +04:00
|
|
|
// add the clean rule
|
2005-06-22 00:29:47 +04:00
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
2005-05-24 22:42:23 +04:00
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/clean";
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(),
|
|
|
|
makeTargetName.c_str()));
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
|
|
|
|
makeTargetName.c_str(), depends, commands);
|
|
|
|
commands.clear();
|
|
|
|
depends.push_back(makeTargetName);
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
|
|
|
|
"clean", depends, commands);
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::AppendGlobalTargetDepends(std::vector<std::string>& depends,
|
2005-06-22 17:06:46 +04:00
|
|
|
cmTarget& target)
|
2005-05-18 21:46:00 +04:00
|
|
|
{
|
|
|
|
// Keep track of dependencies already listed.
|
|
|
|
std::set<cmStdString> emitted;
|
|
|
|
|
|
|
|
// A target should not depend on itself.
|
|
|
|
emitted.insert(target.GetName());
|
|
|
|
|
|
|
|
// Loop over all library dependencies but not for static libs
|
|
|
|
if (target.GetType() != cmTarget::STATIC_LIBRARY)
|
|
|
|
{
|
|
|
|
const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries();
|
|
|
|
for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin();
|
|
|
|
lib != tlibs.end(); ++lib)
|
|
|
|
{
|
|
|
|
// Don't emit the same library twice for this target.
|
|
|
|
if(emitted.insert(lib->first).second)
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
2005-05-18 21:46:00 +04:00
|
|
|
// Add this dependency.
|
2005-07-15 19:38:19 +04:00
|
|
|
this->AppendAnyGlobalDepend(depends, lib->first.c_str(), emitted);
|
2005-05-06 22:49:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-18 21:46:00 +04:00
|
|
|
|
|
|
|
// Loop over all utility dependencies.
|
|
|
|
const std::set<cmStdString>& tutils = target.GetUtilities();
|
|
|
|
for(std::set<cmStdString>::const_iterator util = tutils.begin();
|
|
|
|
util != tutils.end(); ++util)
|
|
|
|
{
|
|
|
|
// Don't emit the same utility twice for this target.
|
|
|
|
if(emitted.insert(*util).second)
|
|
|
|
{
|
|
|
|
// Add this dependency.
|
2005-07-15 19:38:19 +04:00
|
|
|
this->AppendAnyGlobalDepend(depends, util->c_str(), emitted);
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-18 21:46:00 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
2005-07-15 19:38:19 +04:00
|
|
|
::AppendAnyGlobalDepend(std::vector<std::string>& depends, const char* name,
|
|
|
|
std::set<cmStdString>& emitted)
|
2005-05-18 21:46:00 +04:00
|
|
|
{
|
2005-05-20 16:45:33 +04:00
|
|
|
cmTarget *result;
|
2005-05-18 21:46:00 +04:00
|
|
|
|
|
|
|
// search each local generator until a match is found
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
// search all targets
|
|
|
|
result = m_LocalGenerators[i]->GetMakefile()->FindTarget(name);
|
|
|
|
// if a match was found then ...
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg3 =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
|
|
|
std::string tgtName = lg3->GetRelativeTargetDirectory(*result);
|
|
|
|
tgtName += "/all";
|
|
|
|
depends.push_back(tgtName);
|
2005-07-15 19:38:19 +04:00
|
|
|
if(result->GetType() == cmTarget::STATIC_LIBRARY)
|
|
|
|
{
|
|
|
|
const cmTarget::LinkLibraries& tlibs = result->GetLinkLibraries();
|
|
|
|
for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin();
|
|
|
|
lib != tlibs.end(); ++lib)
|
|
|
|
{
|
|
|
|
// Don't emit the same library twice for this target.
|
|
|
|
if(emitted.insert(lib->first).second)
|
|
|
|
{
|
|
|
|
// Add this dependency.
|
|
|
|
this->AppendAnyGlobalDepend(depends, lib->first.c_str(),
|
|
|
|
emitted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-18 21:46:00 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-05-20 19:01:21 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3::WriteHelpRule(std::ostream& ruleFileStream)
|
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
|
|
|
|
|
|
// add the help target
|
|
|
|
std::string path;
|
|
|
|
std::vector<std::string> no_depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
lg->AppendEcho(commands,
|
|
|
|
"The following are some of the valid targets for this Makefile:");
|
|
|
|
lg->AppendEcho(commands,"... all (the default if no target is provided)");
|
|
|
|
lg->AppendEcho(commands,"... clean");
|
|
|
|
lg->AppendEcho(commands,"... depend");
|
|
|
|
lg->AppendEcho(commands,"... install");
|
|
|
|
lg->AppendEcho(commands,"... rebuild_cache");
|
|
|
|
|
2005-06-01 17:25:10 +04:00
|
|
|
// Keep track of targets already listed.
|
|
|
|
std::set<cmStdString> emittedTargets;
|
|
|
|
|
2005-05-20 19:01:21 +04:00
|
|
|
// for each local generator
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
|
|
{
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
|
|
|
|
|
|
|
// for each target Generate the rule files for each target.
|
2005-06-22 17:06:46 +04:00
|
|
|
cmTargets& targets = lg->GetMakefile()->GetTargets();
|
|
|
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
2005-05-20 19:01:21 +04:00
|
|
|
{
|
|
|
|
if((t->second.GetType() == cmTarget::EXECUTABLE) ||
|
2005-06-01 17:25:10 +04:00
|
|
|
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(t->second.GetType() == cmTarget::UTILITY))
|
2005-05-20 19:01:21 +04:00
|
|
|
{
|
2005-06-01 17:25:10 +04:00
|
|
|
if(emittedTargets.insert(t->second.GetName()).second)
|
|
|
|
{
|
|
|
|
path = "... ";
|
|
|
|
path += t->second.GetName();
|
|
|
|
lg->AppendEcho(commands,path.c_str());
|
|
|
|
}
|
2005-05-20 19:01:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Help Target",
|
|
|
|
"help:",
|
|
|
|
no_depends, commands);
|
|
|
|
ruleFileStream << "\n\n";
|
|
|
|
}
|
|
|
|
|
2005-05-24 19:17:30 +04:00
|
|
|
|
|
|
|
bool cmGlobalUnixMakefileGenerator3
|
2005-07-27 17:49:37 +04:00
|
|
|
::NeedRequiresStep(cmLocalUnixMakefileGenerator3 *lg,const char *name)
|
2005-05-24 19:17:30 +04:00
|
|
|
{
|
|
|
|
std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
|
2005-07-27 17:49:37 +04:00
|
|
|
checkSet = lg->GetIntegrityCheckSet()[name];
|
2005-05-24 19:17:30 +04:00
|
|
|
for(std::map<cmStdString,
|
|
|
|
cmLocalUnixMakefileGenerator3::IntegrityCheckSet>::const_iterator
|
|
|
|
l = checkSet.begin(); l != checkSet.end(); ++l)
|
|
|
|
{
|
2005-07-27 19:31:17 +04:00
|
|
|
std::string name2 = "CMAKE_NEEDS_REQUIRES_STEP_";
|
|
|
|
name2 += l->first;
|
|
|
|
name2 += "_FLAG";
|
|
|
|
if(lg->GetMakefile()->GetDefinition(name2.c_str()))
|
2005-05-24 19:17:30 +04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|