# How to force install into custom dir under project

**URL:** https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209
**Category:** Usage
**Created:** [May 13, 2020, 2:42pm UTC](https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209 "2020-05-13T14:42:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yisseamake](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yisseamake/32/897_2.png) [@yisseamake](https://discourse.cmake.org/u/yisseamake)
#### Post date: [May 13, 2020, 2:42pm UTC](https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209/1 "2020-05-13T14:42:59Z")

</div>

I have project structure with custom install dir under the project dir (build dir is at the same level as install dir) which I’d like to install to my librray (with library and public include objects). However I am getting error Target “mylib” INTERFACE\_INCLUDE\_DIRECTORIES property contains path:

```
"/home/myproject/install/include"

```

which is prefixed in the source directory.  
The actual source is in different dir, but the top level project directory is referenced by ${CMAKE\_SOURCE\_DIR} so maybe this is causing error?  
Anyway how to I allow generation to proceed for this case.  
Note, this error occurs after Configuration done so install target for make is configured and running so running cmake script with make install completes successfully wrinting cmake targets to under install dir.

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [May 14, 2020, 7:45am UTC](https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209/2 "2020-05-14T07:45:47Z")

</div>

If I understand your issue correctly, you need to use the `BUILD_INTERFACE` and `INSTALL_INTERFACE` generator expressions to differentiate between building the library and using the library from the install dir.

From [https://cmake.org/cmake/help/latest/command/target\_include\_directories.html:](https://cmake.org/cmake/help/latest/command/target_include_directories.html:)

> Include directories usage requirements commonly differ between the build-tree and the install-tree. The `BUILD_INTERFACE` and `INSTALL_INTERFACE` generator expressions can be used to describe separate usage requirements based on the usage location. Relative paths are allowed within the `INSTALL_INTERFACE` expression and are interpreted relative to the installation prefix. For example:
> 
> ```auto
> target_include_directories(mylib PUBLIC
> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/mylib>
> $<INSTALL_INTERFACE:include/mylib> # <prefix>/include/mylib
> )
> 
> ```

---

<div class="post-metadata">

### Author: ![yisseamake](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yisseamake/32/897_2.png) [@yisseamake](https://discourse.cmake.org/u/yisseamake)
#### Post date: [May 18, 2020, 6:39pm UTC](https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209/3 "2020-05-18T18:39:46Z")

</div>

Thank you for the response. This issue has been resolved by specifying relative path - removing “/home/myproject/” whih tells me the error message is not quite accurate and should rather indicate that installation should not be targeting fixed path on the the build system which maybe invalid on the system using my install dir.
