You are right as already given here: Cmake parallel build
however @ProTur1 is seeking a CMake variable to be set in CMakeLists.txt not an environment variable.
I don’t personally know why this feature does not exist, may be you can try to implement it and see by yourself.
My very personal opinion is that I don’t want the provider of a project to enforce a level of parallelism on my build, if want to build with full parallelism I use ninja generator. If I want to chose a constrained parallelism I build with cmake --build --parallel <myChoice>.
The level of parallelism I want depends on various thing the developer of the project cannot know:
Am I building on my dev machine or in CI ?
Is my dev machine equipped with 4, 8 or 32 cores?
Is the build machine dedicated to that build or shall this build be a background activity which leaves enough computing power/RAM/disk activities etc… to other processes ?
So I don’t know why this feature does not exist but my personal opinion is AFAIK I won’t need it anytime soon.
May be you could explain why, in your point of view this is a desirable/useful feature?
From all the unknowns you mentioned, the cores can also be identified easily. From them, I would like to use only a part of it (although even if fully parallel, the OS scheduler should do its jobs well done as well).
Why it is useful?
for people who want to compile foreign projects, and don’t have time or don’t want to configure and type manually
for pushing to a build server, without command arguments for the build
because it is easily possible to be realized (cmake offers anyhow a whole universe of functionality already)