Including legacy header files of non CMake project in CMake project

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

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

Do you mean something like that:

-- 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:

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

No, I mean this:

toolchain.cmake:

[…]

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.

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