Skip to content

Commit d8ce23e

Browse files
authored
Use CMAKE_TOOLCHAIN_FILE environment variable earlier (#129)
1 parent 9af8515 commit d8ce23e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,14 @@ impl Config {
438438
};
439439
let host = self.host.clone().unwrap_or_else(|| getenv_unwrap("HOST"));
440440

441+
// Some decisions later on are made if CMAKE_TOOLCHAIN_FILE is defined,
442+
// so we need to read it from the environment variables from the beginning.
443+
if !self.defined("CMAKE_TOOLCHAIN_FILE") {
444+
if let Some(s) = self.getenv_target_os("CMAKE_TOOLCHAIN_FILE") {
445+
self.define("CMAKE_TOOLCHAIN_FILE", s);
446+
}
447+
}
448+
441449
let generator = self
442450
.generator
443451
.clone()
@@ -763,14 +771,6 @@ impl Config {
763771
cmd.arg("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON");
764772
}
765773

766-
if !self.defined("CMAKE_TOOLCHAIN_FILE") {
767-
if let Some(s) = self.getenv_target_os("CMAKE_TOOLCHAIN_FILE") {
768-
let mut cmake_toolchain_file = OsString::from("-DCMAKE_TOOLCHAIN_FILE=");
769-
cmake_toolchain_file.push(&s);
770-
cmd.arg(cmake_toolchain_file);
771-
}
772-
}
773-
774774
for &(ref k, ref v) in c_compiler.env().iter().chain(&self.env) {
775775
cmd.env(k, v);
776776
}

0 commit comments

Comments
 (0)