@@ -16,6 +16,7 @@ CMAKE_CONFIGURE_EXTRA_ARGS ?=
1616CMAKE_BUILD_EXTRA_ARGS ?=
1717# gcc or clang
1818COMPILER ?= gcc
19+ NUM_JOBS ?= $(shell echo $$(( $$(nproc ) / 2 ) ) )
1920
2021ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
2122
@@ -28,6 +29,7 @@ DOCS_PRESET := unixlike-docs-only
2829
2930SRC_ENV := if [ -f "$(ROOT_DIR ) /.env" ]; then export $$(cat "$(ROOT_DIR ) /.env" | xargs ) ; echo "Set enviornment variables:"; sed -E 's/=.*//' "$(ROOT_DIR ) /.env"; echo; fi
3031
32+
3133default : help
3234
3335# #### --- snipped from gh:compiler-explorer/compiler-explorer/blob/main/Makefile
@@ -64,34 +66,34 @@ build: build-debug ## alias for build-debug
6466
6567.PHONY : build-debug
6668build-debug : configure-debug # # build in debug mode
67- @$(SRC_ENV ) && cmake --build --preset $(DEBUG_PRESET ) $(CMAKE_BUILD_EXTRA_ARGS )
69+ @$(SRC_ENV ) && cmake --build --preset $(DEBUG_PRESET ) $(CMAKE_BUILD_EXTRA_ARGS ) -j $( NUM_JOBS )
6870
6971.PHONY : build-release
7072build-release : configure-release # # build in release mode (with debug info)
71- @$(SRC_ENV ) && cmake --build --preset $(RELEASE_PRESET ) $(CMAKE_BUILD_EXTRA_ARGS )
73+ @$(SRC_ENV ) && cmake --build --preset $(RELEASE_PRESET ) $(CMAKE_BUILD_EXTRA_ARGS ) -j $( NUM_JOBS )
7274
7375.PHONY : build-docs
7476build-docs : configure-docs # # build in release mode (with debug info)
75- @$(SRC_ENV ) && cmake --build --preset $(DOCS_PRESET ) $(CMAKE_BUILD_EXTRA_ARGS )
77+ @$(SRC_ENV ) && cmake --build --preset $(DOCS_PRESET ) $(CMAKE_BUILD_EXTRA_ARGS ) -j $( NUM_JOBS )
7678
7779.PHONY : build-tests-debug
7880build-tests-debug : configure-debug
79- @$(SRC_ENV ) && cmake --build --preset $(DEBUG_PRESET ) --target asmgrader_tests $(CMAKE_BUILD_EXTRA_ARGS )
81+ @$(SRC_ENV ) && cmake --build --preset $(DEBUG_PRESET ) --target asmgrader_tests $(CMAKE_BUILD_EXTRA_ARGS ) -j $( NUM_JOBS )
8082
8183.PHONY : build-tests-release
8284build-tests-release : configure-release
83- @$(SRC_ENV ) && cmake --build --preset $(RELEASE_PRESET ) --target asmgrader_tests $(CMAKE_BUILD_EXTRA_ARGS )
85+ @$(SRC_ENV ) && cmake --build --preset $(RELEASE_PRESET ) --target asmgrader_tests $(CMAKE_BUILD_EXTRA_ARGS ) -j $( NUM_JOBS )
8486
8587.PHONY : test
8688test : test-debug # # alias for test-debug
8789
8890.PHONY : test-debug
8991test-debug : build-tests-debug # # run tests in debug mode
90- @$(SRC_ENV ) && ctest --preset $(DEBUG_PRESET ) --progress --output-on-failure --no-tests=error $(CTEST_EXTRA_ARGS )
92+ @$(SRC_ENV ) && ctest --preset $(DEBUG_PRESET ) --progress --output-on-failure --no-tests=error $(CTEST_EXTRA_ARGS ) -j $( NUM_JOBS )
9193
9294.PHONY : test-release
9395test-release : build-tests-release # # run tests in release mode
94- @$(SRC_ENV ) && ctest --preset $(RELEASE_PRESET ) --progress --output-on-failure --no-tests=error $(CTEST_EXTRA_ARGS )
96+ @$(SRC_ENV ) && ctest --preset $(RELEASE_PRESET ) --progress --output-on-failure --no-tests=error $(CTEST_EXTRA_ARGS ) -j $( NUM_JOBS )
9597
9698
9799.PHONY : clean
@@ -107,8 +109,10 @@ deep-clean: ## remove all build files and configuration
107109
108110.PHONY : list-opts
109111list-opts : # # list available CMake options
110- @if ! cmake -S . -B build/ -LAH -N 2> /dev/null \
111- | grep ASMGRADER_ -B 1 \
112+ @if ! cmake -S . -B $(shell find build/ -maxdepth 1 -mindepth 1 | head -n1) -LAH -N 2> /dev/null \
113+ | grep ASMGRADER_ --before-context 1 --group-separator=' ' \
114+ | sed ' /\/\// { s/^/[34m/; s/$$/[0m/; }' \
115+ | sed ' /^\w/ { s/^/[32m/; s/:/[0m:/; }' \
112116 ; then \
113117 printf ' \033[31mError: CMake command failed. Is the project configured?\033[0m\n' ; \
114118 exit 1; \
0 commit comments