lib1/CMakeLists.txt
add_library(lib1 STATIC
lib1.cpp
lib1.h
)
target_include_directories(lib1
PRIVATE ../third
)
target_link_libraries(lib1
PRIVATE third
)
CMakeLists.txt
add_subdirectory(lib1)
add_executable(exe
main.cpp
)
target_link_libraries(exe
PRIVATE lib1
)
target_include_directories(lib1_objs
PRIVATE ../lib1
)
When I run make, it show this error
Scanning dependencies of target lib1
[ 25%] Building CXX object lib1/CMakeFiles/lib1.dir/lib1.cpp.o
[ 50%] Linking CXX static library liblib1.a
[ 50%] Built target lib1
Scanning dependencies of target a
[ 75%] Building CXX object CMakeFiles/a.dir/main.cpp.o
[100%] Linking CXX executable a
/usr/bin/ld: cannot find -lthird
collect2: error: ld returned 1 exit status
I only link lib-third PRIVATE in lib1/CMakeLists.txt, why 'exe' need link third?