This is my project tree:
project
| + src
| + external
| | + foo
| | | + include
| | | | - foo.hpp
| | | + src
| | | | - foo.cpp
| | | | - CMakeLists.txt
| | | - CMakeLists.txt
| | + CMakeLists.txt
| + src
| | - main.cpp
| - CMakeLists.txt
foo.cpp includes foo.hpp:
// foo.cpp
#include "foo.hpp"
Now the problem is that including the directory in the top CMake successfully find foo.hpp, but if I include in the subproject it doesn't. Any reason for it? (directories are included before the executable is compiled).
// project/CMakeLists.txt
include_directories(external/foo/include) //OK
add_subdirectory(external)
add_executable(main main.cpp)
target_link_libraries(main foo)
// project/external/CMakeLists.txt
add_subdirectory(foo)
// project/external/foo/CMakeLists.txt
include_directories(include) // NOT WORKING
add_subdirectory(src)
// project/external/foo/src/CMakeLists.txt
add_library(foo foo.cpp)
external/include
in the top-level CMakeList andexternal/foo/include
in the CMakeList inside foo - perhaps that's the issue? – Peplum