# CTest build-and-test with multi-config generators

**URL:** https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008
**Category:** Usage
**Tags:** os:windows, gen:vs
**Created:** [April 14, 2020, 1:47am UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008 "2020-04-14T01:47:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [April 14, 2020, 1:47am UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/1 "2020-04-14T01:47:19Z")

</div>

What is the right way to call CTest in build-and-test mode with a multi-config generator? I see there’s a flag `--build-config-sample`, but it doesn’t let me set the build config directly.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 14, 2020, 11:50am UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/2 "2020-04-14T11:50:33Z")

</div>

Is `--build-config` not suitable?

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [April 15, 2020, 3:06am UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/3 "2020-04-15T03:06:59Z")

</div>

[The documentation](https://cmake.org/cmake/help/latest/manual/ctest.1.html?highlight=ctest#build-and-test-mode) implies that it isn’t available in build-and-test mode. But it indeed works.

See the “Build and Test” section. It shows the syntax as being:

```auto
ctest --build-and-test <path-to-source> <path-to-build>
      --build-generator <generator>
      [<options>...]
      [--build-options <opts>...]
      [--test-command <command> [<args>...]]

```

The text claims that the `[<options>...]` are enumerated below this section, and it doesn’t contain `--build-config`.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 15, 2020, 1:29pm UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/4 "2020-04-15T13:29:03Z")

</div>

Ah, please file an issue, thanks.

---

<div class="post-metadata">

### Author: ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)
#### Post date: [April 15, 2020, 1:45pm UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/5 "2020-04-15T13:45:12Z")

</div>

It is [there](https://cmake.org/cmake/help/latest/manual/ctest.1.html?highlight=ctest#id16), but not where the OP it expected. It is a synonym for the -C option and therefore placed under Options section.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [April 17, 2020, 3:32am UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/6 "2020-04-17T03:32:36Z")

</div>

Do _all_ of the Options apply to build-and-test mode? That isn’t at all clear. `-C` is definitely not mentioned under the “build and test” header.

---

<div class="post-metadata">

### Author: ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)
#### Post date: [April 17, 2020, 3:05pm UTC](https://discourse.cmake.org/t/ctest-build-and-test-with-multi-config-generators/1008/7 "2020-04-17T15:05:01Z")

</div>

I was reading `[<options>...]` this way, that all other options (not explicitely mentioned here) may be applied.
