From 4b2759c268d402784cb5674b24a1e549a3f9cbfb Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 28 Feb 2020 12:13:38 -0500 Subject: [PATCH] cmake: prefer ninja when available --- grwave/base.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/grwave/base.py b/grwave/base.py index b1a246e..c2dc38a 100644 --- a/grwave/base.py +++ b/grwave/base.py @@ -1,6 +1,7 @@ from pathlib import Path import subprocess import io +import os import pandas as pd import numpy as np import shutil @@ -12,12 +13,19 @@ TXW0 = 1e3 # ITU assumes 1kW power CORR = 0.5 +ninja = shutil.which("ninja") + grwave_exe = shutil.which("grwave.bin", path=str(build_dir)) if not grwave_exe: if shutil.which("cmake"): - subprocess.run(["cmake", "-S", str(src_dir), "-B", str(build_dir)]) + opts = [] + if ninja: + opts = ["-G", "Ninja"] + elif os.name == "nt": + opts = ["-G", "MinGW Makefiles", "-DCMAKE_SH=CMAKE_SH-NOTFOUND"] + subprocess.run(["cmake", "-S", str(src_dir), "-B", str(build_dir)] + opts) subprocess.run(["cmake", "--build", str(build_dir)]) - elif shutil.which("meson") and shutil.which("ninja"): + elif shutil.which("meson") and ninja: subprocess.run(["meson", str(src_dir), str(build_dir)]) subprocess.run(["ninja", "-C", str(build_dir)]) grwave_exe = shutil.which("grwave.bin", path=str(build_dir))