ProcessorCount returns unexpected value with cmake-3.15+
After upgrading to cmake-3.15.5, I noticed that ProcessorCount
was returning unexpected values. Comparing this function between 3.14.3 and 3.15.5, I see that coding was added to use nproc
to report the total number of cores. Unfortunately, this tool doesn't always return the number of cores. According to https://www.gnu.org/software/coreutils/manual/coreutils.html#nproc-invocation, if either or both of the environment variables OMP_NUM_THREADS
or OMP_THREAD_LIMIT
are set, then this tool will return those values. I would recommend that the command nproc --all
be used instead of nproc
with arguments.
Example:
$ nproc
40
$ export OMP_NUM_THREADS=8
$ nproc
8
$ nproc --all
40