# Including legacy header files of non CMake project in CMake project

**URL:** <https://discourse.cmake.org/t/including-legacy-header-files-of-non-cmake-project-in-cmake-project/15452>\
**Category:** Code\
**Created:** [January 11, 2026, 8:48am UTC](https://discourse.cmake.org/t/including-legacy-header-files-of-non-cmake-project-in-cmake-project/15452 "2026-01-11T08:48:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc78](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mc78](https://discourse.cmake.org/u/mc78)\
**Post date:** [January 11, 2026, 8:48am UTC](https://discourse.cmake.org/t/including-legacy-header-files-of-non-cmake-project-in-cmake-project/15452/1 "2026-01-11T08:48:10Z")

</div>

I would like to add general `include_directories` to a `toolchain.cmake` file.

However, as soon I specify those include directories, CMake complains about missing `CMakeLists.txt` in that directory. I did not specify `add_library` nor `add_executable` for a subdirectory of `include_directories` so I don’t understand really why CMake complains. There is nothing to do except adding those `include_directories` to the list of `-I` switches.

I use the toolchain file from [CC65 CA65 Toolchain for CMake · GitHub](https://gist.github.com/jroweboy/04a2635d1a24a6373c2745cc911d55dc)

and just add an `include_directories` statement with the include directories I want to include generally in my projects.

---

<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:** [January 11, 2026, 9:32am UTC](https://discourse.cmake.org/t/including-legacy-header-files-of-non-cmake-project-in-cmake-project/15452/2 "2026-01-11T09:32:27Z")

</div>

Do you mean something like that:

```bash
-- Configuring done (1.6s)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FMT_SYSTEM_INCLUDE_PATH
   used as include directory in directory /Users/clausklein/cmake/test
   used as include directory in directory /Users/clausklein/cmake/test
   used as include directory in directory /Users/clausklein/cmake/test
   used as include directory in directory /Users/clausklein/cmake/test

CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of "qt_test":

    "FMT_SYSTEM_INCLUDE_PATH-NOTFOUND"

CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of "qt_test":

    "FMT_SYSTEM_INCLUDE_PATH-NOTFOUND"

-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
bash-5.3$ 

```

If true, you may prevent this by using `REQUIRED`:

```cmake
find_path(FMT_SYSTEM_INCLUDE_PATH "format.hpp" PATH_SUFFIXES fmt REQUIRED)
include_directories(SYSTEM ${FMT_SYSTEM_INCLUDE_PATH})

```

---

<div class="post-metadata">

**Author:** ![mc78](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mc78](https://discourse.cmake.org/u/mc78)\
**Post date:** [January 11, 2026, 6:57pm UTC](https://discourse.cmake.org/t/including-legacy-header-files-of-non-cmake-project-in-cmake-project/15452/3 "2026-01-11T18:57:59Z")

</div>

No, I mean this:

**toolchain.cmake:**

```auto
[…]

set(MY_LIB_DIR /home/user/.../mylib)
include_directories(${MY_LIB_DIR}/include ${MY_LIB_DIR}/libsrc)

```

**Output:**

`$ cmake -B debug -S . --toolchain ../toolchain.cmake`  
`CMake Error: The source directory “/home/user/.../mylib” does not appear to contain CMakeLists.txt`.

---

<div class="post-metadata">

**Author:** ![mc78](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mc78](https://discourse.cmake.org/u/mc78)\
**Post date:** [January 11, 2026, 7:38pm UTC](https://discourse.cmake.org/t/including-legacy-header-files-of-non-cmake-project-in-cmake-project/15452/4 "2026-01-11T19:38:24Z")

</div>

I got my facepalm moment. I’m so sorry about this. I accidentally cd’d into the mylib directory instead of the source directory.
