Skip to content

Instantly share code, notes, and snippets.

@ArtemGr ArtemGr/cmake.rs
Last active Oct 7, 2016

Embed
What would you like to do?
cmake.rs - Use a proper generator under CLion
// [build] rustc -O cmake.rs
// cf. https://youtrack.jetbrains.com/issue/CPP-188#comment=27-899992
use std::env::args;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::Path;
use std::process::Command;
fn main() {
let mut command = Command::new ("C:/spool/msys64/mingw64/bin/cmake.exe");
command.env ("PATH", "C:/spool/msys64/usr/bin;C:/spool/msys64/mingw64/bin");
let mut log = match OpenOptions::new().append (true) .open (&Path::new (r"c:\spool\bin\cmake.log")) {
Ok (file) => file, Err (err) => panic! ("Can't open the log file: {}", err)};
let _ = writeln! (log, "--- Another run -------");
let mut generator_override = true;
for arg in args().skip (1) {
let _ = writeln! (log, "Got an arg: {}", arg);
if arg == "--build" {generator_override = false}
command.arg (arg);}
if generator_override {
command.arg ("-GMSYS Makefiles");} // Override CLion macabre silliness.
let status = command.status().expect ("!cmake");
std::process::exit (status.code().expect ("!status"));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.