Skip to content

Commit ce77ae0

Browse files
authored
parallel builds (if cmake 3.12+) (#200)
1 parent d06e5c7 commit ce77ae0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

setup.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import os.path
99
import platform
10+
import re
1011
import setuptools
1112
import setuptools.command.build_ext
1213
import shutil
@@ -90,6 +91,20 @@ def get_cmake_path():
9091
raise Exception("CMake must be installed to build from source.")
9192

9293

94+
cmake_version = None
95+
96+
97+
def get_cmake_version():
98+
global cmake_version
99+
if cmake_version:
100+
return cmake_version
101+
cmake = get_cmake_path()
102+
stdout = subprocess.check_output([cmake, '--version']).decode('utf-8')
103+
# output looks like: "cmake version 3.18.2\n\nCMake suite maintained ..."
104+
match = re.search(r'([0-9]+)\.([0-9]+)\.([0-9]+)', stdout)
105+
return (int(match.group(1)), int(match.group(2)), int(match.group(3)))
106+
107+
93108
def get_libcrypto_static_library(libcrypto_dir):
94109
lib_path = os.path.join(libcrypto_dir, 'lib64', 'libcrypt')
95110
if is_64bit() and os.path.exists(lib_path):
@@ -203,6 +218,8 @@ def _build_dependency(self, aws_lib, libcrypto_paths):
203218
'--config', build_type,
204219
'--target', 'install',
205220
]
221+
if get_cmake_version() >= (3, 12):
222+
build_cmd += ['--parallel']
206223
print(subprocess.list2cmdline(build_cmd))
207224
subprocess.check_call(build_cmd)
208225

0 commit comments

Comments
 (0)