# CTest scripting + CMake presets?

**URL:** https://discourse.cmake.org/t/ctest-scripting-cmake-presets/9610
**Category:** Usage
**Created:** [December 11, 2023, 6:00pm UTC](https://discourse.cmake.org/t/ctest-scripting-cmake-presets/9610 "2023-12-11T18:00:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [December 11, 2023, 6:00pm UTC](https://discourse.cmake.org/t/ctest-scripting-cmake-presets/9610/1 "2023-12-11T18:00:00Z")

</div>

For local development, I’ve got all of my configuration specified in configure/build/test presets. I’ve been looking at CTest scripting, and it looks like you have to specify all these options again in the arguments to `ctest_build`, `ctest_test`, etc.

Is it possible for these commands to read CMake presets? Am I missing something here…?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [December 12, 2023, 8:13am UTC](https://discourse.cmake.org/t/ctest-scripting-cmake-presets/9610/2 "2023-12-12T08:13:58Z")

</div>

I am not sure if I understand you question right?

I use `cmake --workflow --preset test --fresh`  
or `ctest --build --preset test --rerun-failed`

and this `cmake workflow preset` i.e.:

```json
{
  "version": 6,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 25,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "test",
      "displayName": "Default test Config",
      "description": "Default build using Ninja generator",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/build",
      "installDir": "${sourceDir}/stagedir",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": {
          "type": "path",
          "value": "${sourceDir}/stagedir"
        },
        "CMAKE_BUILD_TYPE": "Release",
        "CMAKE_CXX_EXTENSIONS": false,
        "CMAKE_CXX_STANDARD": "17",
        "CMAKE_CXX_STANDARD_REQUIRED": true
      },
      "environment": {
        "CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
        "CPM_USE_LOCAL_PACKAGES": "NO",
        "CPM_SOURCE_CACHE": "NO"
      },
      "warnings": {
        "deprecated": true,
        "uninitialized": true
      }
    }
  ],
  "buildPresets": [
    {
      "name": "test",
      "configurePreset": "test",
      "targets": [
        "check-format"
      ]
    }
  ],
  "testPresets": [
    {
      "name": "test",
      "configurePreset": "test",
      "output": {
        "outputOnFailure": true
      },
      "execution": {
        "noTestsAction": "error",
        "stopOnFailure": false,
        "rerun-failed": true
      }
    }
  ],
  "packagePresets": [
    {
      "name": "test",
      "configurePreset": "test",
      "generators": [
        "TGZ"
      ]
    }
  ],
  "workflowPresets": [
    {
      "name": "test",
      "steps": [
        {
          "type": "configure",
          "name": "test"
        },
        {
          "type": "build",
          "name": "test"
        },
        {
          "type": "test",
          "name": "test"
        }
      ]
    }
  ]
}

```

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [December 13, 2023, 3:37am UTC](https://discourse.cmake.org/t/ctest-scripting-cmake-presets/9610/3 "2023-12-13T03:37:43Z")

</div>

I do too, when just running tests locally. But to actually run a dashboard, my current workflow is to configure first (using a CMake preset), and then `cd` into that build directory and run `ctest -D Nightly -C Debug`
