I have a project that looks like this.
.
├──include
| └──utilities.hpp
├──source
| ├──main.cpp
| └──utilities.cpp
└──CMakeLists.txt
Where both source/main.cpp
and source/utilities.cpp
have an #include "include/utilities.hpp
directive, and the contents of CMakeLists.txt
are:
cmake_minimum_required(VERSION 3.16.3)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(search VERSION 1.0.0)
add_executable(
search
source/utilities.cpp
source/main.cpp
include/utilities.hpp
)
include_directories(search PUBLIC include)
When I run make VERBOSE+1
, I get the following output:
[ 33%] Building CXX object CMakeFiles/search.dir/source/utilities.cpp.o
/home/mohammed/Work/Projects/search/source/utilities.cpp:1:10: fatal error: include/utilities.hpp: No such file or directory
1 | #include "include/utilities.hpp"
| ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/search.dir/build.make:63 : CMakeFiles/search.dir/source/utilities.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76 : CMakeFiles/search.dir/all] Error 2
make: *** [Makefile:84 : all] Error 2
I tried all the answers to this question. But none of them worked.
Can anyone tell me what am I doing wrong?
p.s If it is not yet clear, I am new to CMake.