# CMakePresets.json and graphviz

**URL:** https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256
**Category:** Usage
**Created:** [May 3, 2021, 9:09pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256 "2021-05-03T21:09:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Hunter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_hunter/32/115_2.png) [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)
#### Post date: [May 3, 2021, 9:09pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/1 "2021-05-03T21:09:19Z")

</div>

Does anyone know if, and how, you can set the equivalent of a “–graphviz=graphviz.dot” command line option in a CMakePresets.json preset?

---

<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: [May 4, 2021, 10:00am UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/2 "2021-05-04T10:00:59Z")

</div>

Cc: @kyle.edwards

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [May 4, 2021, 1:16pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/3 "2021-05-04T13:16:51Z")

</div>

I don’t believe that option is present, no. We could add it.

---

<div class="post-metadata">

### Author: ![David\_Hunter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_hunter/32/115_2.png) [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)
#### Post date: [May 4, 2021, 2:07pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/4 "2021-05-04T14:07:42Z")

</div>

It would be great to have this.  
I added --graphviz=graphviz.dot to my command line so  
cmake --graphviz=graphviz.dot --preset=VS16-x64  
and it seemed to work. It did raise a question however which does not seem to be addressed in the documentation. What happens if I set something on the command line and in a preset. So i might have  
cmake -T foo …  
and have  
“toolset”: { “value”: “bar” }  
So do I get a toolset of foo or bar.  
Obviously I can answer this by trying but I think it would be good to have a section in the documentation about command line versus preset settings.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [May 4, 2021, 2:30pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/5 "2021-05-04T14:30:24Z")

</div>

Per the [cmake(1)](https://cmake.org/cmake/help/latest/manual/cmake.1.html#generate-a-project-buildsystem) documentation:

> The presets are read before all other command line options. The options specified by the preset (variables, generator, etc.) can all be overridden by manually specifying them on the command line. For example, if the preset sets a variable called `MYVAR` to `1`, but the user sets it to `2` with a `-D` argument, the value `2` is preferred.

This same user-overridable behavior applies to all other command line options too.

---

<div class="post-metadata">

### Author: ![David\_Hunter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_hunter/32/115_2.png) [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)
#### Post date: [May 4, 2021, 5:34pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/6 "2021-05-04T17:34:01Z")

</div>

Thanks for the explanation and a great feature.

It would great if that explanation could be added to the [https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#build-preset](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#build-preset) page. I for one didn’t think to look in the place you pointed to but had read the cmake-presets.7.html carefully. Maybe the cmake-presets.7.html could have a link to the other page.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [May 4, 2021, 5:41pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/7 "2021-05-04T17:41:07Z")

</div>

The cmake-presets(7) manual page is a description of the JSON format. The format has multiple frontends, including the CMake CLI, the CMake GUI, Visual Studio, and the VSCode CMake Tools extension. I don’t believe the cmake-presets(7) manual page is the appropriate place to explain the behavior of the CLI, but I’m willing to hear other opinions on this.

---

<div class="post-metadata">

### Author: ![David\_Hunter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_hunter/32/115_2.png) [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)
#### Post date: [May 4, 2021, 5:44pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/8 "2021-05-04T17:44:22Z")

</div>

Not sure I agree with "The cmake-presets(7) manual page is a description of the JSON format. ". I think most people would regard it as “where to go to learn how to use presets” which does include the JSON format but as a subset.

---

<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: [May 4, 2021, 6:27pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/9 "2021-05-04T18:27:45Z")

</div>

I agree. Just a note of how `--preset` interacts with other command line arguments would be nice in the `Introduction` section. I don’t think that every JSON field needs to mention the flag it goes with, but a general note (maybe with an example) would be useful.

---

<div class="post-metadata">

### Author: ![David\_Hunter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_hunter/32/115_2.png) [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)
#### Post date: [May 6, 2021, 1:54pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256/10 "2021-05-06T13:54:04Z")

</div>

I have create an issue [https://gitlab.kitware.com/cmake/cmake/-/issues/22164](https://gitlab.kitware.com/cmake/cmake/-/issues/22164) to request the --graphviz feature in presets.
