# How to get package X header files if find\_package(X) only sets X\_LIBRARIES but not X\_INCLUDE\_DIRS?

**URL:** https://discourse.cmake.org/t/how-to-get-package-x-header-files-if-find-package-x-only-sets-x-libraries-but-not-x-include-dirs/5746
**Category:** Usage
**Created:** [May 27, 2022, 6:11am UTC](https://discourse.cmake.org/t/how-to-get-package-x-header-files-if-find-package-x-only-sets-x-libraries-but-not-x-include-dirs/5746 "2022-05-27T06:11:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)
#### Post date: [May 27, 2022, 6:11am UTC](https://discourse.cmake.org/t/how-to-get-package-x-header-files-if-find-package-x-only-sets-x-libraries-but-not-x-include-dirs/5746/1 "2022-05-27T06:11:58Z")

</div>

I am trying to understand how to use imported libraries in my project. I have read [this documentation](https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/Exporting-and-Importing-Targets), but the concept and jargon are not clear to me. Let’s take a real-world example I’m dealing with now; my project builds a library, and my source files that make up that library must be compiled with headers from imported library X. Cmake’s find\_package(X) sets X\_LIBRARIES to contain IMPORTED targets in the form of `X::foo`, but does _not_ set X\_INCLUDE\_DIRS. How should my project CMakeLists.txt specify where the target library gets package X header files, if I only have ${X\_LIBRARIES} and _not_ ${X\_INCLUDE\_DIRS}? The CMakefile currently looks like this:

```auto
# My library source files
set(src x.c y.c z.c)

# Static library
add_library(myLibrary
            STATIC
            ${src})

# Sources for my library include headers from X. But how do I specify this, if find_package(X) only give ${X_LIBRARIES} and not ${X_INCLUDE_DIR}???
target_include_directories(myLibrary PUBLIC ${X_INCLUDE_DIR})

```

How can I compile the library sources if I only have IMPORTED targets in ${X\_LIBRARIES}?

Thanks!

---

<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: [May 27, 2022, 1:03pm UTC](https://discourse.cmake.org/t/how-to-get-package-x-header-files-if-find-package-x-only-sets-x-libraries-but-not-x-include-dirs/5746/2 "2022-05-27T13:03:39Z")

</div>

The package should just provide the include directories as usage requirements on the imported targets. There’s zero requirement to have any include directory variable available.
