aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-08-21 10:39:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-08-21 10:39:22 +0200
commit7c7cd5c27bd92e5b837c33edb97fa3f0a0d9ad79 (patch)
tree0d577a9d3224a22b23bbbb2dc98376ce19096f66 /build2/cc
parentfe55b14b627ad4d832261c68ea24d37d513e834e (diff)
Unset CL and _CL_ environment variables when detecting MSVC
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/guess.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/build2/cc/guess.cxx b/build2/cc/guess.cxx
index 89030b5..e9b102f 100644
--- a/build2/cc/guess.cxx
+++ b/build2/cc/guess.cxx
@@ -451,7 +451,16 @@ namespace build2
return guess_result ();
};
- r = run<guess_result> (3, xp, f, false);
+ // One can pass extra options/arguments to cl.exe with the CL and _CL_
+ // environment variables. However, if such extra options are passed
+ // without anything to compile, then cl.exe no longer prints usage and
+ // exits successfully but instead issues an error and fails. So we are
+ // going to unset these variables for our test (interestingly, only CL
+ // seem to cause the problem but let's unset both, for good measure).
+ //
+ const char* env[] = {"CL=", "_CL_=", nullptr};
+
+ r = run<guess_result> (3, process_env (xp, env), f, false);
}
if (!r.empty ())