title: error LNK1181 in cmake project with static/shared libs
body: <p>We are trying to port our cmake project <a href="http://slam6d.sourceforge.net/" rel="nofollow noreferrer">3DTK</a> to Windows but are running into multiple LNK1181 errors. Here is the specific error message of one of them. A full error log can be retrieved from the <a href="https://ci.appveyor.com/project/josch/3dtk/branch/master" rel="nofollow noreferrer">appveyor CI</a>.</p>
  
  <pre><code>"C:\slam6d\ALL_BUILD.vcxproj" (default target) (1) -&gt;
  "C:\slam6d\src\scanserver\scanserver.vcxproj" (default target) (115) -&gt;
    LINK : fatal error LNK1181: cannot open input file '..\..\obj\scanclient.lib' [C:\slam6d\src\scanserver\scanserver.vcxproj]
  </code></pre>
  
  <p>Here are the relevant parts from the <code>CMakeLists.txt</code>. The full version is available in our svn <a href="https://sourceforge.net/p/slam6d/code/HEAD/tree/trunk/src/scanserver/CMakeLists.txt" rel="nofollow noreferrer">here</a>.</p>
  
  <pre><code>[...]
  
  add_library(scanclient_objects OBJECT ${CLIENT_SRCS})
  
  # compile with -fPIC so that the result can be made into a shared library
  set_property(TARGET scanclient_objects PROPERTY POSITION_INDEPENDENT_CODE 1)
  
  add_library(scanclient_static STATIC $&lt;TARGET_OBJECTS:scanclient_objects&gt;)
  add_library(scanclient_shared SHARED $&lt;TARGET_OBJECTS:scanclient_objects&gt;)
  
  set_target_properties(scanclient_static PROPERTIES OUTPUT_NAME scanclient CLEAN_DIRECT_OUTPUT 1)
  set_target_properties(scanclient_shared PROPERTIES OUTPUT_NAME scanclient CLEAN_DIRECT_OUTPUT 1)
  
  set(CLIENT_LIBS ${Boost_LIBRARIES} pointfilter)
  
  [...]
  
  target_link_libraries(scanclient_static ${CLIENT_LIBS} ${Boost_FILESYSTEM_LIBRARY})
  target_link_libraries(scanclient_shared ${CLIENT_LIBS} ${Boost_FILESYSTEM_LIBRARY})
  
  [...]
  
  add_executable(scanserver ${SERVER_SRCS})
  
  set(SERVER_LIBS ${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} scanclient_shared scanio_shared)
  
  [...]
  
  target_link_libraries(scanserver ${SERVER_LIBS})
  </code></pre>
  
  <p>There are several puzzeling things here:</p>
  
  <ol>
  <li>Why is the build of <code>scanserver</code> looking for <code>scanclient.lib</code>? It was instructed to link against the dynamic library and not the static library</li>
  <li>When looking at the the full build log, the static library it builds seems to be <code>scanclient32.lib</code>. What is the additional <code>32</code> doing in the filename and even if its auto-generated, why is the linker looking for <code>scanclient.lib</code>?</li>
  </ol>
  
  <p>The build succeeds on Linux and MacOS, so this problem is certainly MSVC specific. So why does linking fail and how can it be fixed?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As suggested by @Tsyvarev I tried removing the static scanclient library (See <a href="https://sourceforge.net/p/slam6d/code/1674/" rel="nofollow noreferrer">this changeset</a>) but the error persisted (see the corresponding <a href="https://ci.appveyor.com/project/josch/3dtk/build/1.0.49" rel="nofollow noreferrer">appveyor log</a> at the very bottom).</p>