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

**URL:** https://discourse.cmake.org/t/cant-figure-out-how-to-replicate-std-make-command-file-x-file-c-file-o/5995
**Category:** Usage
**Created:** [July 4, 2022, 4:46pm UTC](https://discourse.cmake.org/t/cant-figure-out-how-to-replicate-std-make-command-file-x-file-c-file-o/5995 "2022-07-04T16:46:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SurfskiDude](https://discourse.cmake.org/user_avatar/discourse.cmake.org/surfskidude/32/2570_2.png) [@SurfskiDude](https://discourse.cmake.org/u/SurfskiDude)
#### Post date: [July 4, 2022, 4:46pm UTC](https://discourse.cmake.org/t/cant-figure-out-how-to-replicate-std-make-command-file-x-file-c-file-o/5995/1 "2022-07-04T16:46:26Z")

</div>

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

---

<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: [July 5, 2022, 11:50am UTC](https://discourse.cmake.org/t/cant-figure-out-how-to-replicate-std-make-command-file-x-file-c-file-o/5995/2 "2022-07-05T11:50:11Z")

</div>

Something like this:

```cmake
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.
