conan-io / docs

conan.io reStructuredText documentation
http://docs.conan.io
MIT License
110 stars 362 forks source link

CTEST parallel mode enabled if CMake builds in parallel #1096

Open kalman5 opened 5 years ago

kalman5 commented 5 years ago

We are in the process to upgrade from 1.10 to 1.12

I saw from documentation if CMake help builder was constructed (it is by default) using parallel=True then the CTest runs tests in parallel mode as well.

I believe this is an oversight, you should put in CMake.test(...) a new variable that will pass -j to Ctest and not linking the two options build in parallel then tests in parallel.

danimtb commented 5 years ago

Hi @kalman5,

Thanks a lot for the feedback. Indeed this looks like an oversight as the test() method was implemented later after the build() one.

I have taken a look at the source code and it seems the parallel is affecting test() setting up the variable CTEST_PARALLEL_LEVEL and it could be changed like this:

cmake = CMake(self)
cmake.build()  # 'parallel' is enabled by default
cmake.parallel = False
cmake.test()

However, this parallel flag is not documented as an attribute here https://docs.conan.io/en/latest/reference/build_helpers/cmake.html

Will try to at least document this. Thanks!

danimtb commented 5 years ago

Finally transferred this to the documentation repository.

Here is the explanation:

The parallel parameter in the CMake constructor is indeed an attribute that can be modified later.

This is not documented as an attribute here https://docs.conan.io/en/latest/reference/build_helpers/cmake.html

Important: This parameter affects the definitions construction in https://github.com/conan-io/conan/blob/a52dcdc87dd8146b661ed650da616b9fcd2371e3/conans/client/build/cmake_flags.py#L258