Browse Source

Set OpenMP flags for mac

pull/2/head
Andy McAliley 5 years ago
parent
commit
e89827a232
1 changed files with 32 additions and 24 deletions
  1. 32
    24
      CMakeLists.txt

+ 32
- 24
CMakeLists.txt View File

@@ -306,38 +306,46 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
306 306
 
307 307
 if (LEMMA_USE_OPENMP)
308 308
 
309
-            #    if(APPLE)
310
-            #if(CMAKE_C_COMPILER_ID MATCHES "Clang")
311
-            #set(OpenMP_C "${CMAKE_C_COMPILER}")
312
-            #set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
313
-            #set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
314
-            #set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
315
-            #set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
316
-            #set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
317
-            #endif()
318
-            #        if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
319
-            #            set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
320
-            #            set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
321
-            #" -DOpenMP_CXX_LIB_NAMES=\"omp\" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib ")
322
-            #            set(OpenMP_CXX_LIB_NAMES "omp") # "libgomp" "libiomp5")
323
-            #            set(OpenMP_libomp_LIBRARY "/usr/local/opt/libomp/lib/libomp.dylib") #${OpenMP_CXX_LIB_NAMES})
324
-            #set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
325
-            #set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
326
-            #        endif()
327
-            #    endif()
309
+    if(APPLE)
310
+        if(CMAKE_C_COMPILER_ID MATCHES "Clang")
311
+            set(OpenMP_C "${CMAKE_C_COMPILER}")
312
+            set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
313
+            set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
314
+            set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
315
+            set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
316
+            set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
317
+        endif()
318
+        if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
319
+            set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
320
+            set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
321
+            set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
322
+            set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
323
+            set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
324
+            set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
325
+    #         set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
326
+    #         " -DOpenMP_CXX_LIB_NAMES=\"omp\" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib ")
327
+    #         set(OpenMP_CXX_LIB_NAMES "omp") # "libgomp" "libiomp5")
328
+    #         set(OpenMP_libomp_LIBRARY "/usr/local/opt/libomp/lib/libomp.dylib") #${OpenMP_CXX_LIB_NAMES})
329
+    #         set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
330
+    #         set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
331
+        endif()
332
+    endif()
328 333
 
329 334
     if (CMAKE_CROSSCOMPILING)
330 335
         set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
331 336
         set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
332 337
         set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
333
-        add_definitions(-DLEMMAUSEOMP) # -DEIGEN_DONT_VECTORIZE )
334 338
     else()
335 339
         find_package(OpenMP REQUIRED)
336
-        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
337
-        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
338
-        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
339
-        add_definitions(-DLEMMAUSEOMP) # -DEIGEN_DONT_VECTORIZE)
340
+        if (OPENMP_FOUND)
341
+            # include_directories("${OPENMP_INCLUDES}")
342
+            link_directories("${OPENMP_LIBRARIES}")
343
+            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
344
+            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
345
+            set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
346
+        endif()
340 347
     endif()
348
+    add_definitions(-DLEMMAUSEOMP) # -DEIGEN_DONT_VECTORIZE)
341 349
 endif()
342 350
 
343 351
 configure_file (

Loading…
Cancel
Save