2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2005-05-05 20:45:53 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2005-05-05 20:45:53 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2005-05-05 20:45:53 +04:00
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmGeneratorTarget.h"
|
2005-05-05 20:45:53 +04:00
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
|
|
|
#include "cmMakefile.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmMakefileTargetGenerator.h"
|
2005-05-05 20:45:53 +04:00
|
|
|
#include "cmake.h"
|
|
|
|
|
2015-05-24 12:31:14 +03:00
|
|
|
cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
|
2015-07-07 23:37:56 +03:00
|
|
|
: cmGlobalCommonGenerator(cm)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
|
|
|
// This type of makefile always requires unix style paths
|
2006-03-15 19:02:08 +03:00
|
|
|
this->ForceUnixPaths = true;
|
|
|
|
this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
2006-04-27 05:31:39 +04:00
|
|
|
this->ToolSupportsColor = true;
|
2007-06-06 00:35:24 +04:00
|
|
|
|
2009-06-10 21:04:04 +04:00
|
|
|
#if defined(_WIN32) || defined(__VMS)
|
2006-06-19 04:05:56 +04:00
|
|
|
this->UseLinkScript = false;
|
|
|
|
#else
|
2006-06-16 00:17:11 +04:00
|
|
|
this->UseLinkScript = true;
|
2006-06-19 04:05:56 +04:00
|
|
|
#endif
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CommandDatabase = CM_NULLPTR;
|
2015-05-16 06:18:39 +03:00
|
|
|
|
|
|
|
this->IncludeDirective = "include";
|
2015-05-16 06:20:36 +03:00
|
|
|
this->DefineWindowsNULL = false;
|
2015-05-16 06:20:58 +03:00
|
|
|
this->PassMakeflags = false;
|
2015-05-16 06:21:24 +03:00
|
|
|
this->UnixCD = true;
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::EnableLanguage(
|
|
|
|
std::vector<std::string> const& languages, cmMakefile* mf, bool optional)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
2007-06-28 17:09:26 +04:00
|
|
|
this->cmGlobalGenerator::EnableLanguage(languages, mf, optional);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator l = languages.begin();
|
|
|
|
l != languages.end(); ++l) {
|
|
|
|
if (*l == "NONE") {
|
2005-09-02 01:14:56 +04:00
|
|
|
continue;
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ResolveLanguageCompiler(*l, mf, optional);
|
|
|
|
}
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
///! Create a local generator appropriate to this Global Generator
|
2015-08-02 12:08:49 +03:00
|
|
|
cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile* mf)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
2015-08-02 12:41:51 +03:00
|
|
|
return new cmLocalUnixMakefileGenerator3(this, mf);
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::GetDocumentation(
|
|
|
|
cmDocumentationEntry& entry)
|
2005-05-05 20:45:53 +04:00
|
|
|
{
|
2012-11-19 19:42:24 +04:00
|
|
|
entry.Name = cmGlobalUnixMakefileGenerator3::GetActualName();
|
2007-10-22 20:49:09 +04:00
|
|
|
entry.Brief = "Generates standard UNIX makefiles.";
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
|
2013-11-12 17:44:08 +04:00
|
|
|
std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const
|
|
|
|
{
|
|
|
|
// If generating for an extra IDE, the edit_cache target cannot
|
|
|
|
// launch a terminal-interactive tool, so always use cmake-gui.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GetExtraGeneratorName().empty()) {
|
2013-11-12 17:44:08 +04:00
|
|
|
return cmSystemTools::GetCMakeGUICommand();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-12 17:44:08 +04:00
|
|
|
|
|
|
|
// Use an internal cache entry to track the latest dialog used
|
|
|
|
// to edit the cache, and use that for the edit_cache target.
|
|
|
|
cmake* cm = this->GetCMakeInstance();
|
|
|
|
std::string editCacheCommand = cm->GetCMakeEditCommand();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") ||
|
|
|
|
!editCacheCommand.empty()) {
|
|
|
|
if (editCacheCommand.empty()) {
|
2013-11-12 17:44:08 +04:00
|
|
|
editCacheCommand = cmSystemTools::GetCMakeCursesCommand();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (editCacheCommand.empty()) {
|
2013-11-12 17:44:08 +04:00
|
|
|
editCacheCommand = cmSystemTools::GetCMakeGUICommand();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!editCacheCommand.empty()) {
|
|
|
|
cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
|
|
|
|
"Path to cache edit program executable.",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
}
|
|
|
|
}
|
2013-11-12 17:44:08 +04:00
|
|
|
const char* edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND");
|
2016-05-16 17:34:04 +03:00
|
|
|
return edit_cmd ? edit_cmd : "";
|
2013-11-12 17:44:08 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory(
|
|
|
|
cmGeneratorTarget* gt) const
|
2014-03-13 00:09:20 +04:00
|
|
|
{
|
|
|
|
// Compute full path to object file directory for this target.
|
2014-03-17 18:27:01 +04:00
|
|
|
std::string dir;
|
2015-10-21 20:59:12 +03:00
|
|
|
dir += gt->LocalGenerator->GetCurrentBinaryDirectory();
|
2014-03-17 18:27:01 +04:00
|
|
|
dir += "/";
|
2015-10-09 23:27:46 +03:00
|
|
|
dir += gt->LocalGenerator->GetTargetDirectory(gt);
|
2014-03-17 18:27:01 +04:00
|
|
|
dir += "/";
|
|
|
|
gt->ObjectDirectory = dir;
|
2014-03-13 00:09:20 +04:00
|
|
|
}
|
|
|
|
|
2013-11-12 17:44:08 +04:00
|
|
|
void cmGlobalUnixMakefileGenerator3::Configure()
|
|
|
|
{
|
|
|
|
// Initialize CMAKE_EDIT_COMMAND cache entry.
|
|
|
|
this->GetEditCacheCommand();
|
|
|
|
|
|
|
|
this->cmGlobalGenerator::Configure();
|
|
|
|
}
|
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::Generate()
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
2006-07-11 17:55:27 +04:00
|
|
|
// first do superclass method
|
|
|
|
this->cmGlobalGenerator::Generate();
|
|
|
|
|
2011-05-16 19:18:39 +04:00
|
|
|
// initialize progress
|
|
|
|
unsigned long total = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (ProgressMapType::const_iterator pmi = this->ProgressMap.begin();
|
|
|
|
pmi != this->ProgressMap.end(); ++pmi) {
|
2011-05-16 19:18:39 +04:00
|
|
|
total += pmi->second.NumberOfActions;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2011-05-16 19:18:39 +04: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.
|
|
|
|
unsigned long current = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (ProgressMapType::iterator pmi = this->ProgressMap.begin();
|
|
|
|
pmi != this->ProgressMap.end(); ++pmi) {
|
2011-05-16 19:18:39 +04:00
|
|
|
pmi->second.WriteProgressVariables(total, current);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
|
|
|
|
cmLocalGenerator* lg = this->LocalGenerators[i];
|
2015-09-25 01:13:20 +03:00
|
|
|
std::string markFileName = lg->GetCurrentBinaryDirectory();
|
2011-05-16 19:18:39 +04:00
|
|
|
markFileName += "/";
|
|
|
|
markFileName += cmake::GetCMakeFilesDirectory();
|
|
|
|
markFileName += "/progress.marks";
|
|
|
|
cmGeneratedFileStream markFile(markFileName.c_str());
|
|
|
|
markFile << this->CountProgressMarksInAll(lg) << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-10-28 19:13:00 +04:00
|
|
|
|
2005-05-06 22:49:38 +04:00
|
|
|
// write the main makefile
|
2005-05-31 19:46:49 +04:00
|
|
|
this->WriteMainMakefile2();
|
2005-05-06 22:49:38 +04:00
|
|
|
this->WriteMainCMakefile();
|
2011-01-13 07:39:13 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
if (this->CommandDatabase != CM_NULLPTR) {
|
2011-01-13 07:39:13 +03:00
|
|
|
*this->CommandDatabase << std::endl << "]";
|
|
|
|
delete this->CommandDatabase;
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CommandDatabase = CM_NULLPTR;
|
2011-01-13 07:39:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& sourceFile, const std::string& workingDirectory,
|
|
|
|
const std::string& compileCommand)
|
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
if (this->CommandDatabase == CM_NULLPTR) {
|
2011-01-13 07:39:13 +03:00
|
|
|
std::string commandDatabaseName =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
|
|
|
|
"/compile_commands.json";
|
2011-01-13 07:39:13 +03:00
|
|
|
this->CommandDatabase =
|
|
|
|
new cmGeneratedFileStream(commandDatabaseName.c_str());
|
|
|
|
*this->CommandDatabase << "[" << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2011-01-13 07:39:13 +03:00
|
|
|
*this->CommandDatabase << "," << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-01-13 07:39:13 +03:00
|
|
|
*this->CommandDatabase << "{" << std::endl
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " \"directory\": \""
|
|
|
|
<< cmGlobalGenerator::EscapeJSON(workingDirectory)
|
|
|
|
<< "\"," << std::endl
|
|
|
|
<< " \"command\": \""
|
|
|
|
<< cmGlobalGenerator::EscapeJSON(compileCommand)
|
|
|
|
<< "\"," << std::endl
|
|
|
|
<< " \"file\": \""
|
|
|
|
<< cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
|
|
|
|
<< std::endl
|
|
|
|
<< "}";
|
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.
|
2010-11-12 00:02:07 +03:00
|
|
|
std::string makefileName =
|
2005-05-31 19:46:49 +04:00
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2006-06-14 20:28:32 +04:00
|
|
|
makefileName += cmake::GetCMakeFilesDirectory();
|
|
|
|
makefileName += "/Makefile2";
|
2005-05-31 19:46:49 +04:00
|
|
|
cmGeneratedFileStream makefileStream(makefileName.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!makefileStream) {
|
2005-05-31 19:46:49 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-05-31 19:46:49 +04:00
|
|
|
// get a local generator for some useful methods
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-05-31 19:46:49 +04:00
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(makefileStream);
|
2006-02-15 18:34:11 +03:00
|
|
|
|
2005-05-31 19:46:49 +04: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.",
|
2016-05-16 17:34:04 +03:00
|
|
|
"default_target", depends, no_commands, true);
|
2005-05-31 19:46:49 +04:00
|
|
|
|
2006-01-17 18:21:45 +03:00
|
|
|
depends.clear();
|
2006-02-16 00:35:16 +03:00
|
|
|
|
2006-02-17 02:50:16 +03:00
|
|
|
// The all and preinstall rules might never have any dependencies
|
|
|
|
// added to them.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->EmptyRuleHackDepends != "") {
|
2006-03-15 19:02:08 +03:00
|
|
|
depends.push_back(this->EmptyRuleHackDepends);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-17 02:50:16 +03:00
|
|
|
|
2005-05-31 19:46:49 +04:00
|
|
|
// Write and empty all:
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(makefileStream, "The main recursive all target", "all",
|
2006-02-16 00:35:16 +03:00
|
|
|
depends, no_commands, true);
|
2005-05-31 19:46:49 +04:00
|
|
|
|
2006-02-16 23:19:00 +03:00
|
|
|
// Write an empty preinstall:
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(makefileStream, "The main recursive preinstall target",
|
|
|
|
"preinstall", depends, no_commands, true);
|
2006-02-16 23:19:00 +03:00
|
|
|
|
2006-02-16 00:35:16 +03:00
|
|
|
// Write out the "special" stuff
|
|
|
|
lg->WriteSpecialTargetsTop(makefileStream);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-05-31 19:46:49 +04:00
|
|
|
// write the target convenience rules
|
|
|
|
unsigned int i;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i) {
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
|
|
|
|
this->WriteConvenienceRules2(makefileStream, lg);
|
|
|
|
}
|
2005-05-31 19:46:49 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
|
2005-05-31 19:46:49 +04:00
|
|
|
lg->WriteSpecialTargetsBottom(makefileStream);
|
|
|
|
}
|
|
|
|
|
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.
|
2010-11-12 00:02:07 +03:00
|
|
|
std::string cmakefileName =
|
2005-05-06 22:49:38 +04:00
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2006-06-14 20:28:32 +04:00
|
|
|
cmakefileName += cmake::GetCMakeFilesDirectory();
|
|
|
|
cmakefileName += "/Makefile.cmake";
|
2005-05-05 20:45:53 +04:00
|
|
|
cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmakefileStream) {
|
2005-05-05 20:45:53 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
std::string makefileName =
|
2005-05-06 22:49:38 +04:00
|
|
|
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
|
|
makefileName += "/Makefile";
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
// get a local generator for some useful methods
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
// Write the do not edit header.
|
|
|
|
lg->WriteDisclaimer(cmakefileStream);
|
|
|
|
|
2005-05-12 18:49:56 +04:00
|
|
|
// Save the generator name
|
2016-05-16 17:34:04 +03:00
|
|
|
cmakefileStream << "# The generator used is:\n"
|
|
|
|
<< "set(CMAKE_DEPENDS_GENERATOR \"" << this->GetName()
|
|
|
|
<< "\")\n\n";
|
2005-05-12 18:49:56 +04:00
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
// for each cmMakefile get its list of dependencies
|
|
|
|
std::vector<std::string> lfiles;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-05-05 20:45:53 +04:00
|
|
|
// Get the list of files contributing to this generation step.
|
2016-05-16 17:34:04 +03:00
|
|
|
lfiles.insert(lfiles.end(), lg->GetMakefile()->GetListFiles().begin(),
|
2005-05-05 20:45:53 +04:00
|
|
|
lg->GetMakefile()->GetListFiles().end());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-05 20:45:53 +04:00
|
|
|
// Sort the list and remove duplicates.
|
|
|
|
std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
|
2009-06-10 21:02:18 +04:00
|
|
|
#if !defined(__VMS) // The Compaq STL on VMS crashes, so accept duplicates.
|
2010-11-12 00:02:07 +03:00
|
|
|
std::vector<std::string>::iterator new_end =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::unique(lfiles.begin(), lfiles.end());
|
2005-05-05 20:45:53 +04:00
|
|
|
lfiles.erase(new_end, lfiles.end());
|
2009-06-10 21:02:18 +04:00
|
|
|
#endif
|
2005-05-05 20:45:53 +04:00
|
|
|
|
|
|
|
// reset lg to the first makefile
|
2016-05-16 17:34:04 +03:00
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
|
2005-05-05 20:45:53 +04: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"
|
2013-08-22 13:30:19 +04:00
|
|
|
<< "set(CMAKE_MAKEFILE_DEPENDS\n"
|
2016-05-20 00:11:40 +03:00
|
|
|
<< " \"" << lg->Convert(cache, cmOutputConverter::START_OUTPUT) << "\"\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = lfiles.begin();
|
|
|
|
i != lfiles.end(); ++i) {
|
|
|
|
cmakefileStream << " \""
|
2016-05-20 00:11:40 +03:00
|
|
|
<< lg->Convert(*i, cmOutputConverter::START_OUTPUT)
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
cmakefileStream << " )\n\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
|
|
|
|
// Build the path to the cache check file.
|
|
|
|
std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
2006-06-14 20:28:32 +04:00
|
|
|
check += cmake::GetCMakeFilesDirectory();
|
|
|
|
check += "/cmake.check_cache";
|
2005-05-05 20:45:53 +04:00
|
|
|
|
|
|
|
// Set the corresponding makefile in the cmake file.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmakefileStream << "# The corresponding makefile is:\n"
|
|
|
|
<< "set(CMAKE_MAKEFILE_OUTPUTS\n"
|
|
|
|
<< " \""
|
2016-05-20 00:11:40 +03:00
|
|
|
<< lg->Convert(makefileName, cmOutputConverter::START_OUTPUT)
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "\"\n"
|
|
|
|
<< " \""
|
2016-05-20 00:11:40 +03:00
|
|
|
<< lg->Convert(check, cmOutputConverter::START_OUTPUT)
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "\"\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
cmakefileStream << " )\n\n";
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2009-02-06 19:18:56 +03:00
|
|
|
// CMake must rerun if a byproduct is missing.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmakefileStream << "# Byproducts of CMake generate step:\n"
|
|
|
|
<< "set(CMAKE_MAKEFILE_PRODUCTS\n";
|
|
|
|
const std::vector<std::string>& outfiles =
|
|
|
|
lg->GetMakefile()->GetOutputFiles();
|
|
|
|
for (std::vector<std::string>::const_iterator k = outfiles.begin();
|
|
|
|
k != outfiles.end(); ++k) {
|
|
|
|
cmakefileStream << " \""
|
2016-05-20 00:11:40 +03:00
|
|
|
<< lg->Convert(*k, cmOutputConverter::HOME_OUTPUT)
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// add in all the directory information files
|
|
|
|
std::string tmpStr;
|
|
|
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
|
|
|
|
lg =
|
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
|
|
|
|
tmpStr = lg->GetCurrentBinaryDirectory();
|
|
|
|
tmpStr += cmake::GetCMakeFilesDirectory();
|
|
|
|
tmpStr += "/CMakeDirectoryInformation.cmake";
|
|
|
|
cmakefileStream << " \""
|
2016-05-20 00:11:40 +03:00
|
|
|
<< lg->Convert(tmpStr, cmOutputConverter::HOME_OUTPUT)
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
cmakefileStream << " )\n\n";
|
2009-02-06 19:18:56 +03:00
|
|
|
}
|
|
|
|
|
2010-11-12 00:02:07 +03:00
|
|
|
this->WriteMainCMakefileLanguageRules(cmakefileStream,
|
2006-05-11 18:40:28 +04:00
|
|
|
this->LocalGenerators);
|
2006-04-11 19:06:19 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules(
|
|
|
|
cmGeneratedFileStream& cmakefileStream,
|
|
|
|
std::vector<cmLocalGenerator*>& lGenerators)
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* lg;
|
2005-05-06 22:49:38 +04:00
|
|
|
|
2005-07-27 17:49:37 +04:00
|
|
|
// now list all the target info files
|
2016-05-16 17:34:04 +03:00
|
|
|
cmakefileStream << "# Dependency information for all targets:\n";
|
|
|
|
cmakefileStream << "set(CMAKE_DEPEND_INFO_FILES\n";
|
|
|
|
for (unsigned int i = 0; i < lGenerators.size(); ++i) {
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]);
|
2005-07-27 17:49:37 +04:00
|
|
|
// for all of out targets
|
2015-10-18 18:06:14 +03:00
|
|
|
std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
|
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
l != tgts.end(); l++) {
|
|
|
|
if (((*l)->GetType() == cmState::EXECUTABLE) ||
|
|
|
|
((*l)->GetType() == cmState::STATIC_LIBRARY) ||
|
|
|
|
((*l)->GetType() == cmState::SHARED_LIBRARY) ||
|
|
|
|
((*l)->GetType() == cmState::MODULE_LIBRARY) ||
|
|
|
|
((*l)->GetType() == cmState::OBJECT_LIBRARY) ||
|
|
|
|
((*l)->GetType() == cmState::UTILITY)) {
|
2015-10-18 18:06:14 +03:00
|
|
|
cmGeneratorTarget* gt = *l;
|
2015-10-15 01:12:53 +03:00
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(gt);
|
2005-08-02 19:06:16 +04:00
|
|
|
tname += "/DependInfo.cmake";
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(tname);
|
2014-03-11 16:35:32 +04:00
|
|
|
cmakefileStream << " \"" << tname << "\"\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-27 17:49:37 +04:00
|
|
|
cmakefileStream << " )\n";
|
2005-05-05 20:45:53 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
|
|
|
|
std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg,
|
|
|
|
const char* pass, bool check_all, bool check_relink)
|
2005-05-06 22:49:38 +04:00
|
|
|
{
|
2006-03-02 02:54:17 +03:00
|
|
|
// Get the relative path to the subdirectory from the top.
|
2015-09-25 01:13:20 +03:00
|
|
|
std::string makeTarget = lg->GetCurrentBinaryDirectory();
|
2006-03-02 02:54:17 +03:00
|
|
|
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;
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
|
|
|
|
l != targets.end(); ++l) {
|
2015-10-18 17:53:00 +03:00
|
|
|
cmGeneratorTarget* gtarget = *l;
|
2014-02-25 05:31:04 +04:00
|
|
|
int type = gtarget->GetType();
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) ||
|
|
|
|
(type == cmState::SHARED_LIBRARY) ||
|
|
|
|
(type == cmState::MODULE_LIBRARY) ||
|
|
|
|
(type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY)) {
|
2006-03-02 02:54:17 +03:00
|
|
|
// Add this to the list of depends rules in this directory.
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
|
|
|
|
(!check_relink ||
|
|
|
|
gtarget->NeedRelinkBeforeInstall(lg->GetConfigName()))) {
|
2015-10-15 01:12:53 +03:00
|
|
|
std::string tname = lg->GetRelativeTargetDirectory(gtarget);
|
2006-03-02 02:54:17 +03:00
|
|
|
tname += "/";
|
|
|
|
tname += pass;
|
|
|
|
depends.push_back(tname);
|
2005-05-19 23:00:35 +04:00
|
|
|
}
|
2005-05-31 19:46:49 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-31 19:46:49 +04:00
|
|
|
|
2006-03-02 02:54:17 +03:00
|
|
|
// The directory-level rule should depend on the directory-level
|
|
|
|
// rules of the subdirectories.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmState::Snapshot> children =
|
|
|
|
lg->GetStateSnapshot().GetChildren();
|
|
|
|
for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin();
|
|
|
|
ci != children.end(); ++ci) {
|
2015-07-19 17:33:54 +03:00
|
|
|
std::string subdir = ci->GetDirectory().GetCurrentBinary();
|
2006-03-02 02:54:17 +03:00
|
|
|
subdir += "/";
|
|
|
|
subdir += pass;
|
|
|
|
depends.push_back(subdir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-02 02:54:17 +03:00
|
|
|
|
|
|
|
// Work-around for makes that drop rules that have no dependencies
|
|
|
|
// or commands.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (depends.empty() && this->EmptyRuleHackDepends != "") {
|
2006-03-15 19:02:08 +03:00
|
|
|
depends.push_back(this->EmptyRuleHackDepends);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-02 02:54:17 +03:00
|
|
|
|
|
|
|
// Write the rule.
|
|
|
|
std::string doc = "Convenience name for \"";
|
|
|
|
doc += pass;
|
|
|
|
doc += "\" pass in the directory.";
|
|
|
|
std::vector<std::string> no_commands;
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream, doc.c_str(), makeTarget, depends,
|
|
|
|
no_commands, true);
|
2005-05-31 19:46:49 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
|
|
|
|
std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
|
2005-05-31 19:46:49 +04:00
|
|
|
{
|
2006-03-02 02:54:17 +03:00
|
|
|
// Only subdirectories need these rules.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lg->IsRootMakefile()) {
|
2006-03-02 02:54:17 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-25 23:09:06 +04:00
|
|
|
|
2006-03-02 02:54:17 +03:00
|
|
|
// Begin the directory-level rules section.
|
2015-09-25 01:13:20 +03:00
|
|
|
std::string dir = lg->GetCurrentBinaryDirectory();
|
2016-05-20 00:11:40 +03:00
|
|
|
dir = lg->Convert(dir, cmOutputConverter::HOME_OUTPUT,
|
|
|
|
cmOutputConverter::MAKERULE);
|
2006-03-02 02:54:17 +03:00
|
|
|
lg->WriteDivider(ruleFileStream);
|
2016-05-16 17:34:04 +03:00
|
|
|
ruleFileStream << "# Directory level rules for directory " << dir << "\n\n";
|
2006-03-02 02:54:17 +03:00
|
|
|
|
|
|
|
// 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-04 00:31:08 +04:00
|
|
|
this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
|
2005-05-31 18:16:28 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
|
|
|
|
std::vector<std::string>& makeCommand, const std::string& makeProgram,
|
|
|
|
const std::string& /*projectName*/, const std::string& /*projectDir*/,
|
|
|
|
const std::string& targetName, const std::string& /*config*/, bool fast,
|
|
|
|
bool /*verbose*/, std::vector<std::string> const& makeOptions)
|
2006-05-02 17:56:42 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
makeCommand.push_back(this->SelectMakeProgram(makeProgram));
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2006-05-02 17:56:42 +04:00
|
|
|
// Since we have full control over the invocation of nmake, let us
|
|
|
|
// make it quiet.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmHasLiteralPrefix(this->GetName(), "NMake Makefiles")) {
|
2013-11-15 22:33:32 +04:00
|
|
|
makeCommand.push_back("/NOLOGO");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
makeCommand.insert(makeCommand.end(), makeOptions.begin(),
|
|
|
|
makeOptions.end());
|
|
|
|
if (!targetName.empty()) {
|
2015-08-02 12:41:51 +03:00
|
|
|
cmMakefile* mf;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefiles.empty()) {
|
2015-09-24 10:35:55 +03:00
|
|
|
mf = this->Makefiles[0];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-05-31 02:43:31 +03:00
|
|
|
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
|
2016-05-16 17:34:04 +03:00
|
|
|
snapshot.GetDirectory().SetCurrentSource(
|
|
|
|
this->CMakeInstance->GetHomeDirectory());
|
|
|
|
snapshot.GetDirectory().SetCurrentBinary(
|
|
|
|
this->CMakeInstance->GetHomeOutputDirectory());
|
2015-10-13 22:48:46 +03:00
|
|
|
snapshot.SetDefaultDefinitions();
|
2015-05-31 02:57:04 +03:00
|
|
|
mf = new cmMakefile(this, snapshot);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2006-05-02 17:56:42 +04:00
|
|
|
std::string tname = targetName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fast) {
|
2006-06-01 23:51:24 +04:00
|
|
|
tname += "/fast";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-24 10:34:53 +03:00
|
|
|
cmOutputConverter conv(mf->GetStateSnapshot());
|
2016-05-16 17:34:04 +03:00
|
|
|
tname = conv.Convert(tname, cmOutputConverter::HOME_OUTPUT);
|
2013-11-15 22:33:32 +04:00
|
|
|
cmSystemTools::ConvertToOutputSlashes(tname);
|
|
|
|
makeCommand.push_back(tname);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefiles.empty()) {
|
2015-08-02 12:41:51 +03:00
|
|
|
delete mf;
|
2006-05-02 17:56:42 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-05-02 17:56:42 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
|
|
|
|
std::ostream& ruleFileStream, std::set<std::string>& emitted)
|
2005-05-31 19:46:49 +04:00
|
|
|
{
|
2010-11-12 00:02:07 +03:00
|
|
|
std::vector<std::string> depends;
|
2005-05-31 19:46:49 +04:00
|
|
|
std::vector<std::string> commands;
|
|
|
|
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-10-20 21:40:28 +04:00
|
|
|
// write the target convenience rules
|
|
|
|
unsigned int i;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* lg;
|
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i) {
|
|
|
|
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
|
2005-10-20 21:40:28 +04:00
|
|
|
// for each target Generate the rule files for each target.
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
2015-10-18 17:53:00 +03:00
|
|
|
cmGeneratorTarget* gtarget = *t;
|
2006-06-01 22:09:21 +04:00
|
|
|
// Don't emit the same rule twice (e.g. two targets with the same
|
|
|
|
// simple name)
|
2014-02-25 05:31:04 +04:00
|
|
|
int type = gtarget->GetType();
|
|
|
|
std::string name = gtarget->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!name.empty() && emitted.insert(name).second &&
|
|
|
|
// Handle user targets here. Global targets are handled in
|
|
|
|
// the local generator on a per-directory basis.
|
|
|
|
((type == cmState::EXECUTABLE) ||
|
|
|
|
(type == cmState::STATIC_LIBRARY) ||
|
|
|
|
(type == cmState::SHARED_LIBRARY) ||
|
|
|
|
(type == cmState::MODULE_LIBRARY) ||
|
|
|
|
(type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY))) {
|
2007-05-22 18:24:59 +04:00
|
|
|
// Add a rule to build the target by name.
|
|
|
|
lg->WriteDivider(ruleFileStream);
|
2016-05-16 17:34:04 +03:00
|
|
|
ruleFileStream << "# Target rules for targets named " << name
|
|
|
|
<< "\n\n";
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
|
|
|
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
|
tmp += "Makefile2";
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name));
|
2007-05-22 18:24:59 +04:00
|
|
|
depends.clear();
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "Build rule for target.", name,
|
|
|
|
depends, commands, true);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
// Add a fast rule to build the target
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string localName = lg->GetRelativeTargetDirectory(gtarget);
|
2007-05-22 18:24:59 +04:00
|
|
|
std::string makefileName;
|
|
|
|
makefileName = localName;
|
2010-11-12 00:02:07 +03:00
|
|
|
makefileName += "/build.make";
|
2007-05-22 18:24:59 +04:00
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
|
|
|
std::string makeTargetName = localName;
|
|
|
|
makeTargetName += "/build";
|
2014-02-25 05:31:04 +04:00
|
|
|
localName = name;
|
2007-05-22 18:24:59 +04:00
|
|
|
localName += "/fast";
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
|
2007-05-22 18:24:59 +04:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
|
2014-03-11 03:04:11 +04:00
|
|
|
localName, depends, commands, true);
|
2007-08-04 00:31:08 +04:00
|
|
|
|
|
|
|
// Add a local name for the rule to relink the target before
|
|
|
|
// installation.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gtarget->NeedRelinkBeforeInstall(lg->GetConfigName())) {
|
2015-10-15 01:12:53 +03:00
|
|
|
makeTargetName = lg->GetRelativeTargetDirectory(gtarget);
|
2007-08-04 00:31:08 +04:00
|
|
|
makeTargetName += "/preinstall";
|
2014-02-25 05:31:04 +04:00
|
|
|
localName = name;
|
2007-08-04 00:31:08 +04:00
|
|
|
localName += "/preinstall";
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
|
2007-08-04 00:31:08 +04:00
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
|
|
|
"Manual pre-install relink rule for target.",
|
2014-03-11 03:04:11 +04:00
|
|
|
localName, depends, commands, true);
|
2006-05-02 17:56:42 +04:00
|
|
|
}
|
2005-05-31 19:46:49 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-31 19:46:49 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
|
|
|
|
std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
|
2005-05-31 18:16:28 +04:00
|
|
|
{
|
2010-11-12 00:02:07 +03:00
|
|
|
std::vector<std::string> depends;
|
2005-05-31 18:16:28 +04:00
|
|
|
std::vector<std::string> commands;
|
|
|
|
std::string localName;
|
|
|
|
std::string makeTargetName;
|
|
|
|
|
|
|
|
// write the directory level rules for this local gen
|
2016-05-16 17:34:04 +03:00
|
|
|
this->WriteDirectoryRules2(ruleFileStream, lg);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
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.
|
2015-10-18 17:53:00 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
2015-10-18 17:53:00 +03:00
|
|
|
cmGeneratorTarget* gtarget = *t;
|
2014-02-25 05:31:04 +04:00
|
|
|
int type = gtarget->GetType();
|
|
|
|
std::string name = gtarget->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!name.empty() &&
|
|
|
|
((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) ||
|
|
|
|
(type == cmState::SHARED_LIBRARY) ||
|
|
|
|
(type == cmState::MODULE_LIBRARY) ||
|
|
|
|
(type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY))) {
|
2006-05-02 17:56:42 +04:00
|
|
|
std::string makefileName;
|
2005-05-06 22:49:38 +04:00
|
|
|
// Add a rule to build the target by name.
|
2015-10-15 01:12:53 +03:00
|
|
|
localName = lg->GetRelativeTargetDirectory(gtarget);
|
2006-05-02 17:56:42 +04:00
|
|
|
makefileName = localName;
|
2005-05-19 18:52:59 +04:00
|
|
|
makefileName += "/build.make";
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2015-10-19 00:20:47 +03:00
|
|
|
bool needRequiresStep = this->NeedRequiresStep(gtarget);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
lg->WriteDivider(ruleFileStream);
|
2016-05-16 17:34:04 +03:00
|
|
|
ruleFileStream << "# Target rules for target " << localName << "\n\n";
|
2010-11-12 00:02:07 +03:00
|
|
|
|
|
|
|
commands.clear();
|
2013-12-10 20:16:08 +04:00
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/depend";
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
|
2007-12-21 20:22:12 +03:00
|
|
|
|
2013-12-10 20:16:08 +04:00
|
|
|
// add requires if we need it for this generator
|
2016-05-16 17:34:04 +03:00
|
|
|
if (needRequiresStep) {
|
2007-05-22 18:24:59 +04:00
|
|
|
makeTargetName = localName;
|
2013-12-10 20:16:08 +04:00
|
|
|
makeTargetName += "/requires";
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
|
|
|
|
}
|
2013-12-10 20:16:08 +04:00
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/build";
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2013-12-10 20:16:08 +04:00
|
|
|
// Write the rule.
|
|
|
|
localName += "/all";
|
|
|
|
depends.clear();
|
2013-08-22 00:00:48 +04:00
|
|
|
|
2015-02-06 00:48:16 +03:00
|
|
|
cmLocalUnixMakefileGenerator3::EchoProgress progress;
|
2015-10-07 02:17:48 +03:00
|
|
|
progress.Dir = lg->GetBinaryDirectory();
|
2015-02-06 00:48:16 +03:00
|
|
|
progress.Dir += cmake::GetCMakeFilesDirectory();
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostringstream progressArg;
|
|
|
|
const char* sep = "";
|
|
|
|
std::vector<unsigned long>& progFiles =
|
|
|
|
this->ProgressMap[gtarget].Marks;
|
|
|
|
for (std::vector<unsigned long>::iterator i = progFiles.begin();
|
|
|
|
i != progFiles.end(); ++i) {
|
|
|
|
progressArg << sep << *i;
|
|
|
|
sep = ",";
|
2006-06-16 23:29:25 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
progress.Arg = progressArg.str();
|
2015-02-06 00:48:16 +03:00
|
|
|
}
|
2015-07-10 19:14:47 +03:00
|
|
|
|
|
|
|
bool targetMessages = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* tgtMsg =
|
|
|
|
this->GetCMakeInstance()->GetState()->GetGlobalProperty(
|
|
|
|
"TARGET_MESSAGES")) {
|
2015-07-10 19:14:47 +03:00
|
|
|
targetMessages = cmSystemTools::IsOn(tgtMsg);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-10 19:14:47 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (targetMessages) {
|
2015-07-10 19:14:47 +03:00
|
|
|
lg->AppendEcho(commands, "Built target " + name,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3::EchoNormal, &progress);
|
|
|
|
}
|
2013-12-10 20:16:08 +04:00
|
|
|
|
2015-06-06 14:08:17 +03:00
|
|
|
this->AppendGlobalTargetDepends(depends, gtarget);
|
2007-05-22 18:24:59 +04:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
|
2014-03-11 03:04:11 +04:00
|
|
|
localName, depends, commands, true);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
// add the all/all dependency
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
|
2006-02-16 23:19:00 +03:00
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
2007-05-22 18:24:59 +04:00
|
|
|
commands.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "Include target in all.", "all",
|
|
|
|
depends, commands, true);
|
|
|
|
}
|
2010-10-28 19:13:00 +04:00
|
|
|
|
2011-05-16 19:18:39 +04:00
|
|
|
// Write the rule.
|
|
|
|
commands.clear();
|
2010-10-28 19:13:00 +04:00
|
|
|
|
2011-05-16 19:18:39 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
// TODO: Convert the total progress count to a make variable.
|
|
|
|
std::ostringstream progCmd;
|
|
|
|
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
|
|
|
|
// # in target
|
2016-05-20 00:11:40 +03:00
|
|
|
progCmd << lg->Convert(progress.Dir, cmOutputConverter::FULL,
|
|
|
|
cmOutputConverter::SHELL);
|
2016-05-16 17:34:04 +03:00
|
|
|
//
|
|
|
|
std::set<cmGeneratorTarget const*> emitted;
|
|
|
|
progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted);
|
|
|
|
commands.push_back(progCmd.str());
|
2011-05-16 19:18:39 +04:00
|
|
|
}
|
2007-05-22 18:24:59 +04:00
|
|
|
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
|
tmp += "Makefile2";
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName));
|
2011-05-16 19:18:39 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostringstream progCmd;
|
|
|
|
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
|
2016-05-20 00:11:40 +03:00
|
|
|
progCmd << lg->Convert(progress.Dir, cmOutputConverter::FULL,
|
|
|
|
cmOutputConverter::SHELL);
|
2016-05-16 17:34:04 +03:00
|
|
|
progCmd << " 0";
|
|
|
|
commands.push_back(progCmd.str());
|
2011-05-16 19:18:39 +04:00
|
|
|
}
|
2007-05-22 18:24:59 +04:00
|
|
|
depends.clear();
|
|
|
|
depends.push_back("cmake_check_build_system");
|
2015-10-15 01:12:53 +03:00
|
|
|
localName = lg->GetRelativeTargetDirectory(gtarget);
|
2007-05-22 18:24:59 +04:00
|
|
|
localName += "/rule";
|
2010-11-12 00:02:07 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
2007-05-22 18:24:59 +04:00
|
|
|
"Build rule for subdir invocation for target.",
|
2014-03-11 03:04:11 +04:00
|
|
|
localName, depends, commands, true);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
// Add a target with the canonical name (no prefix, suffix or path).
|
|
|
|
commands.clear();
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", name,
|
|
|
|
depends, commands, true);
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
// Add rules to prepare the target for installation.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gtarget->NeedRelinkBeforeInstall(lg->GetConfigName())) {
|
2015-10-15 01:12:53 +03:00
|
|
|
localName = lg->GetRelativeTargetDirectory(gtarget);
|
2007-05-22 18:24:59 +04:00
|
|
|
localName += "/preinstall";
|
2006-05-02 17:56:42 +04:00
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), localName));
|
2010-11-12 00:02:07 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Pre-install relink rule for target.", localName,
|
|
|
|
depends, commands, true);
|
2007-08-03 23:44:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
|
2007-08-03 23:44:25 +04:00
|
|
|
depends.clear();
|
|
|
|
depends.push_back(localName);
|
|
|
|
commands.clear();
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
|
|
|
|
"preinstall", depends, commands, true);
|
2006-02-16 23:19:00 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2007-05-22 18:24:59 +04:00
|
|
|
// add the clean rule
|
2015-10-15 01:12:53 +03:00
|
|
|
localName = lg->GetRelativeTargetDirectory(gtarget);
|
2007-05-22 18:24:59 +04:00
|
|
|
makeTargetName = localName;
|
|
|
|
makeTargetName += "/clean";
|
|
|
|
depends.clear();
|
|
|
|
commands.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
commands.push_back(
|
|
|
|
lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
|
2007-05-22 18:24:59 +04:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
|
2014-03-11 03:04:11 +04:00
|
|
|
makeTargetName, depends, commands, true);
|
2007-05-22 18:24:59 +04:00
|
|
|
commands.clear();
|
|
|
|
depends.push_back(makeTargetName);
|
2016-05-16 17:34:04 +03:00
|
|
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.", "clean",
|
|
|
|
depends, commands, true);
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
|
|
|
|
2015-08-02 11:22:12 +03:00
|
|
|
// Build a map that contains a the set of targets used by each local
|
|
|
|
// generator directory level.
|
2015-08-02 11:23:12 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
|
2015-08-02 11:22:12 +03:00
|
|
|
{
|
2015-08-23 18:52:30 +03:00
|
|
|
this->DirectoryTargetsMap.clear();
|
2015-08-02 11:22:12 +03:00
|
|
|
// Loop over all targets in all local generators.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lgi =
|
|
|
|
this->LocalGenerators.begin();
|
|
|
|
lgi != this->LocalGenerators.end(); ++lgi) {
|
2015-08-02 11:22:12 +03:00
|
|
|
cmLocalGenerator* lg = *lgi;
|
2015-10-18 18:06:14 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
2015-10-18 18:06:14 +03:00
|
|
|
cmGeneratorTarget* gt = *t;
|
2015-08-02 11:22:12 +03:00
|
|
|
|
2015-08-02 11:39:19 +03:00
|
|
|
cmLocalGenerator* tlg = gt->GetLocalGenerator();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (gt->GetType() == cmState::INTERFACE_LIBRARY ||
|
|
|
|
gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
|
2015-08-02 11:39:19 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-02 11:39:19 +03:00
|
|
|
|
2015-08-02 11:41:55 +03:00
|
|
|
cmState::Snapshot csnp = lg->GetStateSnapshot();
|
|
|
|
cmState::Snapshot tsnp = tlg->GetStateSnapshot();
|
|
|
|
|
2015-08-02 11:22:12 +03:00
|
|
|
// Consider the directory containing the target and all its
|
|
|
|
// parents until something excludes the target.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; csnp.IsValid() && !this->IsExcluded(csnp, tsnp);
|
|
|
|
csnp = csnp.GetBuildsystemDirectoryParent()) {
|
2015-08-02 11:22:12 +03:00
|
|
|
// This local generator includes the target.
|
|
|
|
std::set<cmGeneratorTarget const*>& targetSet =
|
2015-08-02 11:41:55 +03:00
|
|
|
this->DirectoryTargetsMap[csnp];
|
2015-08-02 11:22:12 +03:00
|
|
|
targetSet.insert(gt);
|
|
|
|
|
|
|
|
// Add dependencies of the included target. An excluded
|
|
|
|
// target may still be included if it is a dependency of a
|
|
|
|
// non-excluded target.
|
|
|
|
TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (TargetDependSet::const_iterator ti = tgtdeps.begin();
|
|
|
|
ti != tgtdeps.end(); ++ti) {
|
2015-08-02 11:22:12 +03:00
|
|
|
targetSet.insert(*ti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-02 11:22:12 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget(
|
|
|
|
cmGeneratorTarget const* target, std::set<cmGeneratorTarget const*>& emitted)
|
2006-05-23 17:11:46 +04:00
|
|
|
{
|
2009-06-25 17:58:51 +04:00
|
|
|
size_t count = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emitted.insert(target).second) {
|
2015-10-21 20:51:50 +03:00
|
|
|
count = this->ProgressMap[target].Marks.size();
|
2015-06-06 14:08:17 +03:00
|
|
|
TargetDependSet const& depends = this->GetTargetDirectDepends(target);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (TargetDependSet::const_iterator di = depends.begin();
|
|
|
|
di != depends.end(); ++di) {
|
|
|
|
if ((*di)->GetType() == cmState::INTERFACE_LIBRARY) {
|
2012-11-02 18:47:40 +04:00
|
|
|
continue;
|
2006-08-29 20:55:11 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
count += this->CountProgressMarksInTarget(*di, emitted);
|
2006-05-23 17:11:46 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-06-25 17:58:51 +04:00
|
|
|
return count;
|
2006-05-23 17:11:46 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInAll(
|
|
|
|
cmLocalGenerator* lg)
|
2006-07-11 17:55:27 +04:00
|
|
|
{
|
2009-06-25 17:58:51 +04:00
|
|
|
size_t count = 0;
|
2015-06-06 16:24:24 +03:00
|
|
|
std::set<cmGeneratorTarget const*> emitted;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set<cmGeneratorTarget const*> const& targets =
|
|
|
|
this->DirectoryTargetsMap[lg->GetStateSnapshot()];
|
|
|
|
for (std::set<cmGeneratorTarget const*>::const_iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
2015-06-06 16:24:24 +03:00
|
|
|
count += this->CountProgressMarksInTarget(*t, emitted);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-06-25 17:58:51 +04:00
|
|
|
return count;
|
2006-07-11 17:55:27 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
|
2009-06-25 17:58:51 +04:00
|
|
|
cmMakefileTargetGenerator* tg)
|
|
|
|
{
|
2015-10-21 20:51:50 +03:00
|
|
|
TargetProgress& tp = this->ProgressMap[tg->GetGeneratorTarget()];
|
2009-06-25 17:58:51 +04:00
|
|
|
tp.NumberOfActions = tg->GetNumberOfProgressActions();
|
|
|
|
tp.VariableFile = tg->GetProgressFileNameFull();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
|
|
|
|
unsigned long total, unsigned long& current)
|
2009-06-25 17:58:51 +04:00
|
|
|
{
|
|
|
|
cmGeneratedFileStream fout(this->VariableFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 1; i <= this->NumberOfActions; ++i) {
|
2009-06-25 17:58:51 +04:00
|
|
|
fout << "CMAKE_PROGRESS_" << i << " = ";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (total <= 100) {
|
2009-06-25 17:58:51 +04:00
|
|
|
unsigned long num = i + current;
|
|
|
|
fout << num;
|
|
|
|
this->Marks.push_back(num);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (((i + current) * 100) / total >
|
|
|
|
((i - 1 + current) * 100) / total) {
|
|
|
|
unsigned long num = ((i + current) * 100) / total;
|
2009-06-25 17:58:51 +04:00
|
|
|
fout << num;
|
|
|
|
this->Marks.push_back(num);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
fout << "\n";
|
|
|
|
}
|
2009-06-25 17:58:51 +04:00
|
|
|
fout << "\n";
|
|
|
|
current += this->NumberOfActions;
|
|
|
|
}
|
2006-05-23 17:11:46 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends(
|
|
|
|
std::vector<std::string>& depends, cmGeneratorTarget* target)
|
2005-05-18 21:46:00 +04:00
|
|
|
{
|
2008-01-30 20:04:38 +03:00
|
|
|
TargetDependSet const& depends_set = this->GetTargetDirectDepends(target);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (TargetDependSet::const_iterator i = depends_set.begin();
|
|
|
|
i != depends_set.end(); ++i) {
|
2007-12-22 21:08:26 +03:00
|
|
|
// Create the target-level dependency.
|
2015-06-06 14:08:17 +03:00
|
|
|
cmGeneratorTarget const* dep = *i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dep->GetType() == cmState::INTERFACE_LIBRARY) {
|
2012-11-02 18:47:40 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-23 23:03:42 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* lg3 =
|
2015-06-06 14:08:17 +03:00
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(dep->GetLocalGenerator());
|
2015-10-15 01:12:53 +03:00
|
|
|
std::string tgtName =
|
2016-05-16 17:34:04 +03:00
|
|
|
lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep));
|
2005-10-10 19:49:17 +04:00
|
|
|
tgtName += "/all";
|
|
|
|
depends.push_back(tgtName);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-18 21:46:00 +04:00
|
|
|
}
|
2005-05-20 19:01:21 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
|
|
|
|
std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
|
2005-05-20 19:01:21 +04:00
|
|
|
{
|
|
|
|
// add the help target
|
|
|
|
std::string path;
|
|
|
|
std::vector<std::string> no_depends;
|
|
|
|
std::vector<std::string> commands;
|
2016-05-16 17:34:04 +03:00
|
|
|
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");
|
2010-11-12 00:02:07 +03:00
|
|
|
|
2005-06-01 17:25:10 +04:00
|
|
|
// Keep track of targets already listed.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> emittedTargets;
|
2005-06-01 17:25:10 +04:00
|
|
|
|
2005-05-20 19:01:21 +04:00
|
|
|
// for each local generator
|
|
|
|
unsigned int i;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* lg2;
|
|
|
|
for (i = 0; i < this->LocalGenerators.size(); ++i) {
|
2010-11-12 00:02:07 +03:00
|
|
|
lg2 =
|
2016-05-16 17:34:04 +03:00
|
|
|
static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
|
2005-10-20 21:40:28 +04:00
|
|
|
// for the passed in makefile or if this is the top Makefile wripte out
|
|
|
|
// the targets
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lg2 == lg || lg->IsRootMakefile()) {
|
2005-10-20 21:40:28 +04:00
|
|
|
// for each target Generate the rule files for each target.
|
2015-10-18 18:06:14 +03:00
|
|
|
std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
|
|
|
|
t != targets.end(); ++t) {
|
2015-10-18 18:06:14 +03:00
|
|
|
cmGeneratorTarget* target = *t;
|
|
|
|
cmState::TargetType type = target->GetType();
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((type == cmState::EXECUTABLE) ||
|
|
|
|
(type == cmState::STATIC_LIBRARY) ||
|
|
|
|
(type == cmState::SHARED_LIBRARY) ||
|
|
|
|
(type == cmState::MODULE_LIBRARY) ||
|
|
|
|
(type == cmState::OBJECT_LIBRARY) ||
|
|
|
|
(type == cmState::GLOBAL_TARGET) || (type == cmState::UTILITY)) {
|
2015-10-18 18:06:14 +03:00
|
|
|
std::string name = target->GetName();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (emittedTargets.insert(name).second) {
|
2005-10-20 21:40:28 +04:00
|
|
|
path = "... ";
|
2014-02-25 05:31:04 +04:00
|
|
|
path += name;
|
2016-05-26 23:52:22 +03:00
|
|
|
lg->AppendEcho(commands, path);
|
2005-06-01 17:25:10 +04:00
|
|
|
}
|
2005-05-20 19:01:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> const& localHelp = lg->GetLocalHelp();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator o = localHelp.begin();
|
|
|
|
o != localHelp.end(); ++o) {
|
2008-06-06 18:22:51 +04:00
|
|
|
path = "... ";
|
|
|
|
path += *o;
|
2016-05-26 23:52:22 +03:00
|
|
|
lg->AppendEcho(commands, path);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
lg->WriteMakeRule(ruleFileStream, "Help Target", "help", no_depends,
|
|
|
|
commands, true);
|
2005-05-20 19:01:21 +04:00
|
|
|
ruleFileStream << "\n\n";
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmGlobalUnixMakefileGenerator3::NeedRequiresStep(
|
|
|
|
const cmGeneratorTarget* target)
|
2005-05-24 19:17:30 +04:00
|
|
|
{
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> languages;
|
2016-05-16 17:34:04 +03:00
|
|
|
target->GetLanguages(
|
|
|
|
languages,
|
|
|
|
target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
|
|
|
for (std::set<std::string>::const_iterator l = languages.begin();
|
|
|
|
l != languages.end(); ++l) {
|
2007-08-03 17:39:32 +04:00
|
|
|
std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
|
|
|
|
var += *l;
|
|
|
|
var += "_FLAG";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (target->Target->GetMakefile()->GetDefinition(var)) {
|
2005-05-24 19:17:30 +04:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-24 19:17:30 +04:00
|
|
|
return false;
|
|
|
|
}
|