I have a project with the following file structure:
project
|
|-------> lib1
| |----> lib1.h
|
|-------> lib2
| |----> lib2.h
|
|-------> main.cc
The two libs lib1
and lib2
only contain header files while lib2.h
includes lib1.h
, and main.cc
includes lib2.h
.
How do I write the cmake file for this project now? I tried to create an interface library for lib2
, but the compiler can't find lib1.h
. Here are the contents of my cmake files:
CMakeLists.txt for lib2:
add_library(lib2 INTERFACE)
target_sources(lib2 INTERFACE lib2.h)
target_include_directories(lib2 INTERFACE ../lib1/lib1.h)
CMakeLists.txt for the whole project:
add_executable(project main.cc)
target_link_libraries(project lib2)
What's the problem in the cmake files?