1
# - Finds OpenMP support
2
# This module can be used to detect OpenMP support in a compiler.
3
# If the compiler supports OpenMP, the flags required to compile with
4
# openmp support are set.
6
# The following variables are set:
7
# OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support
8
# OPENMP_FOUND - true if openmp is detected
10
# Supported compilers can be found at http://openmp.org/wp/openmp-compilers/
12
# Modified for libsoxr not to rely on presence of C++ compiler.
14
#=============================================================================
15
# Copyright 2009 Kitware, Inc.
16
# Copyright 2008-2009 André Rigland Brodtkorb <Andre.Brodtkorb@ifi.uio.no>
18
# Redistribution and use in source and binary forms, with or without
19
# modification, are permitted provided that the following conditions are
22
# * Redistributions of source code must retain the above copyright notice,
23
# this list of conditions and the following disclaimer.
25
# * Redistributions in binary form must reproduce the above copyright notice,
26
# this list of conditions and the following disclaimer in the documentation
27
# and/or other materials provided with the distribution.
29
# * The names of Kitware, Inc., the Insight Consortium, or the names of
30
# any consortium members, or of any contributors, may not be used to
31
# endorse or promote products derived from this software without
32
# specific prior written permission.
34
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
35
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
38
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45
include (CheckCSourceCompiles)
46
include (FindPackageHandleStandardArgs)
48
set (OpenMP_C_FLAG_CANDIDATES
51
#Microsoft Visual Studio
57
#Empty, if compiler automatically accepts openmp
69
# sample openmp source code to test
70
set (OpenMP_C_TEST_SOURCE
81
# if these are set then do not try to find them again,
82
# by avoiding any try_compiles for the flags
83
if (DEFINED OpenMP_C_FLAGS)
84
set (OpenMP_C_FLAG_CANDIDATES)
85
endif (DEFINED OpenMP_C_FLAGS)
88
foreach (FLAG ${OpenMP_C_FLAG_CANDIDATES})
89
set (SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
90
set (CMAKE_REQUIRED_FLAGS "${FLAG}")
91
unset (OpenMP_FLAG_DETECTED CACHE)
92
message (STATUS "Try OpenMP C flag = [${FLAG}]")
93
check_c_source_compiles ("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
94
set (CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
95
if (OpenMP_FLAG_DETECTED)
96
set (OpenMP_C_FLAGS_INTERNAL "${FLAG}")
98
endif (OpenMP_FLAG_DETECTED)
99
endforeach (FLAG ${OpenMP_C_FLAG_CANDIDATES})
101
set (OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
102
CACHE STRING "C compiler flags for OpenMP parallization")
104
# handle the standard arguments for find_package
105
find_package_handle_standard_args (OpenMP DEFAULT_MSG
106
OpenMP_C_FLAGS OpenMP_C_FLAGS)
108
mark_as_advanced (OpenMP_C_FLAGS)