# Are generator expressions supported in set\_target\_properties / IMPORTED\_LOCATION

**URL:** https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790
**Category:** Usage
**Created:** [November 3, 2022, 11:37pm UTC](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790 "2022-11-03T23:37:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Chris\_Apple](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chris_apple/32/2042_2.png) [@Chris\_Apple](https://discourse.cmake.org/u/Chris_Apple)
#### Post date: [November 3, 2022, 11:37pm UTC](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790/1 "2022-11-03T23:37:10Z")

</div>

Wondering if this is supported, or I’m doing something wrong.

I have a line that works:

```auto
set_target_properties(NSPR::NSPR PROPERTIES
    IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/darwin_arm64/libnspr4.a"
)

```

But then breaks when I put in a generator expression (simplifying the internals to BOOL/ON for now):

```auto
set_target_properties(NSPR::NSPR PROPERTIES
    IMPORTED_LOCATION "$<$<BOOL:ON>:${CMAKE_CURRENT_SOURCE_DIR}/lib/darwin_arm64/libnspr4.a>"
)

```

The error that comes up makes me think that the generator expression is unsupported, and is just being directly put into the final compiler command:

```auto
ninja: error: '$<$<BOOL:ON>:/Users/chrisapple/code/spatial/tps/nspr/nspr/lib/darwin_arm64/libnspr4.a>', needed by 'bin/quaterniontest', missing and no known rule to make it

```

---

<div class="post-metadata">

### Author: ![Chris\_Apple](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chris_apple/32/2042_2.png) [@Chris\_Apple](https://discourse.cmake.org/u/Chris_Apple)
#### Post date: [November 3, 2022, 11:58pm UTC](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790/2 "2022-11-03T23:58:49Z")

</div>

A related issue [Does the IMPORTED\_LOCATION property support generator expressions?](https://discourse.cmake.org/t/does-the-imported-location-property-support-generator-expressions/5730)

never answered the core question.

nor did [Generator expressions for IMPORTED\_IMPLIB/LOCATION properties? - #2 by marc.chevrier](https://discourse.cmake.org/t/generator-expressions-for-imported-implib-location-properties/4564/2)

Which maybe implies I’m just messing something up? 🙂

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [November 4, 2022, 11:25am UTC](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790/3 "2022-11-04T11:25:09Z")

</div>

In general, generator expressions are only supported in contexts which explicitly list their support (such as the [`COMPILE_OPTIONS` property](https://cmake.org/cmake/help/latest/prop_tgt/COMPILE_OPTIONS.html)). `IMPORTED_LOCATION` does not list such support, so unless some other documentation clearly says otherwise, it can be assumed it does not support them.

---

<div class="post-metadata">

### Author: ![Chris\_Apple](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chris_apple/32/2042_2.png) [@Chris\_Apple](https://discourse.cmake.org/u/Chris_Apple)
#### Post date: [November 4, 2022, 4:58pm UTC](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790/4 "2022-11-04T16:58:02Z")

</div>

Perfect! Thank you!
