title: link pthread statically with cmake
body: <p>How can I get CMake to link <code>pthread</code> statically on Windows? I use <code>MSYS2 MinGW 32 bit</code> and <code>cmake</code> v3.7.</p>
  
  <p>What I would like to achieve is a compiler invocation like </p>
  
  <pre><code>g++ -static-libgcc -static-libstdc++ -std=c++11 -o test test.cpp -Wl,-Bstatic -lpthread
  </code></pre>
  
  <p>Setting </p>
  
  <pre><code>target_link_libraries(test PUBLIC "-Wl,-Bstatic -lpthread")
  </code></pre>
  
  <p>results in <code>-Wl,-Bdynamic -Wl,-Bstatic -lpthread</code> being called. If I change <code>CMAKE_EXE_LINKER_FLAGS</code>, <code>pthreads</code> is included before my object files and thus symbols are not resolved. </p>