Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Modules/NProc.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This CMake module returns the result of 'nproc' (or its equivalent on Apple).
# The newline is trimmed from the result using the `tr -d '\n'` command.

if(APPLE)
execute_process(COMMAND sysctl -n hw.logicalcpu OUTPUT_VARIABLE NPROC)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# When CMake 3.25 is mandated, we can use elseif(LINUX)
execute_process(COMMAND nproc OUTPUT_VARIABLE NPROC)
execute_process(COMMAND sysctl -n hw.logicalcpu COMMAND tr -d '\n' OUTPUT_VARIABLE NPROC)
elseif(LINUX)
execute_process(COMMAND nproc COMMAND tr -d '\n' OUTPUT_VARIABLE NPROC)
endif()
2 changes: 1 addition & 1 deletion test/max-parallelism/check_parallelism_default.jsonnet.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
modules: {
verify: {
cpp: 'check_parallelism',
expected_parallelism: '@NPROC@',
expected_parallelism: @NPROC@,
},
},
}
Loading