# BASE\_DIRS in \`target\_sources()\`

**URL:** https://discourse.cmake.org/t/base-dirs-in-target-sources/9591
**Category:** Code
**Created:** [December 9, 2023, 12:44am UTC](https://discourse.cmake.org/t/base-dirs-in-target-sources/9591 "2023-12-09T00:44:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kelarov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kelarov/32/4927_2.png) [@Kelarov](https://discourse.cmake.org/u/Kelarov)
#### Post date: [December 9, 2023, 12:44am UTC](https://discourse.cmake.org/t/base-dirs-in-target-sources/9591/1 "2023-12-09T00:44:56Z")

</div>

Hi all.  
What would be the correct approach for:  
Say I have a `./src/utils/utils.ixx`, and, in that file, I want to include:

- `./extern/include/generator.hpp`
- and two windows headers, namely:
  - `$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}/um/windows.h` and
  - `$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}/ucrt/conio.h`

I would then link my other modules with the `utils` module, so that I could use the functionality from it.

I have tried everything and no matter what I do, I get errors saying that the `um/windows.h` and `ucrt/conio.h` should be in one of the base dirs, although I literaly hard-coded the expanded version of `$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}/`; still, it only considers relative paths and, therefore, will look into `./src/utils/`

I have tried using two targets, one for the headers [using `HEADERS` as the type and adding `$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}/` for the base dir] and one for the `generator.hpp` + `utils.ixx` and it will say that it can’t determine the linker language from the `HEADERS` setup, etc.

What would be the appropriate approach here?  
I would basically `#include` the `generator` file and the windows headers in the `utils.ixx` file, do what I needed to do with them, and simply link `utils` with the other libs, so I could call functions from `utils`.

Thank you.

---

<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 11, 2023, 3:48pm UTC](https://discourse.cmake.org/t/base-dirs-in-target-sources/9591/2 "2023-12-11T15:48:50Z")

</div>

Are you trying to add `um/windows.h` and `ucrt/conio.h` to the file list of your target? That seems wrong to me. I would model this as something like:

```cmake
add_library(WindowsHeaders IMPORTED INTERFACE)
target_include_directories(WindowsHeaders INTERFACE $ENV{WindowsSdkDir}/Include/…)

```

and then link to `WindowsHeaders` as needed.

---

<div class="post-metadata">

### Author: ![Kelarov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kelarov/32/4927_2.png) [@Kelarov](https://discourse.cmake.org/u/Kelarov)
#### Post date: [December 11, 2023, 5:03pm UTC](https://discourse.cmake.org/t/base-dirs-in-target-sources/9591/3 "2023-12-11T17:03:07Z")

</div>

It seemed wrong to me too, I just didn’t know what else to do 😂, or how to model it to use with my C++20 Modules; I, however, knew that I would need to have that “INTERFACE” keyword somehow, somewhere haha.  
So, basically, I should have the two targets separate - create a target for the windows headers and make my own modules their own thing and then just do the linking.  
I didn’t know about that construct [`add_library(WindowsHeaders IMPORTED INTERFACE)`].  
Thank you very much 🙌, Ben.

Cheers
