From db607dea8dbb0d16e75e5ae1e764002e4ce8e605 Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Sat, 9 Jun 2012 13:52:20 +0200 Subject: Ninja: don't use cmcldeps for try_compile --- Source/cmNinjaTargetGenerator.cxx | 16 ++++++++++++++-- Source/cmcldeps.cxx | 12 ++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 75b3929..40fdc8b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -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, "", @@ -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; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 48f2cfd..d6cafc5 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -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); -- cgit v0.12