Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #256 from tserong/wip-workaround-qemu-zero-cpu-cores
Browse files Browse the repository at this point in the history
cmake: workaround _num_cores being 0 under qemu emulation
  • Loading branch information
tserong authored Nov 23, 2023
2 parents 9dcbde6 + b666926 commit e5de266
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmake/modules/LimitJobs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ set(MAX_COMPILE_MEM 3500 CACHE INTERNAL "maximum memory used by each compiling j
set(MAX_LINK_MEM 4500 CACHE INTERNAL "maximum memory used by each linking job (in MiB)")

cmake_host_system_information(RESULT _num_cores QUERY NUMBER_OF_LOGICAL_CORES)
# This will never be zero on a real system, but it can be if you're doing
# weird things like trying to cross-compile using qemu emulation.
if(_num_cores EQUAL 0)
set(_num_cores 1)
endif()
cmake_host_system_information(RESULT _total_mem QUERY TOTAL_PHYSICAL_MEMORY)

math(EXPR _avg_compile_jobs "${_total_mem} / ${MAX_COMPILE_MEM}")
Expand Down

0 comments on commit e5de266

Please sign in to comment.