Issue
I followed this answer to create a CMakeLists.txt for a simple Makefile
Makefile
CC = g++
INCFLAGS = -I/usr/local/include/embree3
LDFLAGS = -L"/usr/local/lib/" -lembree3
RM = /bin/rm -f
all:
$(CC) -o main main.cpp $(INCFLAGS) $(LDFLAGS)
clean:
$(RM) *.o main
CMakeLists.txt
cmake_minimum_required(VERSION 3.1.0)
project(aaf_project_impl)
include_directories(/usr/local/include/embree3) # -I flags for compiler
link_directories(/usr/local/lib/) # -L flags for linker
add_executable(main main.cpp)
target_link_libraries(main embree) # -l flags for linking prog target
The Makefile compiles properly and the executable runs without any issues. And to use the cmake file, I do the following (assuming I am in source directory)
- mkdir build
- cd build
- cmake ..
- make
The make
in step 4 throws the following error
main.cpp:4:10: fatal error: 'embree3/rtcore.h' file not found
#include <embree3/rtcore.h>
^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
I installed embree from source by cloning the git repo. I am using Macbook M1 (MacOS Big Sur 11.5.1).
I am very new to cmake (started using it a day ago) so I apologize if this is a rather silly question.
Solution
Ok, so following your answer to my comments, the problem is that since you starts your include instruction by embree3 (which make sense to avoid names conflict), cmake should have as include directory the directory containing the embree3 installation, not the embree3 folder itself.
This is why include_directories(/usr/local/include) is working instead of include_directories(/usr/local/include/embree3).
Answered By - Laurent Jospin