From 77971c42e49f7ed29b260b8da6542b05fa9024b6 Mon Sep 17 00:00:00 2001 From: Brian Gerkey Date: Tue, 28 Dec 2010 17:41:17 +0000 Subject: [PATCH] applied patch to use standard OpenMP detection, #3184 --- core/rosbuild/public.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/rosbuild/public.cmake b/core/rosbuild/public.cmake index b2fc93b4..be91a99c 100644 --- a/core/rosbuild/public.cmake +++ b/core/rosbuild/public.cmake @@ -965,6 +965,15 @@ macro(rosbuild_add_openmp_flags target) _rosbuild_warn("because ROS_TEST_COVERAGE is set, OpenMP support is disabled") else("$ENV{ROS_TEST_COVERAGE}" STREQUAL "1") + # First, try to use the standard FindOpenMP module (#3184). If that + # fails, fall back on manual detection. I don't know why the standard + # detection would ever fail; it's possible that the manual + # detection is now vestigial and could be removed. + include(FindOpenMP) + if(${OPENMP_FOUND} STREQUAL "TRUE") + rosbuild_add_compile_flags(${target} ${OpenMP_C_FLAGS}) + rosbuild_add_link_flags(${target} ${OpenMP_C_FLAGS}) + else(${OPENMP_FOUND} STREQUAL "TRUE") # list of OpenMP flags to check set(_rospack_check_openmp_flags "-fopenmp" # gcc @@ -987,7 +996,7 @@ macro(rosbuild_add_openmp_flags target) if(NOT _rospack_openmp_flag_found) set(CMAKE_REQUIRED_FLAGS ${_rospack_openmp_test_flag}) check_function_exists(omp_set_num_threads _rospack_openmp_function_found${_rospack_openmp_test_flag}) - + if(_rospack_openmp_function_found${_rospack_openmp_test_flag}) set(_rospack_openmp_flag_value ${_rospack_openmp_test_flag}) set(_rospack_openmp_flag_found TRUE) @@ -1006,6 +1015,7 @@ macro(rosbuild_add_openmp_flags target) message("WARNING: OpenMP compile flag not found") endif(_rospack_openmp_flag_found) + endif(${OPENMP_FOUND} STREQUAL "TRUE") endif("$ENV{ROS_TEST_COVERAGE}" STREQUAL "1") endmacro(rosbuild_add_openmp_flags)