title: What is the proper use of CMake FindThreads with modern C++?
body: <p>The source for the CMake (<a href="https://github.com/Kitware/CMake/blob/master/Modules/FindThreads.cmake" rel="noreferrer">https://github.com/Kitware/CMake/blob/master/Modules/FindThreads.cmake</a>) claims the following about the "FindThreads" functionality:</p>
  
  <blockquote>
    <p>This module is not needed for C++11 and later if threading is done using
    <code>std::thread</code> from the standard library.</p>
  </blockquote>
  
  <p>But if I follow this advice (on my Mint18 x86_64 system, gcc8, CMake 3.13.2) I get:</p>
  
  <pre><code>/usr/bin/ld: CMakeFiles/prism-esm-dummy.dir/src/main.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
  //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>If the module is exercised (as best I could figure using other SO articles and previously given advice):</p>
  
  <pre><code>set (THREADS_PREFER_PTHREAD_FLAG ON)
  find_package (Threads REQUIRED)
  
  add_executable(my_app main.cpp)
  target_link_libraries (my_app Threads::Threads)
  </code></pre>
  
  <p>... the result is the same.</p>
  
  <p><code>THREADS_FOUND</code> is <code>true</code> and <code>CMAKE_USE_PTHREADS_INIT</code> is <code>1</code>, but i get no <code>-pthread</code> under compile, or a <code>-lpthread</code> during link.  I checked a number of other variables mentioned in the module, and all I tried were not set.</p>
  
  <p>Is there a correct way to do this?  Or should I just use the normal flags and move on with my life?</p>