# Subdirectory that is just header files

**URL:** <https://discourse.cmake.org/t/subdirectory-that-is-just-header-files/2316>\
**Category:** Code\
**Created:** [December 9, 2020, 12:51am UTC](https://discourse.cmake.org/t/subdirectory-that-is-just-header-files/2316 "2020-12-09T00:51:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Post date:** [December 9, 2020, 12:51am UTC](https://discourse.cmake.org/t/subdirectory-that-is-just-header-files/2316/1 "2020-12-09T00:51:07Z")

</div>

I have a pain in the butt situation. I am stuck working with a very old makefile based make system (about 200 directories). Moving it to CMake is not a short term option.

Building is “fine” but debugging is really horrible as there is no “Project” with the files being debugged. Its just an old school makefile based system. No IDE integration. For Eclipse the typical soluition is to do the “auto import” of all files under the top source directory.

But Visual Studio really doesn’t have a counter. I have a solution that essentially creates a CMake solution/project files for each directory. It works great, except to solve that, I want the “build” step for each directory to call “make –J ” which I can get working using a custom target

But there are a number of directories, that are header files only. Meaning there is no build target.

add\_library will not work, since it reports “can not determine linker” which is fully understandable. Is there any way to simply say, “this project creates a folder with just files in it, and there is nothing to build”

Thanks

Scott

---

<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 9, 2020, 2:05am UTC](https://discourse.cmake.org/t/subdirectory-that-is-just-header-files/2316/2 "2020-12-09T02:05:35Z")

</div>

For header-only libraries, you would want an `INTERFACE` library: `add_library(header_only INTERFACE ${headers})`. I think more recent versions (3.18+?) have support for showing these in IDEs.

---

<div class="post-metadata">

**Author:** ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Post date:** [December 9, 2020, 2:09am UTC](https://discourse.cmake.org/t/subdirectory-that-is-just-header-files/2316/3 "2020-12-09T02:09:32Z")

</div>

Thanks. I’ll look into that.

~~Scott

---

<div class="post-metadata">

**Author:** ![anon45792294](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@anon45792294](https://discourse.cmake.org/u/anon45792294)\
**Post date:** [December 9, 2020, 4:10pm UTC](https://discourse.cmake.org/t/subdirectory-that-is-just-header-files/2316/4 "2020-12-09T16:10:55Z")

</div>

Examples you might want to look into:

> **[g-truc/glm](https://github.com/g-truc/glm)**
>
> OpenGL Mathematics (GLM). Contribute to g-truc/glm development by creating an account on GitHub.

  

> **[microsoft/GSL](https://github.com/Microsoft/GSL)**
>
> Guidelines Support Library. Contribute to microsoft/GSL development by creating an account on GitHub.

  

> **[Neargye/magic\_enum](https://github.com/Neargye/magic_enum)**
>
> Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code - Neargye/magic\_enum
