#cmake include problems
10 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
here is a segment of my cmake file
# add executable (repl)
add_executable(repl "src/repl.cpp")
# target_link_libraries(repl modeldb)
# add library
file(GLOB_RECURSE MODELDB_SRC "src/*.cpp" "src/*.hpp")
file(GLOB_RECURSE MODELDB_INCLUDE "include/modeldb/*.hpp")
add_library(modeldb SHARED ${MODELDB_SRC} ${MODELDB_INCLUDE})
# set include directories
target_include_directories(modeldb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/modeldb)
target_include_directories(modeldb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(modeldb PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)```
i did target include PRIVATE and PUBLIC bc in the source code of the library, i do:
#include "storage/cursor.hpp"```
but i want other people to do
```cpp
#include <modeldb/storage/cursor.hpp>
when they are using my library
im the repl file, i'm doing:
#include <modeldb/compiler/metacmd/metacmd.hpp>```
this include works, but i get an error
#include "compiler/metacmd/metacmdresult.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/repl.dir/src/repl.cpp.o] Error 1
make[1]: *** [CMakeFiles/repl.dir/all] Error 2```
so i think it's doing this include correctly, but when it pastes "metacmd.hpp" into repl.cpp, and metacmd.hpp has
#include "compiler/metacmd/metacmdresult.hpp"```
and it doesn't recognize that
tldr, in file a I do:
#include "b"
but in the executable i do
#include <modeldb/a>
but it errors bc
modeldb/a does
#include "b"
and it doesn't recognize "b"
!solved