2005-05-05 16:45:53 +00: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"
|
2006-05-23 13:11:46 +00:00
|
|
|
#include "cmSourceFile.h"
|
|
|
|
#include "cmTarget.h"
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3()
|
|
|
|
{
|
|
|
|
// This type of makefile always requires unix style paths
|
2006-03-15 16:02:08 +00:00
|
|
|
this->ForceUnixPaths = true;
|
|
|
|
this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
2006-04-27 01:31:39 +00:00
|
|
|
this->ToolSupportsColor = true;
|
2007-06-05 20:35:24 +00:00
|
|
|
this->ForceVerboseMakefiles = false;
|
|
|
|
|
2006-06-19 00:05:56 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
this->UseLinkScript = false;
|
|
|
|
#else
|
2006-06-15 20:17:11 +00:00
|
|
|
this->UseLinkScript = true;
|
2006-06-19 00:05:56 +00:00
|
|
|
#endif
|
2005-05-05 16:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalUnixMakefileGenerator3
|
2007-06-28 13:09:26 +00:00
|
|
|
::EnableLanguage(std::vector<std::string>const& languages,
|
|
|
|
cmMakefile *mf,
|
|
|
|
bool optional)
|
2005-05-05 16:45:53 +00:00
|
|
|
{
|
2007-06-28 13:09:26 +00:00
|
|
|
this->cmGlobalGenerator::EnableLanguage(languages, mf, optional);
|
2005-05-05 16:45:53 +00:00
|
|
|
std::string path;
|
|
|
|
for(std::vector<std::string>::const_iterator l = languages.begin();
|
|
|
|
l != languages.end(); ++l)
|
|
|
|
{
|
2005-09-01 21:14:56 +00:00
|
|
|
if(*l == "NONE")
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2005-05-05 16:45:53 +00:00
|
|
|
const char* lang = l->c_str();
|
|
|
|
std::string langComp = "CMAKE_";
|
|
|
|
langComp += lang;
|
|
|
|
langComp += "_COMPILER";
|
|
|
|
|
|
|
|
if(!mf->GetDefinition(langComp.c_str()))
|
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
cmSystemTools::Error(langComp.c_str(),
|
|
|
|
" not set, after EnableLanguage");
|
2005-05-05 16:45:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-12-13 20:54:29 +00:00
|
|
|
const char* name = mf->GetRequiredDefinition(langComp.c_str());
|
2005-12-22 21:42:36 +00:00
|
|
|
if(!cmSystemTools::FileIsFullPath(name))
|
|
|
|
{
|
|
|
|
path = cmSystemTools::FindProgram(name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = name;
|
|
|
|
}
|
2007-06-28 13:09:26 +00:00
|
|
|
if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str()))
|
|
|
|
&& (optional==false))
|
2005-05-05 16:45:53 +00:00
|
|
|
{
|
|
|
|
std::string message = "your ";
|
|
|
|
message += lang;
|
2005-12-22 21:42:36 +00:00
|
|
|
message += " compiler: \"";
|
|
|
|
message += name;
|
|
|
|
message += "\" was not found. Please set ";
|
|
|
|
message += langComp;
|
|
|
|
message += " to a valid compiler path or name.";
|
|
|
|
cmSystemTools::Error(message.c_str());
|
|
|
|
path = name;
|
2005-05-05 16:45:53 +00:00
|
|
|
}
|
2005-12-22 21:42:36 +00:00
|
|
|
std::string doc = lang;
|
|
|
|
doc += " compiler.";
|
2007-12-13 20:54:29 +00:00
|
|
|
const char* cname = this->GetCMakeInstance()->
|
|
|
|
GetCacheManager()->GetCacheValue(langComp.c_str());
|
|
|
|
std::string changeVars;
|
|
|
|
if(cname && (path != cname))
|
|
|
|
{
|
|
|
|
const char* cvars =
|
|
|
|
this->GetCMakeInstance()->GetProperty(
|
|
|
|
"__CMAKE_DELETE_CACHE_CHANGE_VARS_");
|
|
|
|
if(cvars)
|
|
|
|
{
|
|
|
|
changeVars += cvars;
|
|
|
|
changeVars += ";";
|
|
|
|
}
|
|
|
|
changeVars += langComp;
|
|
|
|
changeVars += ";";
|
|
|
|
changeVars += cname;
|
|
|
|
this->GetCMakeInstance()->SetProperty(
|
|
|
|
"__CMAKE_DELETE_CACHE_CHANGE_VARS_",
|
|
|
|
changeVars.c_str());
|
|
|
|
}
|
2005-12-22 21:42:36 +00:00
|
|
|
mf->AddCacheDefinition(langComp.c_str(), path.c_str(),
|
|
|
|
doc.c_str(), cmCacheManager::FILEPATH);
|
2005-05-05 16:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///! Create a local generator appropriate to this Global Generator
|
|
|
|
cmLocalGenerator *cmGlobalUnixMakefileGenerator3::CreateLocalGenerator()
|
|
|
|
{
|
|
|
|
cmLocalGenerator* lg = new cmLocalUnixMakefileGenerator3;
|
|
|
|
lg->SetGlobalGenerator(this);
|
|
|
|
return lg;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-05-11 14:40:28 +00:00
|
|
|
void cmGlobalUnixMakefileGenerator3
|
|
|
|
::GetDocumentation(cmDocumentationEntry& entry) const
|
2005-05-05 16:45:53 +00:00
|
|
|
{
|
2007-10-22 16:49:09 +00:00
|
|
|
entry.Name = this->GetName();
|
|
|
|
entry.Brief = "Generates standard UNIX makefiles.";
|
|
|
|
entry.Full =
|
2005-05-05 16:45:53 +00:00
|
|
|
"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 18:49:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmGlobalUnixMakefileGenerator3::Generate()
|
|
|
|
{
|
2006-07-11 13:55:27 +00:00
|
|
|
// first do superclass method
|
|
|
|
this->cmGlobalGenerator::Generate();
|
|
|
|
|
2006-05-25 14:55:24 +00:00
|
|
|
// initialize progress
|
2006-05-23 13:11:46 +00:00
|
|
|
unsigned int i;
|
2006-07-11 13:55:27 +00:00
|
|
|
unsigned long total = 0;
|
2006-05-23 13:11:46 +00:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
|
|
|
{
|
2006-07-11 13:55:27 +00:00
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
|
|
|
total += lg->GetNumberOfProgressActions();
|
2006-05-23 13:11:46 +00:00
|
|
|
}
|
2005-05-06 18:49:38 +00:00
|
|
|
|
2006-07-12 17:11:27 +00:00
|
|
|
// write each target's progress.make this loop is done twice. Bascially the
|
|
|
|
// Generate pass counts all the actions, the first loop below determines
|
|
|
|
// how many actions have progress updates for each target and writes to
|
|
|
|
// corrrect variable values for everything except the all targets. The
|
|
|
|
// second loop actually writes out correct values for the all targets as
|
|
|
|
// well. This is because the all targets require more information that is
|
|
|
|
// computed in the first loop.
|
2006-07-11 13:55:27 +00:00
|
|
|
unsigned long current = 0;
|
2006-07-12 17:11:27 +00:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
2006-07-11 13:55:27 +00:00
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
|
|
|
lg->WriteProgressVariables(total,current);
|
|
|
|
}
|
2006-07-12 17:11:27 +00:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
2006-07-11 13:55:27 +00:00
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
2006-07-12 17:11:27 +00:00
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
|
|
|
lg->WriteAllProgressVariable();
|
2006-07-11 13:55:27 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 18:49:38 +00:00
|
|
|
// write the main makefile
|
2005-05-31 15:46:49 +00:00
|
|
|
this->WriteMainMakefile2();
|
2005-05-06 18:49:38 +00:00
|
|
|
this->WriteMainCMakefile();
|
|
|
|
}
|
|
|
|
|
2005-05-31 15:46:49 +00: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();
|
2006-06-14 16:28:32 +00:00
|
|
|
makefileName += cmake::GetCMakeFilesDirectory();
|
|
|
|
makefileName += "/Makefile2";
|
2005-05-31 15:46:49 +00:00
|
|
|
cmGeneratedFileStream makefileStream(makefileName.c_str());
|
|
|
|
if(!makefileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get a local generator for some useful methods
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
2006-03-15 16:02:08 +00:00
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
|
2005-05-31 15:46:49 +00:00
|
|
|
|
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(makefileStream);
|
2006-02-15 15:34:11 +00:00
|
|
|
|
2005-05-31 15:46:49 +00:00
|
|
|
// 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,
|
2006-02-15 21:35:16 +00:00
|
|
|
no_commands, true);
|
2005-05-31 15:46:49 +00:00
|
|
|
|
2006-01-17 15:21:45 +00:00
|
|
|
depends.clear();
|
2006-02-15 21:35:16 +00:00
|
|
|
|
2006-02-16 23:50:16 +00:00
|
|
|
// The all and preinstall rules might never have any dependencies
|
|
|
|
// added to them.
|
2006-03-15 16:02:08 +00:00
|
|
|
if(this->EmptyRuleHackDepends != "")
|
2006-02-16 23:50:16 +00:00
|
|
|
{
|
2006-03-15 16:02:08 +00:00
|
|
|
depends.push_back(this->EmptyRuleHackDepends);
|
2006-02-16 23:50:16 +00:00
|
|
|
}
|
|
|
|
|
2005-05-31 15:46:49 +00:00
|
|
|
// Write and empty all:
|
|
|
|
lg->WriteMakeRule(makefileStream,
|
|
|
|
"The main recursive all target", "all",
|
2006-02-15 21:35:16 +00:00
|
|
|
depends, no_commands, true);
|
2005-05-31 15:46:49 +00:00
|
|
|
|
2006-02-16 20:19:00 +00:00
|
|
|
// Write an empty preinstall:
|
|
|
|
lg->WriteMakeRule(makefileStream,
|
|
|
|
"The main recursive preinstall target", "preinstall",
|
|
|
|
depends, no_commands, true);
|
|
|
|
|
2006-02-15 21:35:16 +00:00
|
|
|
// Write out the "special" stuff
|
|
|
|
lg->WriteSpecialTargetsTop(makefileStream);
|
2005-05-31 15:46:49 +00:00
|
|
|
|
|
|
|
// write the target convenience rules
|
|
|
|
unsigned int i;
|
2006-03-15 16:02:08 +00:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
2007-08-03 19:44:25 +00:00
|
|
|
this->WriteConvenienceRules2(makefileStream,lg);
|
2005-05-31 15:46:49 +00:00
|
|
|
}
|
|
|
|
|
2006-03-15 16:02:08 +00:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
|
2005-05-31 15:46:49 +00:00
|
|
|
lg->WriteSpecialTargetsBottom(makefileStream);
|
|
|
|
}
|
|
|
|
|
2005-05-06 18:49:38 +00:00
|
|
|
|
2005-05-05 16:45:53 +00: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 18:49:38 +00:00
|
|
|
std::string cmakefileName =
|
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2006-06-14 16:28:32 +00:00
|
|
|
cmakefileName += cmake::GetCMakeFilesDirectory();
|
|
|
|
cmakefileName += "/Makefile.cmake";
|
2005-05-05 16:45:53 +00:00
|
|
|
cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
|
|
|
|
if(!cmakefileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2005-05-06 18:49:38 +00:00
|
|
|
|
|
|
|
std::string makefileName =
|
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
|
|
makefileName += "/Makefile";
|
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
// get a local generator for some useful methods
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
2006-03-15 16:02:08 +00:00
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(cmakefileStream);
|
|
|
|
|
2005-05-12 14:49:56 +00:00
|
|
|
// Save the generator name
|
|
|
|
cmakefileStream
|
|
|
|
<< "# The generator used is:\n"
|
|
|
|
<< "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n";
|
|
|
|
|
2005-05-05 16:45:53 +00:00
|
|
|
// for each cmMakefile get its list of dependencies
|
|
|
|
std::vector<std::string> lfiles;
|
2006-03-15 16:02:08 +00:00
|
|
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
2005-05-05 16:45:53 +00:00
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
// 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
|
2006-03-15 16:02:08 +00:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
// 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"
|
2006-05-11 14:40:28 +00:00
|
|
|
<< " \""
|
|
|
|
<< lg->Convert(cache.c_str(),
|
|
|
|
cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
|
2005-05-05 16:45:53 +00:00
|
|
|
for(std::vector<std::string>::const_iterator i = lfiles.begin();
|
|
|
|
i != lfiles.end(); ++i)
|
|
|
|
{
|
|
|
|
cmakefileStream
|
2006-05-11 14:40:28 +00:00
|
|
|
<< " \""
|
|
|
|
<< lg->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT).c_str()
|
2005-05-05 16:45:53 +00:00
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
cmakefileStream
|
|
|
|
<< " )\n\n";
|
|
|
|
|
|
|
|
// Build the path to the cache check file.
|
|
|
|
std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2006-06-14 16:28:32 +00:00
|
|
|
check += cmake::GetCMakeFilesDirectory();
|
|
|
|
check += "/cmake.check_cache";
|
2005-05-05 16:45:53 +00:00
|
|
|
|
|
|
|
// Set the corresponding makefile in the cmake file.
|
|
|
|
cmakefileStream
|
|
|
|
<< "# The corresponding makefile is:\n"
|
|
|
|
<< "SET(CMAKE_MAKEFILE_OUTPUTS\n"
|
2006-05-11 14:40:28 +00: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 16:45:53 +00:00
|
|
|
|
|
|
|
// add in all the directory information files
|
|
|
|
std::string tmpStr;
|
2006-03-15 16:02:08 +00:00
|
|
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
2005-05-05 16:45:53 +00:00
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
2005-05-05 16:45:53 +00:00
|
|
|
tmpStr = lg->GetMakefile()->GetStartOutputDirectory();
|
2006-06-14 16:28:32 +00:00
|
|
|
tmpStr += cmake::GetCMakeFilesDirectory();
|
|
|
|
tmpStr += "/CMakeDirectoryInformation.cmake";
|
2005-05-13 13:54:30 +00:00
|
|
|
cmakefileStream << " \"" <<
|
2006-05-11 14:40:28 +00:00
|
|
|
lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
|
|
|
|
<< "\"\n";
|
|
|
|
const std::vector<std::string>& outfiles =
|
|
|
|
lg->GetMakefile()->GetOutputFiles();
|
2006-04-10 17:53:00 +00:00
|
|
|
for(std::vector<std::string>::const_iterator k= outfiles.begin();
|
|
|
|
k != outfiles.end(); ++k)
|
|
|
|
{
|
|
|
|
cmakefileStream << " \"" <<
|
2006-05-11 14:40:28 +00:00
|
|
|
lg->Convert(k->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
|
|
|
|
<< "\"\n";
|
2006-04-10 17:53:00 +00:00
|
|
|
}
|
2005-05-05 16:45:53 +00:00
|
|
|
}
|
|
|
|
cmakefileStream << " )\n\n";
|
2005-05-06 18:49:38 +00:00
|
|
|
|
2006-05-11 14:40:28 +00:00
|
|
|
this->WriteMainCMakefileLanguageRules(cmakefileStream,
|
|
|
|
this->LocalGenerators);
|
2006-04-11 15:06:19 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 18:49:38 +00:00
|
|
|
void cmGlobalUnixMakefileGenerator3
|
2005-07-27 13:49:37 +00:00
|
|
|
::WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
|
2006-05-11 14:40:28 +00:00
|
|
|
std::vector<cmLocalGenerator *> &lGenerators
|
|
|
|
)
|
2005-05-06 18:49:38 +00:00
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg;
|
|
|
|
|
2005-07-27 13:49:37 +00:00
|
|
|
// now list all the target info files
|
2005-05-05 16:45:53 +00:00
|
|
|
cmakefileStream
|
2007-12-21 18:10:33 +00:00
|
|
|
<< "# Dependency information for all targets:\n";
|
2005-05-05 16:45:53 +00:00
|
|
|
cmakefileStream
|
2005-07-27 13:49:37 +00:00
|
|
|
<< "SET(CMAKE_DEPEND_INFO_FILES\n";
|
|
|
|
for (unsigned int i = 0; i < lGenerators.size(); ++i)
|
2005-05-05 16:45:53 +00:00
|
|
|
{
|
2005-07-27 13:49:37 +00: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 16:45:53 +00:00
|
|
|
{
|
2005-08-02 15:06:16 +00:00
|
|
|
if((l->second.GetType() == cmTarget::EXECUTABLE) ||
|
|
|
|
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
2007-12-21 18:10:33 +00:00
|
|
|
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
|
|
|
(l->second.GetType() == cmTarget::UTILITY))
|
2005-08-02 15:06:16 +00:00
|
|
|
{
|
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/DependInfo.cmake";
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(tname);
|
|
|
|
cmakefileStream << " \"" << tname.c_str() << "\"\n";
|
|
|
|
}
|
2005-05-05 16:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-27 13:49:37 +00:00
|
|
|
cmakefileStream << " )\n";
|
2005-05-05 16:45:53 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 18:49:38 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
2006-03-01 23:54:17 +00:00
|
|
|
::WriteDirectoryRule2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3* lg,
|
|
|
|
const char* pass, bool check_all,
|
|
|
|
bool check_relink)
|
2005-05-06 18:49:38 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
// Get the relative path to the subdirectory from the top.
|
|
|
|
std::string makeTarget = lg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
makeTarget += "/";
|
|
|
|
makeTarget += pass;
|
|
|
|
|
|
|
|
// The directory-level rule should depend on the target-level rules
|
|
|
|
// for all targets in the directory.
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
for(cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
|
|
|
|
l != lg->GetMakefile()->GetTargets().end(); ++l)
|
2005-05-13 18:13:00 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
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))
|
2005-05-19 19:00:35 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
// Add this to the list of depends rules in this directory.
|
2007-03-12 14:26:59 +00:00
|
|
|
if((!check_all || !l->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
|
2006-03-01 23:54:17 +00:00
|
|
|
(!check_relink || l->second.NeedRelinkBeforeInstall()))
|
2005-05-19 19:00:35 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
|
|
|
tname += "/";
|
|
|
|
tname += pass;
|
|
|
|
depends.push_back(tname);
|
2005-05-19 19:00:35 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-31 15:46:49 +00:00
|
|
|
}
|
|
|
|
|
2006-03-01 23:54:17 +00:00
|
|
|
// The directory-level rule should depend on the directory-level
|
|
|
|
// rules of the subdirectories.
|
2006-05-11 14:40:28 +00:00
|
|
|
for(std::vector<cmLocalGenerator*>::iterator sdi =
|
|
|
|
lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi)
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
cmLocalUnixMakefileGenerator3* slg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(*sdi);
|
|
|
|
std::string subdir = slg->GetMakefile()->GetStartOutputDirectory();
|
|
|
|
subdir += "/";
|
|
|
|
subdir += pass;
|
|
|
|
depends.push_back(subdir);
|
2005-05-31 15:46:49 +00:00
|
|
|
}
|
2006-03-01 23:54:17 +00:00
|
|
|
|
|
|
|
// Work-around for makes that drop rules that have no dependencies
|
|
|
|
// or commands.
|
2006-03-15 16:02:08 +00:00
|
|
|
if(depends.empty() && this->EmptyRuleHackDepends != "")
|
2006-03-01 23:54:17 +00:00
|
|
|
{
|
2006-03-15 16:02:08 +00:00
|
|
|
depends.push_back(this->EmptyRuleHackDepends);
|
2006-03-01 23:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
std::string doc = "Convenience name for \"";
|
|
|
|
doc += pass;
|
|
|
|
doc += "\" pass in the directory.";
|
|
|
|
std::vector<std::string> no_commands;
|
|
|
|
lg->WriteMakeRule(ruleFileStream, doc.c_str(),
|
|
|
|
makeTarget.c_str(), depends, no_commands, true);
|
2005-05-31 15:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
2006-03-01 23:54:17 +00:00
|
|
|
::WriteDirectoryRules2(std::ostream& ruleFileStream,
|
|
|
|
cmLocalUnixMakefileGenerator3* lg)
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
// Only subdirectories need these rules.
|
|
|
|
if(!lg->GetParent())
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2006-03-01 23:54:17 +00:00
|
|
|
return;
|
2005-05-13 18:13:00 +00:00
|
|
|
}
|
2005-05-25 19:09:06 +00:00
|
|
|
|
2006-03-01 23:54:17 +00:00
|
|
|
// Begin the directory-level rules section.
|
|
|
|
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";
|
|
|
|
|
|
|
|
// Write directory-level rules for "all".
|
|
|
|
this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false);
|
|
|
|
|
|
|
|
// Write directory-level rules for "clean".
|
|
|
|
this->WriteDirectoryRule2(ruleFileStream, lg, "clean", false, false);
|
|
|
|
|
|
|
|
// Write directory-level rules for "preinstall".
|
2007-08-03 20:31:08 +00:00
|
|
|
this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
|
2005-05-31 14:16:28 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 13:56:42 +00:00
|
|
|
|
2006-05-11 14:40:28 +00:00
|
|
|
std::string cmGlobalUnixMakefileGenerator3
|
|
|
|
::GenerateBuildCommand(const char* makeProgram, const char *projectName,
|
|
|
|
const char* additionalOptions, const char *targetName,
|
2006-06-01 19:51:24 +00:00
|
|
|
const char* config, bool ignoreErrors, bool fast)
|
2006-05-02 13:56:42 +00:00
|
|
|
{
|
|
|
|
// Project name and config are not used yet.
|
|
|
|
(void)projectName;
|
|
|
|
(void)config;
|
|
|
|
|
2006-05-11 14:40:28 +00:00
|
|
|
std::string makeCommand =
|
|
|
|
cmSystemTools::ConvertToUnixOutputPath(makeProgram);
|
|
|
|
|
2006-05-02 13:56:42 +00:00
|
|
|
// Since we have full control over the invocation of nmake, let us
|
|
|
|
// make it quiet.
|
|
|
|
if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
|
|
|
|
{
|
|
|
|
makeCommand += " /NOLOGO ";
|
|
|
|
}
|
|
|
|
if ( ignoreErrors )
|
|
|
|
{
|
|
|
|
makeCommand += " -i";
|
|
|
|
}
|
|
|
|
if ( additionalOptions )
|
|
|
|
{
|
|
|
|
makeCommand += " ";
|
|
|
|
makeCommand += additionalOptions;
|
|
|
|
}
|
|
|
|
if ( targetName && strlen(targetName))
|
|
|
|
{
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg;
|
|
|
|
if (this->LocalGenerators.size())
|
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
|
|
|
|
(this->LocalGenerators[0]);
|
2006-05-02 13:56:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
|
|
|
|
(this->CreateLocalGenerator());
|
2006-05-02 13:56:42 +00:00
|
|
|
// set the Start directories
|
|
|
|
lg->GetMakefile()->SetStartDirectory
|
|
|
|
(this->CMakeInstance->GetStartDirectory());
|
|
|
|
lg->GetMakefile()->SetStartOutputDirectory
|
|
|
|
(this->CMakeInstance->GetStartOutputDirectory());
|
|
|
|
lg->GetMakefile()->MakeStartDirectoriesCurrent();
|
|
|
|
}
|
|
|
|
|
2006-05-02 14:48:14 +00:00
|
|
|
makeCommand += " \"";
|
2006-05-02 13:56:42 +00:00
|
|
|
std::string tname = targetName;
|
2006-06-01 19:51:24 +00:00
|
|
|
if(fast)
|
|
|
|
{
|
|
|
|
tname += "/fast";
|
|
|
|
}
|
2006-05-02 13:56:42 +00:00
|
|
|
tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT,
|
2006-05-03 19:17:55 +00:00
|
|
|
cmLocalGenerator::MAKEFILE);
|
2006-05-02 13:56:42 +00:00
|
|
|
makeCommand += tname.c_str();
|
|
|
|
makeCommand += "\"";
|
|
|
|
if (!this->LocalGenerators.size())
|
|
|
|
{
|
|
|
|
delete lg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return makeCommand;
|
|
|
|
}
|
|
|
|
|
2005-05-31 14:16:28 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::WriteConvenienceRules(std::ostream& ruleFileStream,
|
2005-06-01 13:25:10 +00:00
|
|
|
std::set<cmStdString> &emitted)
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2005-10-20 17:40:28 +00:00
|
|
|
|
|
|
|
// write the target convenience rules
|
|
|
|
unsigned int i;
|
|
|
|
cmLocalUnixMakefileGenerator3 *lg;
|
2006-03-15 16:02:08 +00:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
|
|
|
|
(this->LocalGenerators[i]);
|
2005-10-20 17:40:28 +00:00
|
|
|
// for each target Generate the rule files for each target.
|
|
|
|
cmTargets& targets = lg->GetMakefile()->GetTargets();
|
|
|
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2006-06-01 18:09:21 +00:00
|
|
|
// Don't emit the same rule twice (e.g. two targets with the same
|
|
|
|
// simple name)
|
|
|
|
if(t->second.GetName() &&
|
|
|
|
strlen(t->second.GetName()) &&
|
2007-05-22 14:24:59 +00:00
|
|
|
emitted.insert(t->second.GetName()).second &&
|
|
|
|
// Handle user targets here. Global targets are handled in
|
|
|
|
// the local generator on a per-directory basis.
|
|
|
|
((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)))
|
2005-05-31 15:46:49 +00:00
|
|
|
{
|
2007-05-22 14:24:59 +00: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();
|
|
|
|
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
|
tmp += "Makefile2";
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
|
|
|
(tmp.c_str(),t->second.GetName()));
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back("cmake_check_build_system");
|
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Build rule for target.",
|
|
|
|
t->second.GetName(), depends, commands,
|
|
|
|
true);
|
|
|
|
|
|
|
|
// Add a fast rule to build the target
|
|
|
|
std::string localName = lg->GetRelativeTargetDirectory(t->second);
|
|
|
|
std::string makefileName;
|
|
|
|
makefileName = localName;
|
|
|
|
makefileName += "/build.make";
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
|
|
|
std::string makeTargetName = localName;
|
|
|
|
makeTargetName += "/build";
|
|
|
|
localName = t->second.GetName();
|
|
|
|
localName += "/fast";
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
|
|
|
(makefileName.c_str(), makeTargetName.c_str()));
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
|
|
|
|
localName.c_str(), depends, commands, true);
|
2007-08-03 20:31:08 +00:00
|
|
|
|
|
|
|
// Add a local name for the rule to relink the target before
|
|
|
|
// installation.
|
|
|
|
if(t->second.NeedRelinkBeforeInstall())
|
|
|
|
{
|
|
|
|
makeTargetName = lg->GetRelativeTargetDirectory(t->second);
|
|
|
|
makeTargetName += "/preinstall";
|
|
|
|
localName = t->second.GetName();
|
|
|
|
localName += "/preinstall";
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
|
|
|
(makefileName.c_str(), makeTargetName.c_str()));
|
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Manual pre-install relink rule for target.",
|
|
|
|
localName.c_str(), depends, commands, true);
|
|
|
|
}
|
2006-05-02 13:56:42 +00:00
|
|
|
}
|
2005-05-31 15:46:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::WriteConvenienceRules2(std::ostream& ruleFileStream,
|
2007-08-03 19:44:25 +00:00
|
|
|
cmLocalUnixMakefileGenerator3 *lg)
|
2005-05-31 14:16:28 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
std::string localName;
|
|
|
|
std::string makeTargetName;
|
|
|
|
|
2006-05-15 17:02:28 +00:00
|
|
|
|
2005-05-31 14:16:28 +00:00
|
|
|
// write the directory level rules for this local gen
|
2005-05-31 15:46:49 +00:00
|
|
|
this->WriteDirectoryRules2(ruleFileStream,lg);
|
2005-05-31 14:16:28 +00:00
|
|
|
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2005-05-25 19:09:06 +00:00
|
|
|
|
2005-05-11 16:44:01 +00:00
|
|
|
// for each target Generate the rule files for each target.
|
2005-06-22 13:06:46 +00:00
|
|
|
cmTargets& targets = lg->GetMakefile()->GetTargets();
|
|
|
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
2005-05-06 18:49:38 +00:00
|
|
|
{
|
2007-05-22 14:24:59 +00:00
|
|
|
if (t->second.GetName()
|
|
|
|
&& strlen(t->second.GetName())
|
|
|
|
&& ((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)))
|
2005-05-06 18:49:38 +00:00
|
|
|
{
|
2006-05-02 13:56:42 +00:00
|
|
|
std::string makefileName;
|
2005-05-06 18:49:38 +00:00
|
|
|
// Add a rule to build the target by name.
|
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
2006-05-02 13:56:42 +00:00
|
|
|
makefileName = localName;
|
2005-05-19 14:52:59 +00:00
|
|
|
makefileName += "/build.make";
|
2005-05-18 17:46:00 +00:00
|
|
|
|
2007-08-03 13:39:32 +00:00
|
|
|
bool needRequiresStep = this->NeedRequiresStep(t->second);
|
2007-05-22 14:24:59 +00:00
|
|
|
|
|
|
|
lg->WriteDivider(ruleFileStream);
|
|
|
|
ruleFileStream
|
|
|
|
<< "# Target rules for target "
|
|
|
|
<< localName << "\n\n";
|
|
|
|
|
|
|
|
commands.clear();
|
2007-12-21 17:22:12 +00:00
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/depend";
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
|
|
|
(makefileName.c_str(),makeTargetName.c_str()));
|
|
|
|
|
|
|
|
// add requires if we need it for this generator
|
|
|
|
if (needRequiresStep)
|
2005-05-18 17:46:00 +00:00
|
|
|
{
|
2007-05-22 14:24:59 +00:00
|
|
|
makeTargetName = localName;
|
2007-12-21 17:22:12 +00:00
|
|
|
makeTargetName += "/requires";
|
2007-05-22 14:24:59 +00:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
2007-12-21 17:22:12 +00:00
|
|
|
(makefileName.c_str(),makeTargetName.c_str()));
|
2007-05-22 14:24:59 +00:00
|
|
|
}
|
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/build";
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
|
|
|
(makefileName.c_str(),makeTargetName.c_str()));
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
localName += "/all";
|
|
|
|
depends.clear();
|
2006-05-15 17:02:28 +00:00
|
|
|
|
2007-05-22 14:24:59 +00:00
|
|
|
std::string progressDir =
|
|
|
|
lg->GetMakefile()->GetHomeOutputDirectory();
|
|
|
|
progressDir += cmake::GetCMakeFilesDirectory();
|
2006-06-16 19:29:25 +00:00
|
|
|
{
|
|
|
|
cmOStringStream progCmd;
|
2007-05-22 14:24:59 +00:00
|
|
|
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
|
|
|
|
// all target counts
|
2006-06-16 19:29:25 +00:00
|
|
|
progCmd << lg->Convert(progressDir.c_str(),
|
2007-05-22 14:24:59 +00:00
|
|
|
cmLocalGenerator::FULL,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
progCmd << " ";
|
|
|
|
std::vector<int> &progFiles = lg->ProgressFiles[t->first];
|
|
|
|
for (std::vector<int>::iterator i = progFiles.begin();
|
|
|
|
i != progFiles.end(); ++i)
|
|
|
|
{
|
|
|
|
progCmd << " " << *i;
|
|
|
|
}
|
2006-06-16 19:29:25 +00:00
|
|
|
commands.push_back(progCmd.str());
|
|
|
|
}
|
2007-05-22 14:24:59 +00:00
|
|
|
progressDir = "Built target ";
|
|
|
|
progressDir += t->first;
|
|
|
|
lg->AppendEcho(commands,progressDir.c_str());
|
|
|
|
|
|
|
|
this->AppendGlobalTargetDepends(depends,t->second);
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
|
|
|
|
localName.c_str(), depends, commands, true);
|
|
|
|
|
|
|
|
// add the all/all dependency
|
2007-08-03 19:44:25 +00:00
|
|
|
if(!this->IsExcluded(this->LocalGenerators[0], t->second))
|
2006-06-16 19:29:25 +00:00
|
|
|
{
|
2006-02-16 20:19:00 +00:00
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
2007-05-22 14:24:59 +00:00
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Include target in all.",
|
|
|
|
"all", depends, commands, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
|
|
|
progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
|
|
|
|
progressDir += cmake::GetCMakeFilesDirectory();
|
|
|
|
|
|
|
|
{
|
|
|
|
// TODO: Convert the total progress count to a make variable.
|
|
|
|
cmOStringStream progCmd;
|
|
|
|
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
|
|
|
|
// # in target
|
|
|
|
progCmd << lg->Convert(progressDir.c_str(),
|
|
|
|
cmLocalGenerator::FULL,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
//
|
|
|
|
std::set<cmStdString> emitted;
|
|
|
|
progCmd << " "
|
|
|
|
<< this->GetTargetTotalNumberOfActions(t->second,
|
|
|
|
emitted);
|
|
|
|
commands.push_back(progCmd.str());
|
|
|
|
}
|
|
|
|
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
|
tmp += "Makefile2";
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
|
|
|
(tmp.c_str(),localName.c_str()));
|
|
|
|
{
|
|
|
|
cmOStringStream progCmd;
|
|
|
|
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
|
|
|
|
progCmd << lg->Convert(progressDir.c_str(),
|
|
|
|
cmLocalGenerator::FULL,
|
|
|
|
cmLocalGenerator::SHELL);
|
|
|
|
progCmd << " 0";
|
|
|
|
commands.push_back(progCmd.str());
|
|
|
|
}
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back("cmake_check_build_system");
|
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
|
|
|
localName += "/rule";
|
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Build rule for subdir invocation for target.",
|
|
|
|
localName.c_str(), depends, commands, true);
|
|
|
|
|
|
|
|
// Add a target with the canonical name (no prefix, suffix or path).
|
|
|
|
commands.clear();
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
|
|
|
|
t->second.GetName(), depends, commands, true);
|
|
|
|
|
|
|
|
// Add rules to prepare the target for installation.
|
2007-08-02 18:28:00 +00:00
|
|
|
if(t->second.NeedRelinkBeforeInstall())
|
2007-05-22 14:24:59 +00:00
|
|
|
{
|
2006-05-02 13:56:42 +00:00
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
2007-05-22 14:24:59 +00:00
|
|
|
localName += "/preinstall";
|
2006-05-02 13:56:42 +00:00
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
|
|
|
commands.push_back(lg->GetRecursiveMakeCall
|
2007-05-22 14:24:59 +00:00
|
|
|
(makefileName.c_str(), localName.c_str()));
|
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Pre-install relink rule for target.",
|
|
|
|
localName.c_str(), depends, commands, true);
|
2007-08-03 19:44:25 +00:00
|
|
|
|
|
|
|
if(!this->IsExcluded(this->LocalGenerators[0], t->second))
|
|
|
|
{
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
|
|
|
|
"preinstall", depends, commands, true);
|
|
|
|
}
|
2006-02-16 20:19:00 +00:00
|
|
|
}
|
2007-05-22 14:24:59 +00:00
|
|
|
|
|
|
|
// add the clean rule
|
|
|
|
localName = lg->GetRelativeTargetDirectory(t->second);
|
|
|
|
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, true);
|
|
|
|
commands.clear();
|
|
|
|
depends.push_back(makeTargetName);
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
|
|
|
|
"clean", depends, commands, true);
|
2005-05-18 17:46:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 13:11:46 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int cmGlobalUnixMakefileGenerator3
|
2008-01-31 03:56:34 +00:00
|
|
|
::GetTargetTotalNumberOfActions(cmTarget & target,
|
2006-08-29 16:55:11 +00:00
|
|
|
std::set<cmStdString> &emitted)
|
2006-05-23 13:11:46 +00:00
|
|
|
{
|
2006-08-29 16:55:11 +00:00
|
|
|
// do not double count
|
|
|
|
int result = 0;
|
2006-05-23 13:11:46 +00:00
|
|
|
|
2006-08-29 16:55:11 +00:00
|
|
|
if(emitted.insert(target.GetName()).second)
|
2006-05-23 13:11:46 +00:00
|
|
|
{
|
2006-08-29 16:55:11 +00:00
|
|
|
cmLocalUnixMakefileGenerator3 *lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>
|
|
|
|
(target.GetMakefile()->GetLocalGenerator());
|
|
|
|
result = static_cast<int>(lg->ProgressFiles[target.GetName()].size());
|
|
|
|
|
2008-01-31 03:56:34 +00:00
|
|
|
TargetDependSet & depends = this->GetTargetDirectDepends(target);
|
2006-08-29 16:55:11 +00:00
|
|
|
|
2008-01-31 03:56:34 +00:00
|
|
|
TargetDependSet::iterator i;
|
2006-08-29 16:55:11 +00:00
|
|
|
for (i = depends.begin(); i != depends.end(); ++i)
|
|
|
|
{
|
|
|
|
result += this->GetTargetTotalNumberOfActions(**i, emitted);
|
|
|
|
}
|
2006-05-23 13:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-04-12 18:21:58 +00:00
|
|
|
unsigned long cmGlobalUnixMakefileGenerator3
|
|
|
|
::GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg)
|
2006-07-11 13:55:27 +00:00
|
|
|
{
|
|
|
|
unsigned long result = 0;
|
2008-03-12 18:37:46 +00:00
|
|
|
std::set<cmStdString> emitted;
|
2008-01-31 03:56:34 +00:00
|
|
|
std::set<cmTarget *>& targets = this->LocalGeneratorToTargetMap[lg];
|
|
|
|
for(std::set<cmTarget *>::iterator t = targets.begin();
|
2007-08-03 19:44:25 +00:00
|
|
|
t != targets.end(); ++t)
|
2006-07-11 13:55:27 +00:00
|
|
|
{
|
2008-03-12 18:37:46 +00:00
|
|
|
result += this->GetTargetTotalNumberOfActions(**t,emitted);
|
2006-07-11 13:55:27 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-05-23 13:11:46 +00:00
|
|
|
|
2005-05-18 17:46:00 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmGlobalUnixMakefileGenerator3
|
|
|
|
::AppendGlobalTargetDepends(std::vector<std::string>& depends,
|
2005-06-22 13:06:46 +00:00
|
|
|
cmTarget& target)
|
2005-05-18 17:46:00 +00:00
|
|
|
{
|
2008-01-30 17:04:38 +00:00
|
|
|
TargetDependSet const& depends_set = this->GetTargetDirectDepends(target);
|
2007-12-23 20:03:42 +00:00
|
|
|
for(TargetDependSet::const_iterator i = depends_set.begin();
|
|
|
|
i != depends_set.end(); ++i)
|
2005-10-10 15:49:17 +00:00
|
|
|
{
|
2007-12-22 18:08:26 +00:00
|
|
|
// Create the target-level dependency.
|
2007-12-23 20:03:42 +00:00
|
|
|
cmTarget const* dep = *i;
|
|
|
|
cmLocalUnixMakefileGenerator3* lg3 =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>
|
|
|
|
(dep->GetMakefile()->GetLocalGenerator());
|
|
|
|
std::string tgtName = lg3->GetRelativeTargetDirectory(*dep);
|
2005-10-10 15:49:17 +00:00
|
|
|
tgtName += "/all";
|
|
|
|
depends.push_back(tgtName);
|
2005-05-18 17:46:00 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-20 15:01:21 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2005-10-20 17:40:28 +00:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteHelpRule
|
|
|
|
(std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3 *lg)
|
2005-05-20 15:01:21 +00:00
|
|
|
{
|
|
|
|
// add the help target
|
|
|
|
std::string path;
|
|
|
|
std::vector<std::string> no_depends;
|
|
|
|
std::vector<std::string> commands;
|
2006-05-11 14:40:28 +00:00
|
|
|
lg->AppendEcho(commands,"The following are some of the valid targets "
|
|
|
|
"for this Makefile:");
|
2005-05-20 15:01:21 +00:00
|
|
|
lg->AppendEcho(commands,"... all (the default if no target is provided)");
|
|
|
|
lg->AppendEcho(commands,"... clean");
|
|
|
|
lg->AppendEcho(commands,"... depend");
|
|
|
|
|
2005-06-01 13:25:10 +00:00
|
|
|
// Keep track of targets already listed.
|
|
|
|
std::set<cmStdString> emittedTargets;
|
|
|
|
|
2005-05-20 15:01:21 +00:00
|
|
|
// for each local generator
|
|
|
|
unsigned int i;
|
2005-10-20 17:40:28 +00:00
|
|
|
cmLocalUnixMakefileGenerator3 *lg2;
|
2006-03-15 16:02:08 +00:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i)
|
2005-05-20 15:01:21 +00:00
|
|
|
{
|
2006-05-11 14:40:28 +00:00
|
|
|
lg2 =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
|
2005-10-20 17:40:28 +00:00
|
|
|
// for the passed in makefile or if this is the top Makefile wripte out
|
|
|
|
// the targets
|
|
|
|
if (lg2 == lg || !lg->GetParent())
|
2005-05-20 15:01:21 +00:00
|
|
|
{
|
2005-10-20 17:40:28 +00:00
|
|
|
// for each target Generate the rule files for each target.
|
2006-04-25 20:31:21 +00:00
|
|
|
cmTargets& targets = lg2->GetMakefile()->GetTargets();
|
2005-10-20 17:40:28 +00:00
|
|
|
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
|
2005-05-20 15:01:21 +00:00
|
|
|
{
|
2005-10-20 17:40:28 +00: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) ||
|
2006-04-20 14:51:16 +00:00
|
|
|
(t->second.GetType() == cmTarget::GLOBAL_TARGET) ||
|
2005-10-20 17:40:28 +00:00
|
|
|
(t->second.GetType() == cmTarget::UTILITY))
|
2005-06-01 13:25:10 +00:00
|
|
|
{
|
2005-10-20 17:40:28 +00:00
|
|
|
if(emittedTargets.insert(t->second.GetName()).second)
|
|
|
|
{
|
|
|
|
path = "... ";
|
|
|
|
path += t->second.GetName();
|
|
|
|
lg->AppendEcho(commands,path.c_str());
|
|
|
|
}
|
2005-06-01 13:25:10 +00:00
|
|
|
}
|
2005-05-20 15:01:21 +00:00
|
|
|
}
|
2006-08-23 13:45:24 +00:00
|
|
|
std::vector<cmStdString> const& localHelp = lg->GetLocalHelp();
|
|
|
|
for(std::vector<cmStdString>::const_iterator o = localHelp.begin();
|
|
|
|
o != localHelp.end(); ++o)
|
2006-01-02 17:36:54 +00:00
|
|
|
{
|
2006-08-23 13:45:24 +00:00
|
|
|
path = "... ";
|
|
|
|
path += *o;
|
|
|
|
lg->AppendEcho(commands, path.c_str());
|
2006-01-02 17:36:54 +00:00
|
|
|
}
|
2005-05-20 15:01:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Help Target",
|
2008-03-24 14:26:38 +00:00
|
|
|
"help",
|
2006-02-15 21:35:16 +00:00
|
|
|
no_depends, commands, true);
|
2005-05-20 15:01:21 +00:00
|
|
|
ruleFileStream << "\n\n";
|
|
|
|
}
|
|
|
|
|
2005-05-24 15:17:30 +00:00
|
|
|
|
|
|
|
bool cmGlobalUnixMakefileGenerator3
|
2007-08-03 13:39:32 +00:00
|
|
|
::NeedRequiresStep(cmTarget const& target)
|
2005-05-24 15:17:30 +00:00
|
|
|
{
|
2007-08-03 13:39:32 +00:00
|
|
|
std::set<cmStdString> languages;
|
|
|
|
target.GetLanguages(languages);
|
|
|
|
for(std::set<cmStdString>::const_iterator l = languages.begin();
|
|
|
|
l != languages.end(); ++l)
|
2005-05-24 15:17:30 +00:00
|
|
|
{
|
2007-08-03 13:39:32 +00:00
|
|
|
std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
|
|
|
|
var += *l;
|
|
|
|
var += "_FLAG";
|
|
|
|
if(target.GetMakefile()->GetDefinition(var.c_str()))
|
2005-05-24 15:17:30 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|