1# cmake {#cmake} 2 3Overrides the default configure phase to run the CMake command. 4 5By default, we use the Make generator of CMake. 6But when Ninja is also available as a `nativeBuildInput`, this setup hook will detect that and use the ninja generator. 7 8Dependencies are added automatically to `CMAKE_PREFIX_PATH` so that packages are correctly detected by CMake. 9Some additional flags are passed in to give similar behavior to configure-based packages. 10 11By default, parallel building is enabled as CMake supports parallel building almost everywhere. 12 13You can disable this hook’s behavior by setting `configurePhase` to a custom value, or by setting `dontUseCmakeConfigure`. 14 15## Variables controlling CMake {#cmake-variables-controlling} 16 17### CMake Exclusive Variables {#cmake-exclusive-variables} 18 19#### `cmakeFlags` {#cmake-flags} 20 21Controls the flags passed to `cmake setup` during configure phase. 22 23#### `cmakeBuildDir` {#cmake-build-dir} 24 25Directory where CMake will put intermediate files. 26 27Setting this can be useful for debugging multiple CMake builds while in the same source directory, for example, when building for different platforms. 28Different values for each build will prevent build artefacts from interefering with each other. 29This setting has no tangible effect when running the build in a sandboxed derivation. 30 31The default value is `build`. 32 33#### `dontUseCmakeConfigure` {#dont-use-cmake-configure} 34 35When set to true, don't use the predefined `cmakeConfigurePhase`. 36 37## Controlling CTest invocation {#cmake-ctest} 38 39By default tests are run by make in [`checkPhase`](#ssec-check-phase) or by [ninja](#ninja) if `ninja` is 40available in `nativeBuildInputs`. Makefile and Ninja generators produce the `test` target, which invokes `ctest` under the hood. 41This makes passing additional arguments to `ctest` difficult, so it's possible to invoke it directly in `checkPhase` 42by adding `ctestCheckHook` to `nativeCheckInputs`. 43 44### CTest Variables {#cmake-ctest-variables} 45 46#### `disabledTests` {#cmake-ctest-disabled-tests} 47 48Allows to disable running a list of tests. Note that regular expressions are not supported by `disabledTests`, but 49it can be combined with `--exclude-regex` option. 50 51#### `ctestFlags` {#cmake-ctest-flags} 52 53Additional options passed to `ctest` together with `checkFlags`.