# \`add\_custom\_command\` with target properties at build time

**URL:** <https://discourse.cmake.org/t/add-custom-command-with-target-properties-at-build-time/8464>\
**Category:** Code\
**Created:** [July 5, 2023, 3:25pm UTC](https://discourse.cmake.org/t/add-custom-command-with-target-properties-at-build-time/8464 "2023-07-05T15:25:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lecris](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lecris/32/3193_2.png) [@Lecris](https://discourse.cmake.org/u/Lecris)\
**Post date:** [July 5, 2023, 3:25pm UTC](https://discourse.cmake.org/t/add-custom-command-with-target-properties-at-build-time/8464/1 "2023-07-05T15:25:10Z")

</div>

I am trying to design an interface for `fypp` that mimics `add_library`, `target_sources` and `add_executable`. The issue I am currently stuck on is how can I get the target properties, e.g. `COMPILE_DEFINITIONS` that would be run at build time. I have considered using [`cmake_language(deffer)`](https://cmake.org/cmake/help/latest/command/cmake_language.html#defer), but I don’t think that will help with genex or `add_custom_command(APPEND)`.

---

<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 9, 2023, 4:33pm UTC](https://discourse.cmake.org/t/add-custom-command-with-target-properties-at-build-time/8464/2 "2023-07-09T16:33:54Z")

</div>

The only reliably way to get the full flags is by something like `CMAKE_<LANG>_COMPILER_LAUNCHER`, `compile_commands.json`, or the `cmake-file-api`. I think getting `fypp` support as an alternative Fortran preprocessor may be easier.

---

<div class="post-metadata">

**Author:** ![Lecris](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lecris/32/3193_2.png) [@Lecris](https://discourse.cmake.org/u/Lecris)\
**Post date:** [July 9, 2023, 5:45pm UTC](https://discourse.cmake.org/t/add-custom-command-with-target-properties-at-build-time/8464/3 "2023-07-09T17:45:09Z")

</div>

> [@ben.boeckel](#):
>
> I think getting `fypp` support as an alternative Fortran preprocessor may be easier.

Indeed and maybe you’ve read in the other post, the issue is that the suffix needs to chnage from `.fypp` to `.f90`, which is not supported by `<PREPROCESSED_SOURCES>`

---

<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 10, 2023, 12:01am UTC](https://discourse.cmake.org/t/add-custom-command-with-target-properties-at-build-time/8464/4 "2023-07-10T00:01:09Z")

</div>

Yeah, that’s hard-coded logic too (the `.F90` extension change at least).
