title: CMake : multiple subprojects using the same static library
body: <p>I'm using cmake to compile one of my work projets, here is the deal</p>
  
  <pre><code>-
    client/
      CMakeLists.txt
    server/
      CMakeLists.txt
    libs/
      libstuff/
        CMakeLists.txt
    CMakeLists.txt
  </code></pre>
  
  <p>So i want to be able to compile each subproject individually, and build both the client and the server from the root folder.</p>
  
  <p>Let's say the client and the server need libstuff.</p>
  
  <p>I tried to use "add_subdirectory" with the path of the lib in both client and server CMakeLists.txt, it works when you compile the server or the client, but if you try to run both from the root directory :</p>
  
  <pre><code>CMake Error at common/libplugin/CMakeLists.txt:33 (ADD_LIBRARY):
    add_library cannot create target "plugin" because another target with the
    same name already exists.  The existing target is a static library created
    in source directory "/home/adrien/git/r-type/common/libplugin".  See
    documentation for policy CMP0002 for more details.
  </code></pre>
  
  <p>So i'm kind of new w/ cmake and i'm not sure what i should do, should i use add_dependencies?</p>
  
  <p>Thanks for your help,</p>