Here is a simplified version of my C++/CMake project's layout:
├── CMakeLists.txt
│
├── project_name/
│ ├── source_1.hpp
│ └── CMakeLists.txt
│
├── tests/
│ ├── test_1.cpp
│ └── CMakeLists.txt
And here are CMakeLists.txt
:
- Root directory:
add_subdirectory(project_name) add_subdirectory(tests)
project_name
directory:add_library(main_library INTERFACE) target_include_directories(main_library INTERFACE .)
tests
directory:add_executable(test_1 test_1.cpp) target_link_libraries(test_1 PRIVATE main_library)
So in test_1.cpp
I want to include source_1.hpp
.
Currently, I have to write #include "../project_name/source_1.hpp"
.
Is there a way to use a path that would be relative to the project's root directory for such includes, i.e. #include "project_name/source_1.hpp
?