I am trying to create a library or possibly better to make two libraries. The file structure is below (with generic names). I am trying to get the ExampleProject to be able to include messageA.h, which would include MessageUtilitiesA.h. Currently it can find the messageA.cpp but then it cannot find MessageUtitlities.h
project
|. CMakeLists.txt
|----src
|. classA.cpp
|----include
| classA.h
|----SecondFolder
| include
| Messages
| messageA.h // this includes messageUtilityA.h
|. |. messageB.h // etc
| MessageUtilities
} |. messageUtilityA.h
|
|----ExampleProject
| src
| example.cpp // needs to be able to include ClassA.h, and messageA.h
classA.cpp needs to be able to #include "Messages/messageA.h"
example.cpp needs to be able to #include "classA.h" and #include "Messages/messageA.h"
I am currently using Conan and CMake. Do I just need to make SecondFolder it's own library. In the cmake I am doing
project(base CXX)
add_library(base
src/classA.cpp
)
target_include_directories(base
PUBLIC
include
SecondFolder/include
set_target_properties(base PROPERTIES PUBLIC_HEADER "include classA.h;{PROJECT_SOURCE_DIR}/SecondFolder/include/Messages/include/MessageA.h") # might just need to glob all the .h's from the entire folder perhaps
install(TARGETS base)
Maybe I just need to add more to the cmake target_properties, make a second library just for the SecondFolder?
the CMakeLists.txt for the example is able to target_link_libraries(example base::base) and it finds the messageA.h but then complains that it cannot include messageUtilityA.h which messageA.h includes. So it cannot find the #include "<namespace>/messageUtilityA.h.
conan file does have
exports_source = "CMakeLists.txt", "src/*", "include/*", "SecondFolder/*"
MessageUtilitiesA.h,MessageUtitlities.h,messageUtilityA.h,MessageUtiltiesA.hwhich seems about the same header file. This is very confusing and it smells like a simple typo in your code when you include that header. But since your code (and description) are impresize, we cannot show the place of the typo.#includecalls and names of files which performs such inclusions. Like in that question: stackoverflow.com/questions/61384481/…