From e87258510567cb95800178dec30b058c885c326c Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Wed, 9 Dec 2015 15:53:52 -0500 Subject: [PATCH] CMake: move find OpenMP so it can be found for all compilers not just GCC. --- CMakeLists.txt | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0479c2431a..f612687ea7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,20 +180,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" ) @@ -425,6 +411,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 # ##########################