I don't see the problem. With your static library, you can do this:
target_link_libraries(my_target_or_executable /home/me/somedir/mymagiclib.a)
Or
target_link_libraries(my_target_or_executable -L/home/me/somedir/)
target_link_libraries(my_target_or_executable mymagiclib.a)
I even linked to shared libraries yesterday this way. Because I had a conflict in gcc's address sanitizer library coming from multiple sources.
Notice however the difference with linking to a library, the normal way. For your libtest.a
, you do this:
target_link_libraries(my_target_or_executable -ltest)
Notice that you dropped the lib
prefix here. But don't do this when you want to specify the library manually.