# Get INSTALL\_INTERFACE in \`install(CODE)\`.

**URL:** https://discourse.cmake.org/t/get-install-interface-in-install-code/2308
**Category:** Code
**Created:** [December 7, 2020, 5:36am UTC](https://discourse.cmake.org/t/get-install-interface-in-install-code/2308 "2020-12-07T05:36:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [December 7, 2020, 5:36am UTC](https://discourse.cmake.org/t/get-install-interface-in-install-code/2308/1 "2020-12-07T05:36:03Z")

</div>

I think I have found a bug, or at the very least a vexing behavior. Here’s my minimal example:

```cmake
cmake_minimum_required(VERSION 3.16)
project(example)

add_library(example INTERFACE)
target_compile_definitions(example INTERFACE $<BUILD_INTERFACE:BUILD> $<INSTALL_INTERFACE:INSTALL>)

install(CODE [[
message(STATUS "$<TARGET_PROPERTY:example,INTERFACE_COMPILE_DEFINITIONS>")
]])

```

Build with:

```auto
$ cmake -S . -B build
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/build
$ cmake --build build
$ cmake --install build --prefix install
-- Install configuration: ""
-- BUILD

```

As you can see, `BUILD` is printed rather than `INSTALL`. I would understand this for `file(GENERATE)`, but for `install(CODE)`, this is rather surprising, since it’s the _install_ command I’m going through.

Is there any way to access the `INSTALL_INTERFACE` version of properties in a generator expression? If not, was this a deliberate design decision? I’d like to understand it, if so. Obviously to be changed at this point would require a policy.

---

<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: [December 7, 2020, 3:04pm UTC](https://discourse.cmake.org/t/get-install-interface-in-install-code/2308/2 "2020-12-07T15:04:07Z")

</div>

This is because the install scripts are written during the build, so they get the build’s view of the properties. We’d probably need a genex to force the install’s view of the properties. Perhaps `$<INSTALL:$<TARGET_PROPERTY:example,INTERFACE_COMPILE_DEFINITIONS>>`?

Cc: @brad.king @craig.scott
