← Back to team overview

kicad-developers team mailing list archive

[PATCH 3/4] Allow OpenMP with non-gcc compilers

 

This simply moves the OpenMP handling code out of the gcc specific block
with no code changes. This is safe because OpenMP detection is portable.
---
 CMakeLists.txt | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d09a459..ec89978 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -192,20 +192,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
     set( CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG" )
     set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG" )
 
-    find_package( OpenMP QUIET )
-
-    if( OPENMP_FOUND )
-        set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
-        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
-        add_definitions( -DUSE_OPENMP )
-
-        # MinGW does not include the OpenMP link library and FindOpenMP.cmake does not
-        # set it either.  Not sure this is the most elegant solution but it works.
-        if( MINGW )
-            set( OPENMP_LIBRARIES gomp )
-        endif()
-    endif()
-
     if( MINGW )
         set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
 
@@ -437,6 +423,25 @@ include( ExternalProject )
 #================================================
 include( CheckFindPackageResult )
 
+#######################
+# Find OpenMP support #
+#######################
+
+find_package( OpenMP QUIET )
+check_find_package_result( OPENMP_FOUND "OpenMP" )
+
+if( OPENMP_FOUND )
+    set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
+    set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
+    add_definitions( -DUSE_OPENMP )
+
+    # MinGW does not include the OpenMP link library and FindOpenMP.cmake does not
+    # set it either.  Not sure this is the most elegant solution but it works.
+    if( MINGW )
+        set( OPENMP_LIBRARIES gomp )
+    endif()
+endif()
+
 ##########################
 # Find wxWidgets library #
 ##########################

Follow ups

References