0

I need to use Devil for a school project and im having a bit of trouble.

The #include <IL/il.h> says 'IL/il.h' file not found, so im trying to add the .h path to CMakeList.

I install Devil with homebrew and add the following to CMakeList:

include_directories(/opt/homebrew/Cellar/devil/1.8.0_3/include/IL)

And

add_executable(IL/il.h)

But i get this error:

CMake Error at CMakeLists.txt:16 (add_executable): The target name "IL/il.h" is reserved or not valid for certain CMake features, such as generator expressions, and may result in undefined behavior.

Miguelii
  • 27
  • 7
  • 2
    `add_executable(IL/il.h)` is not an executable. Remove that line. – drescherjm Mar 29 '22 at 14:33
  • 2
    `include_directories(/opt/homebrew/Cellar/devil/1.8.0_3/include/IL)` probably should be `include_directories(/opt/homebrew/Cellar/devil/1.8.0_3/include)` unless you actually have a `/opt/homebrew/Cellar/devil/1.8.0_3/include/IL/IL` folder. Remember the `IL/il.h` path will be relative to the folders specified as include directories. – drescherjm Mar 29 '22 at 14:34
  • @drescherjm I remove the add_executable line and modify the include_directories to only /include, it works! Thank u – Miguelii Mar 29 '22 at 14:37
  • You don't need to add headers as sources to a target. It's convenient to do so, if the headers belong to the target itself, e.g. Visual Studio lists them among the soures in that case, but usually you don't add headers of external libs. Furthermore usually `target_include_directories` should be preferred to `include_directories`. – fabian Mar 29 '22 at 17:42

0 Answers0