mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-27 19:28:37 -06:00
Merge topic 'processor_count_linux_containers'
f20eab9cdc ProcessorCount: Return the container CPU count instead of the host count
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3032
This commit is contained in:
@@ -69,6 +69,20 @@ function(ProcessorCount var)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT count)
|
||||
# Linux (systems with nproc):
|
||||
# Prefer nproc to getconf if available as getconf may return the host CPU count in Linux containers
|
||||
find_program(ProcessorCount_cmd_nproc nproc)
|
||||
mark_as_advanced(ProcessorCount_cmd_nproc)
|
||||
if(ProcessorCount_cmd_nproc)
|
||||
execute_process(COMMAND ${ProcessorCount_cmd_nproc}
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
OUTPUT_VARIABLE count)
|
||||
#message("ProcessorCount: trying nproc '${ProcessorCount_cmd_nproc}'")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT count)
|
||||
# Linux (systems with getconf):
|
||||
find_program(ProcessorCount_cmd_getconf getconf)
|
||||
|
||||
Reference in New Issue
Block a user