summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-09 11:52:20 (GMT)
committerPeter Kuemmel <syntheticpp@gmx.net>2012-06-09 12:12:11 (GMT)
commitdb607dea8dbb0d16e75e5ae1e764002e4ce8e605 (patch)
tree04cbcb2e2f9e33c5b2d4013992c2364590ac7ae4
parent7553a3799a188594ee0bda46b18095479e3ee54b (diff)
downloadCMake-db607dea8dbb0d16e75e5ae1e764002e4ce8e605.zip
CMake-db607dea8dbb0d16e75e5ae1e764002e4ce8e605.tar.gz
CMake-db607dea8dbb0d16e75e5ae1e764002e4ce8e605.tar.bz2
Ninja: don't use cmcldeps for try_compile
-rw-r--r--Source/cmNinjaTargetGenerator.cxx16
-rw-r--r--Source/cmcldeps.cxx12
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, "<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;
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);