aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-03-23 23:57:05 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-03-24 00:04:22 +0300
commit7a48deafe7615392b458681bd23e6136ed20deb6 (patch)
treef49550c23d0858632bfc96f614e6d71b90598293 /project
parentproject.utils: log to stdout, not stderr (diff)
downloadcmake-common-7a48deafe7615392b458681bd23e6136ed20deb6.tar.gz
cmake-common-7a48deafe7615392b458681bd23e6136ed20deb6.zip
project.cmake: set CMAKE_BUILD_PARALLEL_LEVEL
Diffstat (limited to 'project')
-rw-r--r--project/cmake/build.py9
-rw-r--r--project/cmake/toolchain.py2
-rw-r--r--project/utils.py4
3 files changed, 11 insertions, 4 deletions
diff --git a/project/cmake/build.py b/project/cmake/build.py
index 9f9bc00..20c823f 100644
--- a/project/cmake/build.py
+++ b/project/cmake/build.py
@@ -39,8 +39,15 @@ DEFAULT_CONFIGURATION = Configuration.DEBUG
DEFAULT_TOOLSET = ToolchainType.AUTO
+# This way of basically passing `-j` to make is more universal compared to
+# _guessing_ that the build system is make and passing -j explicitly. Plus it
+# works with older CMake versions, which don't support the --parallel flag.
+cmake_env = os.environ.copy()
+cmake_env['CMAKE_BUILD_PARALLEL_LEVEL'] = str(os.cpu_count())
+
+
def run_cmake(cmake_args):
- return run(['cmake'] + cmake_args)
+ return run(['cmake'] + cmake_args, env=cmake_env)
class GenerationPhase:
diff --git a/project/cmake/toolchain.py b/project/cmake/toolchain.py
index 3311d04..af3da21 100644
--- a/project/cmake/toolchain.py
+++ b/project/cmake/toolchain.py
@@ -72,7 +72,7 @@ class MSVC(Auto):
return ['-A', self.platform.msvc_arch()]
def build_system_args(self):
- return ['/m']
+ return []
class Makefile(Toolchain):
diff --git a/project/utils.py b/project/utils.py
index 868592a..f40767a 100644
--- a/project/utils.py
+++ b/project/utils.py
@@ -47,9 +47,9 @@ def cd(path):
os.chdir(cwd)
-def run(cmd_line):
+def run(cmd_line, **kwargs):
logging.info('Running executable: %s', cmd_line)
- return subprocess.run(cmd_line, check=True)
+ return subprocess.run(cmd_line, check=True, **kwargs)
@contextmanager