Ninja: don't use cmcldeps for try_compile
This commit is contained in:
parent
7553a3799a
commit
db607dea8d
|
@ -331,13 +331,25 @@ cmNinjaTargetGenerator
|
|||
vars.TargetPDB = "$TARGET_PDB";
|
||||
|
||||
cmMakefile* mf = this->GetMakefile();
|
||||
bool useClDeps = false;
|
||||
const char* clDepsBinary = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
|
||||
const char* clShowPrefix = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
|
||||
const char* projectName = mf->GetProjectName();
|
||||
if (clDepsBinary && clShowPrefix)
|
||||
{
|
||||
useClDeps = true;
|
||||
if (projectName && std::string(projectName) == "CMAKE_TRY_COMPILE")
|
||||
{
|
||||
// don't wrap for try_compile, TODO but why doesn't it work with cmcldeps?
|
||||
useClDeps = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string depfile;
|
||||
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
|
||||
const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str());
|
||||
if (depfileFlags || (clDepsBinary && clShowPrefix)) {
|
||||
if (depfileFlags || useClDeps) {
|
||||
std::string depfileFlagsStr = depfileFlags ? depfileFlags : "";
|
||||
depfile = "$out.d";
|
||||
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
||||
|
@ -366,7 +378,7 @@ cmNinjaTargetGenerator
|
|||
std::string cmdLine =
|
||||
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
||||
|
||||
if(clDepsBinary && clShowPrefix)
|
||||
if(useClDeps)
|
||||
{
|
||||
std::string prefix = clShowPrefix;
|
||||
cmdLine = "\"" + std::string(clDepsBinary) + "\" $in $out.d $out \"" + prefix + "\" " + cmdLine;
|
||||
|
|
|
@ -52,6 +52,8 @@ struct Subprocess {
|
|||
|
||||
const string& GetOutput() const;
|
||||
|
||||
int ExitCode() const { return exit_code_; }
|
||||
|
||||
private:
|
||||
Subprocess();
|
||||
bool Start(struct SubprocessSet* set, const string& command);
|
||||
|
@ -69,6 +71,7 @@ struct Subprocess {
|
|||
OVERLAPPED overlapped_;
|
||||
char overlapped_buf_[4 << 10];
|
||||
bool is_reading_;
|
||||
int exit_code_;
|
||||
#else
|
||||
int fd_;
|
||||
pid_t pid_;
|
||||
|
@ -189,7 +192,7 @@ void Win32Fatal(const char* function) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
Subprocess::Subprocess() : child_(NULL) , overlapped_(), is_reading_(false) {
|
||||
Subprocess::Subprocess() : child_(NULL) , overlapped_(), is_reading_(false), exit_code_(1) {
|
||||
}
|
||||
|
||||
Subprocess::~Subprocess() {
|
||||
|
@ -338,7 +341,7 @@ ExitStatus Subprocess::Finish() {
|
|||
|
||||
CloseHandle(child_);
|
||||
child_ = NULL;
|
||||
|
||||
exit_code_ = exit_code;
|
||||
return exit_code == 0 ? ExitSuccess :
|
||||
exit_code == CONTROL_C_EXIT ? ExitInterrupted :
|
||||
ExitFailure;
|
||||
|
@ -606,8 +609,9 @@ int main() {
|
|||
}
|
||||
|
||||
bool success = subproc->Finish() == ExitSuccess;
|
||||
string output = subproc->GetOutput();
|
||||
int exit_code = subproc->ExitCode();
|
||||
|
||||
string output = subproc->GetOutput();
|
||||
delete subproc;
|
||||
|
||||
// process the include directives and output everything else
|
||||
|
@ -635,7 +639,7 @@ int main() {
|
|||
}
|
||||
|
||||
if (!success)
|
||||
return 3;
|
||||
return exit_code;
|
||||
|
||||
// don't update .d until/unless we succeed compilation
|
||||
outputDepFile(dfile, objfile, includes);
|
||||
|
|
Loading…
Reference in New Issue