title: Link a shared library with CMake
body: <p>I'm trying to link in a pre-compiled shared library file called libtest-lib.so. This is what I have at the bottom of my CMakeLists.txt:</p>
  
  <pre><code>link_directories("/projectspath/LinkTest/TestLib/app/build/intermediates/cmake/debug/obj/armeabi-v7a")
  
  add_library(testlib libtest-lib.so)
  
  target_link_libraries(testlib libtest-lib.so)
  </code></pre>
  
  <p>As above, I get the following error:</p>
  
  <pre><code>CMake Error at CMakeLists.txt:49 (add_library):
    Cannot find source file:
      libtest-lib.so
    Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm     .hpp
    .hxx .in .txx
   CMake Error: CMake can not determine linker language for target:    testlib
  </code></pre>
  
  <p>If I comment out the add_library line, I get the following:</p>
  
  <pre><code>CMake Error at CMakeLists.txt:51 (target_link_libraries):
  Cannot specify link libraries for target "testlib" which is not built by this project.
  </code></pre>
  
  <p>It seems that source files (.c, cpp, etc) are absolutely required when linking in a library. But how do I link in an .so file? The docs say the following about target_link_libraries():</p>
  
  <p><i>The named  must have been created in the current directory by a command such as add_executable() or add_library().</i></p>
  
  <p>If I substitute add_library() with add_executable() I get the same error. What is the proper way to link an .so file in CMake?</p>