I'm trying to build a C++ project using CMake. Therefore I'd like to create a library from a subdirectory. My project structure looks like the following:
project
core
CMakeLists.txt
point.h
point.cpp
CMakeLists.txt
build
main.cpp
My outer CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(MyProject)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(core)
add_executable(main main.cpp)
target_link_libraries(main core)
My inner CMakeLists.txt:
add_library(
core
point.cpp
)
I'm importing point.h in my main.cpp file with #include "core/point.h"
When I run cmake from the build folder no error occurs. Building using make gives me the following error:
fatal error: point.h: No such file or directory
2 | #include "core/point.h"
| ^~~~~~~~~
compilation terminated.