Ninja code generator does not build in correct order when using protobuf and custom_command

@hsattler
I added:

target_sources ( MyProtoLib PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/some_header.h )

add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/some_header.h
  COMMAND "${CMAKE_COMMAND}" -E env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
          python3 ${CMAKE_CURRENT_SOURCE_DIR}/test.py
  DEPENDS test.py
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/foo_pb2.py
)

I get:

../src/Main.cpp:2:10: fatal error: some_header.h: No such file or directory
    2 | #include "some_header.h"

The python code itself will not be executed…so there is even no some_header.h created at all