Open LecrisUT opened 11 months ago
@LecrisUT did you consider using jobs
property in build and test presets of CMakePresets.json
?
Yes, but there is no macro expansion from cmake to get the $(nproc)
dynamically. Also jobs
value takes precedence so it should be safe to set is as a default
@LecrisUT The cmake
invocation could be customized to satisfy any additional needs with the usage of the *AdditionalArgs
and *CmdString
inputs.
If those inputs are not enough, contribution to this project are welcome.
Yes, but $(nproc)
is a bit tricky because it is not a static variable: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
But this should be a simple enough addition I can write it up
@LecrisUT I am trying to understand which problem we are trying to solve. When defining the value of CMAKE_BUILD_PARALLEL_LEVEL
is going to be useful? I'd expect that delegating the choice to the current build tool is always the best choice because it should be able to utilize all the cpu available cycles, by default. For example, when using cmake
and ninja
, there is no need to specify any special additional value to ensure the build is as fast as possible on the system it is running on.
Could you show some workflows on GH which gives good use of such variable?
For CMAKE_BUILD_PARALLEL_LEVEL
it is more confusing than the test one. If we look at the -j
documentation, there are a few caveats:
ninja
and the OS defaults Unix makefile
, and vscode
, xcode
? I have encountered situations where the CMake was generator dependent so probably the user's CI can be extensive.-j
without value to specify to build in maximum parallel-j $(nproc)
explicitly? For those that have defaults, how is it calculated?-j
without valueSetting CMAKE_BUILD_PARALLEL_LEVEL
seems the most general way of solving this, even though it might not be as efficient as the automatic.
About the preset options, these options are available, but:
null
in order to pass a -j
without value$(nproc)
The action should set the following environment variables, especially when presets are used:
(effectively running
cmake --build -j $(nproc)
andctest -j $(nproc)
)These could be controlled by: