Can't figure out how to replicate std make command: file.x > file.c > file.o

I am trying to find a cmake way for a job that can be done as follows using standard make:

file.x : file.c
mygenerator file.x > file.c

file.c: file.o
gcc -o file.o file.c

Something like this:

add_custom_command(
  OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/out.c"
  DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/out.in"
  COMMAND mkgenerator "${CMAKE_CURRENT_SOURCE_DIR}/out.in" -o "${CMAKE_CURRENT_BINARY_DIR}/out.c"
  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  COMMENT "generating out.c")
add_library(use_out "${CMAKE_CURRENT_BINARY_DIR}/out.c")

You can wrap it up in a function to make it easier to use.