# target\_include\_directories(mylib SYSTEM ...) is exported without \_IMPORT\_PREFIX?

**URL:** https://discourse.cmake.org/t/target-include-directories-mylib-system-is-exported-without-import-prefix/5359
**Category:** Code
**Created:** [April 3, 2022, 10:59am UTC](https://discourse.cmake.org/t/target-include-directories-mylib-system-is-exported-without-import-prefix/5359 "2022-04-03T10:59:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [April 3, 2022, 10:59am UTC](https://discourse.cmake.org/t/target-include-directories-mylib-system-is-exported-without-import-prefix/5359/1 "2022-04-03T10:59:43Z")

</div>

This `CMakeLists.txt` snipped:

```cmake
# to get CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)

# target_include_directories with the SYSTEM modifier will request the compiler
# to omit warnings from the provided paths, if the compiler supports that
target_include_directories(
  ${PROJECT_NAME} SYSTEM PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
                                $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

```

Generates this exported config code:

```cmake
# Create imported target greeter::greeter
add_library(greeter::greeter STATIC IMPORTED)

set_target_properties(greeter::greeter PROPERTIES
  INTERFACE_COMPILE_FEATURES "cxx_std_20"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "fmt::fmt;greeter::project_warnings;greeter::project_options"
  INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "include"
)

```

- At the line with `INTERFACE_SYSTEM_INCLUDE_DIRECTORIES` the `${_IMPORT_PREFIX}/...` is missing!
- And the **CMAKE\_INSTALL\_PREFIX=/usr/** is ignored in this way of installation?

I am using **cmake version 3.23.0** on **OSX** and install the project doing this:

```bash
bash-3.2$ make install -n
cmake -B ./build-ModernCmakeStarter-Debug -S /Users/clausklein/Workspace/cpp/ModernCmakeStarter/all -D CMAKE_STAGING_PREFIX=/Users/clausklein/Workspace/cpp/stage -D CMAKE_INSTALL_PREFIX=/usr/
cmake --build ./build-ModernCmakeStarter-Debug --target all
cmake --build ./build-ModernCmakeStarter-Debug --target test
gcovr ./build-ModernCmakeStarter-Debug
cmake -B ./build-ModernCmakeStarter-Debug -S /Users/clausklein/Workspace/cpp/ModernCmakeStarter/all -D USE_SANITIZER=""
DESTDIR=/Users/clausklein/Workspace/cpp/stage cmake --install ./build-ModernCmakeStarter-Debug --prefix /usr/
bash-3.2$ 

```

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [April 5, 2022, 4:17am UTC](https://discourse.cmake.org/t/target-include-directories-mylib-system-is-exported-without-import-prefix/5359/2 "2022-04-05T04:17:56Z")

</div>

@ben.boeckel Is this a BUG or wrong usage?

---

<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: [April 5, 2022, 2:14pm UTC](https://discourse.cmake.org/t/target-include-directories-mylib-system-is-exported-without-import-prefix/5359/3 "2022-04-05T14:14:23Z")

</div>

Looks to be a bug to me. Probably just an oversight on which properties need `_IMPORT_PREFIX` applied. Please open [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues).

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [April 5, 2022, 6:30pm UTC](https://discourse.cmake.org/t/target-include-directories-mylib-system-is-exported-without-import-prefix/5359/4 "2022-04-05T18:30:33Z")

</div>

done, see [issues/23393](https://gitlab.kitware.com/cmake/cmake/-/issues/23393)
