<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>hello,</p>
    <p><br>
    </p>
    <p>My build step is not thread-safe (the instruction in the COMMAND
      part). Every build step depends on one source file:</p>
    <p><br>
    </p>
    <p><i>add_custom_command(</i><i><br>
      </i><i>        DEPENDS on_source.file</i><i><br>
      </i><i>        OUTPUT</i><i><br>
      </i><i>                object_file_for_source_file</i><i><br>
      </i><i>        COMMAND not-thread-safe-compiler --build
        on_source.file</i><i><br>
      </i><i>        COMMENT</i><i><br>
      </i><i>                "Building Source object"</i><i><br>
      </i><i>)</i><br>
    </p>
    <p><br>
    </p>
    <p>add_custom_target DEPENDS on OUTPUT from all custom command's,
      but in order to prevent parallel execution when cmake is called:</p>
    <p><br>
    </p>
    <p><i>cmake --build . --target all -j30</i></p>
    <p><br>
    </p>
    <p>I need to build each step in any order, but still not as a
      dependency as this would trigger unnecessary recompilation. Using
      MAIN_DEPENDENCY defines hierarchical dependency, but this won't
      help in this situation.</p>
    <p><br>
    </p>
    <p>I cannot figure out how to prevent parallel execution of COMMAND
      in CMake. The only option I see is a single command</p>
    <p><br>
    </p>
    <p><i>add_custom_target(tgt</i><i><br>
      </i><i>
                DEPENDS on_all_source.files</i><i><br>
      </i><i>
                COMMAND not-thread-safe-compiler --build on_source1.file</i>
    </p>
    <p>
    </p>
    <p><i>        COMMAND not-thread-safe-compiler --build
        on_source2.file</i>
    </p>
    <p>
    </p>
    <p><i>        COMMAND not-thread-safe-compiler --build
        on_source3.file</i></p>
    <p><i>        . . .</i><i><br>
      </i>
    </p>
    <p>
    </p>
    <p><i>        COMMENT</i><i><br>
      </i><i>
                        "Building target"</i><i><br>
      </i><i>
        )</i></p>
    <p><br>
    </p>
    <p>this would rebuild every source, though.</p>
    <p><br>
    </p>
    <p>How do I set this up?</p>
    <p><br>
    </p>
    <p>thank you<br>
    </p>
  </body>
</html>