Hi,

Attached is a patch to add the correct option for building OpenMP code using 
Clang. Per the llvm release notes 
<http://llvm.org/releases/3.7.0/tools/clang/docs/ReleaseNotes.html> it is 
necessary to give -fopenmp=libomp to build properly, not just -fopenmp. Tested 
on 64-bit Linux using clang 3.7.0.

Chris

>From f80164de4b51afc7cdcc053346c696ea2baaa4a4 Mon Sep 17 00:00:00 2001
From: Chris Pavlina <pavlina.ch...@gmail.com>
Date: Thu, 10 Dec 2015 10:40:27 -0500
Subject: [PATCH] Add Clang support to FindOpenMP

---
 Modules/FindOpenMP.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index a102c66..ee4bdd6 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -50,6 +50,8 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
     " "
     #GNU
     "-fopenmp"
+    #Clang
+    "-fopenmp=libomp"
     #Microsoft Visual Studio
     "/openmp"
     #Intel windows
@@ -67,6 +69,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
   )
 
   set(OMP_FLAG_GNU "-fopenmp")
+  set(OMP_FLAG_Clang "-fopenmp=libomp")
   set(OMP_FLAG_HP "+Oopenmp")
   if(WIN32)
     set(OMP_FLAG_Intel "-Qopenmp")
-- 
2.6.4

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to