# Tutorial Step 8 Visual Studio build steps in wrong order?

**URL:** https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443
**Category:** Usage
**Tags:** os:windows, gen:vs
**Created:** [March 22, 2024, 3:37am UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443 "2024-03-22T03:37:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gaz0](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gaz0/32/4466_2.png) [@gaz0](https://discourse.cmake.org/u/gaz0)
#### Post date: [March 22, 2024, 3:37am UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443/1 "2024-03-22T03:37:12Z")

</div>

I built and ran Step 8 of the tutorial OK. But if I rebuild SqrtLibrary in Visual Studio I get

```auto
Rebuild started at 9:08 AM...
1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1>1>Checking Build System
2>------ Rebuild All started: Project: MakeTable, Configuration: Debug x64 ------
2>Building Custom Rule C:/Users/perma/source/repos/cmake-3.28-tutorial/Step8/MathFunctions/CMakeLists.txt
2>MakeTable.cxx
2>MakeTable.vcxproj -> C:\Users\perma\source\builds\cmake-3.28-tutorial\Step8_msvc17\MathFunctions\Debug\MakeTable.exe
3>------ Rebuild All started: Project: SqrtLibrary, Configuration: Debug x64 ------
3>Generating Table.h
3>Building Custom Rule C:/Users/perma/source/repos/cmake-3.28-tutorial/Step8/MathFunctions/CMakeLists.txt
3>mysqrt.cxx
3>SqrtLibrary.vcxproj -> C:\Users\perma\source\builds\cmake-3.28-tutorial\Step8_msvc17\MathFunctions\Debug\SqrtLibrary.lib
========== Rebuild All: 3 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 9:08 AM and took 03.147 seconds ==========

```

When it gets to build SqrtLibrary, after ZERO\_CHECK and MakeTable, the first thing it does is generate Table.h. Only after that does it run the check to see whether CMake should recreate the build tree (if I am interpreting it correctly). It seems to me that the build step associated with CMakeLists.txt should come first.  
What am I missing?

---

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [March 22, 2024, 10:30pm UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443/2 "2024-03-22T22:30:28Z")

</div>

`ZERO_CHECK` is just CMake checking if it needs to re-run. By definition if your `CMakeLists.txt` changes you need to regenerate your visual studio solution.

If this check didn’t exist each time you changed any `CMakeLists.txt` or `*.cmake` file you would have to manually regenerate the visual studio solution.

That’s why it runs first. Hence the name 0 check. It’s the first thing that needs to be checked. (Programmers start at 0).

So in order.

0.) ZERO\_CHECK  
1.) Build MakeTable executable. This HAS to happen before table.h can be generated.  
2.) Generate table.h using MakeTable  
3.) Build SqrtLibrary library which include table.h

---

<div class="post-metadata">

### Author: ![gaz0](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gaz0/32/4466_2.png) [@gaz0](https://discourse.cmake.org/u/gaz0)
#### Post date: [March 22, 2024, 11:24pm UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443/3 "2024-03-22T23:24:16Z")

</div>

Thanks for responding. To clarify, my question is about these three lines in the output I copied:

```auto
3>------ Rebuild All started: Project: SqrtLibrary, Configuration: Debug x64 ------
3>Generating Table.h
3>Building Custom Rule C:/Users/perma/source/repos/cmake-3.28-tutorial/Step8/MathFunctions/CMakeLists.txt

```

The line that starts with `Building Custom Rule` is from a custom build step in `SqrtLibrary` that seems to be looking at whether it needs to recreate the build tree, similar to what `ZERO_CHECK` does. If that is what it is doing, why is it not running before the other custom build step in that project, which is the one that generates `Table.h`.

I’m also curious about why we need both ZERO\_CHECK and the custom build steps to check the build in each project.

---

<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 10, 2024, 11:54pm UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443/4 "2024-04-10T23:54:23Z")

</div>

> [@gaz0](#):
>
> I’m also curious about why we need both ZERO\_CHECK and the custom build steps to check the build in each project.

Probably arcane reasons related to ancient Visual Studio versions. @brad.king may know.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [April 11, 2024, 12:20pm UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443/5 "2024-04-11T12:20:18Z")

</div>

> [@gaz0](#):
>
> I’m also curious about why we need both ZERO\_CHECK and the custom build steps to check the build in each project.

The per-project checks came first. When VS introduced support for parallel builds of multiple projects, `ZERO_CHECK` was created to synchronize an initial check. The per-project checks are attached to the `CMakeLists.txt` files and so were kept to provide a convenient way to interactively reconfigure after editing one. During a normal build the per-project checks should do nothing once `ZERO_CHECK` is done.
