I have a executable used to generate a "cache" file. In CMake, I have something like this:
add_executable(Generator ...)
add_custom_target(OUTPUT cache
    DEPENDS Generator OtherDep1 OtherDep2
    COMMAND Generator --input OtherDep1 OtherDep2 --output cache)

However, because it takes about 10 minutes and I do not care of the cache differs when Generator changes, I do not want cache to be re-computed whenever Generator is re-linked for whatever reason. But if I remove Generator from the dependencies, it may not be available when the custom commands needs it.
I know this is a bit far from the usual Make/CMake workflow, but is there something I can do to require Generator to have been compiled before running the custom command?

How to make a CMake custom command depends on a target being built but without rerunning on relink?

I do not want cache to be re-computed whenever Generator is re-linked for whatever reason.

Then you need to define target-level dependencies instead of file-level ones. Target-level dependencies are defined with add_dependencies command:
add_executable(Generator ...)

# Custom command for **file-level** dependencies.
# The output will be rebuilt whenever it will be found older than one of its dependencies.
add_custom_command(OUTPUT cache
    DEPENDS OtherDep1 OtherDep2
    COMMAND Generator --input OtherDep1 OtherDep2 --output cache)

# Custom target.
# It just makes sure, that its dependencies are up-to-date.
add_custom_target(create_cache
   DEPENDS cache
)

# **target-level** dependencies between the targets.
# They ensures only order, but do not cause rebuilding of one target
# because of another target has been rebuilt
add_dependencies(create_cache Generator)

