title: CMake unresolved externals
body: <p>I am trying to compile a very simple CMake project using Visual Studio 2013, however I am getting the following error upon trying to compile it:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>error LNK1120: 1 unresolved externals   cmake_issue\build\Debug\cmake_issue.exe 1   1   cmake_issue
  error LNK2001: unresolved external symbol "public: static int Other::value" (?value@Other@@2HA) cmake_issue\build\test.obj  cmake_issue
  </code></pre>
  
  <p>I have a base directory with the following <code>CMakeLists.txt</code> in:</p>
  
  <pre><code>project(cmake_issue)
  add_subdirectory(other)
  add_executable(cmake_issue src/test.cc)
  target_link_libraries(cmake_issue other)
  </code></pre>
  
  <p>And the contents of <code>src/test.cc</code>:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;cstdio&gt;
  
  #include "other/other.h"
  
  int main(int argc, char *argv[]) {
      printf("value = %d\n", Other::value);
  
      return 0;
  }
  </code></pre>
  
  <p>And a subdirectory called <code>other</code> with the following <code>CMakeLists.txt</code> in:</p>
  
  <pre><code>add_library(other SHARED src/other.cc)
  target_include_directories(other PUBLIC include)
  target_link_libraries(other)
  </code></pre>
  
  <p>And the contents of <code>other/include/other/other.h</code>:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#ifndef _OTHER_H_
  #define _OTHER_H_
  
  class __declspec(dllexport) Other {
  public:
      static int value;
  };
  
  #endif
  </code></pre>
  
  <p>And the contents of <code>other/src/other.cc</code>:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "other/other.h"
  
  int Other::value = 30;
  </code></pre>
  
  <p>If I build the project with cmake and then open the generated sln in Visual Studio, both of the projects appear in the Solution Explorer.</p>
  
  <p>If I right click and build <code>other</code>, it builds fine. However if I try and build <code>cmake_issue</code>, I get the errors above. It looks like the <code>cmake_issue</code> solution is not using the <code>other.dll</code> (or <code>other.lib</code>) files being generated when compiling the <code>other</code> solution.</p>
  
  <p>I can upload a zip of the source if it is needed.</p>