# Are \`IF\` generator expressions short circuit?

**URL:** https://discourse.cmake.org/t/are-if-generator-expressions-short-circuit/8000
**Category:** Usage
**Created:** [April 27, 2023, 2:10pm UTC](https://discourse.cmake.org/t/are-if-generator-expressions-short-circuit/8000 "2023-04-27T14:10:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gabyx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gabyx/32/2107_2.png) [@gabyx](https://discourse.cmake.org/u/gabyx)
#### Post date: [April 27, 2023, 2:10pm UTC](https://discourse.cmake.org/t/are-if-generator-expressions-short-circuit/8000/1 "2023-04-27T14:10:17Z")

</div>

Are generator expression short circuit:

```cmake
$<$<IN_LIST,
  $<TARGET_PROPERTY:${targetName},TYPE>,
    EXECUTABLE;SHARED_LIBRARY;MODULE_LIBRARY>:
  $<TARGET_RUNTIME_DLLS:${targetName}>>

```

So if `targetName` is an `STATIC_LIBRARY` on generation time, will the above not evaluate `$<TARGET_RUNTIME_DLLS:` generator expression because that would result in an error by documentation.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [April 29, 2023, 6:20am UTC](https://discourse.cmake.org/t/are-if-generator-expressions-short-circuit/8000/2 "2023-04-29T06:20:05Z")

</div>

My understanding is that both branches are always evaluated. I think the reason has to do with how generator expression evaluation is implemented, making short-circuit evaluation non-trivial.
