I am having some problems linking libraries with CMake.
I have a lib2 library that uses another lib1 library. At this point everything is fine. The problem is when I add the lib2 to a my_app executable. When I build my application
I get an error because it cannot find lib1.h, but I am not using lib1.h in my_app, it is a dependency of lib2. The structure is as follows:
lib1
project(lib1)
include_directories(include)
add_library(lib1 ./src/lib1.cpp)
lib2
project(lib2)
include_directories(include path/to/include/lib1.h)
add_library(lib2 ./src/lib2.cpp)
target_link_library(lib2 path/to/lib1.a)
target_include_directories(lib2 path/to/include/lib1.h)
my_app (Where I have the error)
project(my_app)
include_directories(include path/to/include/lib2.h)
add_executable(my_app ./src/my_app.cpp)
target_link_library(my_app path/to/lib2.a)
How should I solve this dependencie without adding explicit lib1.h in my_app CMake? If it's posible...