Commit d0425627 authored by Alexander Dielen's avatar Alexander Dielen
Browse files

build with ninja if available

parent 58c235dc
Pipeline #6128 passed with stage
in 1 minute and 33 seconds
......@@ -31,6 +31,22 @@ class CMakeBuild(build_ext):
for ext in self.extensions:
def which(program, env=os.environ):
def isExe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if isExe(program):
return program
for path in env.get("PATH", "").split(os.pathsep):
path = path.strip("\"")
exe = os.path.join(path, program)
if isExe(exe):
return exe
return None
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
......@@ -51,6 +67,10 @@ class CMakeBuild(build_ext):
env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
if self.which('ninja', env) != None:
cmake_args += ['-GNinja']
if not os.path.exists(self.build_temp):
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment