title: How do I tell CMake to link in a static library in the source directory?
body: <p>I have a small project with a Makefile which I'm trying to convert to CMake, mostly just to get experience with CMake. For purposes of this example, the project contains a source file (C++, though I don't think the language is particularly relevant) and a static library file which I've copied from elsewhere. Assume for argument's sake that the source code to the library is unavailable; I only have the .a file and the corresponding header.</p>
  
  <p>My handmade Makefile contains this build rule:</p>
  
  <pre><code>main: main.o libbingitup.a
      g++ -o main main.o libbingitup.a
  </code></pre>
  
  <p>which works fine. How do I tell CMake to reproduce this? Not literally this exact makefile, of course, but something that includes an equivalent linking command. I've tried the obvious but naive ways, like</p>
  
  <pre><code>add_executable(main main.cpp libbingitup.a)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>add_executable(main main.cpp)
  target_link_libraries(main libbingitup.a)
  </code></pre>
  
  <p>as well as various things with <code>link_directories(.)</code> or <code>add_library(bingitup STATIC IMPORTED)</code> etc. but nothing so far that results in a successful linkage. What should I be doing?</p>
  
  <hr>
  
  <p>Version details: CMake 2.8.7 on Linux (Kubuntu 12.04) with GCC 4.6.3</p>