title: MacOS, CMake and OpenMP
body: <p>I am using the newest CMake (3.9.3) from Homebrew along with LLVM 5.0.0 also from Brew, because Clang here has OpenMP support.</p>
  
  <p>This worked in CMake 3.8.2 with LLVM 5.</p>
  
  <hr>
  
  <p>In my <code>CMakeLists.txt</code> I have </p>
  
  <pre><code>find_package( OpenMP )
  </code></pre>
  
  <p>and later I want to do</p>
  
  <pre><code>if( OpenMP_CXX_FOUND )
  </code></pre>
  
  <p>However CMake doesn't seem to pick up on the <code>find_package</code> directive. </p>
  
  <p>I run CMake with</p>
  
  <pre><code>cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DUSE_WERROR=ON
  </code></pre>
  
  <p>where I have checked that <code>clang</code> and <code>clang++</code> points correctly to <code>/usr/local/opt/llvm/bin/clang</code> and <code>/usr/local/opt/llvm/bin/clang++</code></p>
  
  <p>All I get is these two lines:</p>
  
  <pre><code>-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) (found version "1.0")
  -- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) (found version "1.0")
  </code></pre>
  
  <p>If I set <code>OpenMP_C_FLAGS</code> myself (with <code>-DOpenMP_C_FLAGS=-fopenmp=libomp</code>) it changes the error to</p>
  
  <pre><code>-- Could NOT find OpenMP_C (missing: OpenMP_C_LIB_NAMES) (found version "3.1")
  </code></pre>
  
  <p>Notice that it changes the version number, so it must be finding something, right?</p>
  
  <p>What am I missing for this to work properly?</p>
  
  <hr>
  
  <p>Okay, it seem that inside the <code>FindOpenMP.cmake</code> supplied by CMake we do a <code>try_compile</code>, which fails silently (because we do it a lot of times and most of them will fail, this makes sense). However, with Clang a <code>-Werror</code> flag is supplied, which fails because of an unused command line argument. I can thus add:</p>
  
  <pre><code>if(APPLE)
      if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
          set(OpenMP_C_FLAG "-fopenmp=libomp -Wno-unused-command-line-argument")
      endif()
      if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
          set(OpenMP_CXX_FLAG "-fopenmp=libomp -Wno-unused-command-line-argument")
      endif()
  endif()
  </code></pre>
  
  <p>to my project because I know that <code>-fopenmp=libomp</code> will work for this Clang.</p>
  
  <p>Is this the right way of doing it?</p>