diff --git a/CMakeLists.txt b/CMakeLists.txt index f2d3d8f19d..e719d5c601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,10 +157,17 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) endif() 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 ) diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index aa04eb2f5c..47a5c3c111 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -116,6 +116,7 @@ if( USE_KIWAY_DLLS ) ${GLEW_LIBRARIES} ${CAIRO_LIBRARIES} ${PIXMAN_LIBRARY} + ${OPENMP_LIBRARIES} ) # Only for win32 cross compilation using MXE diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index ca49ce6f64..5c1583d711 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -536,6 +536,7 @@ if( USE_KIWAY_DLLS ) OUTPUT_NAME pcbnew PREFIX ${KIFACE_PREFIX} SUFFIX ${KIFACE_SUFFIX} + COMPILE_FLAGS ${OpenMP_CXX_FLAGS} ) target_link_libraries( pcbnew_kiface 3d-viewer @@ -557,6 +558,7 @@ if( USE_KIWAY_DLLS ) ${PIXMAN_LIBRARY} ${Boost_LIBRARIES} # must follow GITHUB ${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost + ${OPENMP_LIBRARIES} ) set_source_files_properties( pcbnew.cpp PROPERTIES # The KIFACE is in pcbnew.cpp, export it: