diff options
author | Brad King <brad.king@kitware.com> | 2019-03-01 13:52:08 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-01 13:52:37 (GMT) |
commit | 0465c32a82f4da7745294edb1b0efe50ca66e15c (patch) | |
tree | 19942399e283eb40f1036a2cafe57a35ebd0a9f6 /Modules | |
parent | 9a5fe96f4fb8b5fbc39f8a01a388cf428ffaed32 (diff) | |
parent | f20eab9cdc26ffbacb32e5942e2969058e50581a (diff) | |
download | CMake-0465c32a82f4da7745294edb1b0efe50ca66e15c.zip CMake-0465c32a82f4da7745294edb1b0efe50ca66e15c.tar.gz CMake-0465c32a82f4da7745294edb1b0efe50ca66e15c.tar.bz2 |
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
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/ProcessorCount.cmake | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index e4b4e53..8c25256 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -70,6 +70,20 @@ function(ProcessorCount var) 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) mark_as_advanced(ProcessorCount_cmd_getconf) |