I have a project constructed from multiple git repos, I want to use some external open source libs in it (lets say lib1 lib2).
I have added the libs to the root cmake and to the subproject cmake:
root cmake:
find_package(lib1 REQUIRED)
find_package(lib2 REQUIRED)
subproj1/cmake:
find_package(Lib1 REQUIRED)
find_package(Lib2 REQUIRED)
target_link_libraries(subproject1
Lib1
Lib2
/path to dir contains Lib1 + Lib2 dir (see below)
)
path contains:
/Lib1/:
Lib1Config.cmake
Lib1ConfigVersion.cmake
Lib1Targets-release.cmake
Lib1Targets.cmake
/Lib2/:
Lib2Config.cmake
Lib2ConfigVersion.cmake
Lib2Targets-release.cmake
Lib2Targets.cmake
when I build the project I get:
/usr/bin/ld: cannot find -lLib1
/usr/bin/ld: cannot find -lLib2
even though in the clion-log:
./subproj1/cmake-build-debug/CMakeFiles/clion-log.txt:57:-- Found the Lib1 static library: /path.../libLib1.a
Found the Lib1 shared library: path.../libLib1.so.1000.0.0
Found the Lib1 import library: Lib1_IMPORT_LIB-NOTFOUND
./subproj1/cmake-build-debug/CMakeFiles/clion-log.txt:57:-- Found the Lib2 static library: /path.../libLib2.a
Found the Lib2 shared library: path.../libLib2.so.1000.0.0
Found the Lib2 import library: Lib2_IMPORT_LIB-NOTFOUND
Any idea why linker can't find the libs?
it now works after I change the linkage to full path:
target_link_libraries(.../libLib1.so .../libLib2.so)
now sure why it works