Makefile: Allow "gmake target1 target2 -j" (#14312)
Add the .NOTPARALLEL target to each local Makefile command-line interface entry point file so that even with -j we launch only one "make -f Makefile2" at a time. The actual build rules in Makefile2 and lower will still run in parallel. Do not add .NOTPARALLEL for Borland or Watcom make tools because they do not tolerate it. Other make tools that do not understand .NOTPARALLEL will not be hurt. Suggested-by: Robert Luberda <robert-cmake@debian.org>
This commit is contained in:
parent
2a384e08cc
commit
bd11de0857
|
@ -44,6 +44,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||||
cmMakefile *, bool optional);
|
cmMakefile *, bool optional);
|
||||||
|
|
||||||
|
virtual bool AllowNotParallel() const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -125,6 +125,9 @@ public:
|
||||||
const std::string &workingDirectory,
|
const std::string &workingDirectory,
|
||||||
const std::string &compileCommand);
|
const std::string &compileCommand);
|
||||||
|
|
||||||
|
/** Does the make tool tolerate .NOTPARALLEL? */
|
||||||
|
virtual bool AllowNotParallel() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void WriteMainMakefile2();
|
void WriteMainMakefile2();
|
||||||
void WriteMainCMakefile();
|
void WriteMainCMakefile();
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||||
cmMakefile *, bool optional);
|
cmMakefile *, bool optional);
|
||||||
|
|
||||||
|
virtual bool AllowNotParallel() const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1686,6 +1686,17 @@ void cmLocalUnixMakefileGenerator3
|
||||||
"default_target",
|
"default_target",
|
||||||
depends,
|
depends,
|
||||||
no_commands, true);
|
no_commands, true);
|
||||||
|
|
||||||
|
// Help out users that try "gmake target1 target2 -j".
|
||||||
|
cmGlobalUnixMakefileGenerator3* gg =
|
||||||
|
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
|
||||||
|
if(gg->AllowNotParallel())
|
||||||
|
{
|
||||||
|
std::vector<std::string> no_depends;
|
||||||
|
this->WriteMakeRule(ruleFileStream,
|
||||||
|
"Allow only one \"make -f Makefile2\" at a time, but pass parallelism.",
|
||||||
|
".NOTPARALLEL", no_depends, no_commands, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->WriteSpecialTargetsTop(ruleFileStream);
|
this->WriteSpecialTargetsTop(ruleFileStream);
|
||||||
|
|
Loading…
Reference in New Issue