title: C++ internal CMake error with checking pthread
body: <p>I have CMakeLists.txt with the following instructions:</p>
  <pre><code>set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  set(THREADS_PREFER_PTHREAD_FLAG TRUE)
  find_package(Threads REQUIRED)
  
  ...
  target_link_libraries(zipkin Threads::Threads ${CURL_LIBRARIES} ${WIN32_LIBRARIES})
  </code></pre>
  <p>But when I try to build it, I have the following errors in the CMakeError.log:</p>
  <pre><code>13 CMakeFiles/cmTC_78fe1.dir/CheckSymbolExists.c.o: In function `main':
  14 CheckSymbolExists.c:(.text+0x1b): undefined reference to `pthread_create'
  15 collect2: error: ld returned 1 exit status
  16 CMakeFiles/cmTC_78fe1.dir/build.make:97: recipe for target 'cmTC_78fe1' failed
  17 make[2]: *** [cmTC_78fe1] Error 1
  18 make[2]: Leaving directory '/home/vbalun/Desktop/dsp/dsp-deps/zipkin-cpp-opentracing/build/CMakeFiles/CMakeTmp'
  19 Makefile:126: recipe for target 'cmTC_78fe1/fast' failed
  20 make[1]: *** [cmTC_78fe1/fast] Error 2
  21 make[1]: Leaving directory '/home/vbalun/Desktop/dsp/dsp-deps/zipkin-cpp-opentracing/build/CMakeFiles/CMakeTmp'
  22 
  23 File /home/vbalun/Desktop/dsp/dsp-deps/zipkin-cpp-opentracing/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
  24 /* */
  25 #include &lt;pthread.h&gt;
  26 
  27 int main(int argc, char** argv)
  28 {
  29   (void)argv;
  30 #ifndef pthread_create
  31   return ((int*)(&amp;pthread_create))[argc];
  32 #else
  33   (void)argc;
  34   return 0;
  35 #endif
  36 }
  </code></pre>
  <p>CMake creates new temp file for checking pthread and I think It's internal CMake error, but how can I fix it?
  CMake(3.10.2) and Ubuntu(18.04)</p>