xref: /llvm-project/openmp/runtime/cmake/LibompCheckFortranFlag.cmake (revision 5e2358c781b85a18d1463fd924d2741d4ae5e42e)
1#
2#//===----------------------------------------------------------------------===//
3#//
4#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5#// See https://llvm.org/LICENSE.txt for license information.
6#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7#//
8#//===----------------------------------------------------------------------===//
9#
10
11# Checking a fortran compiler flag
12# There is no real trivial way to do this in CMake, so we implement it here
13# this will have ${boolean} = TRUE if the flag succeeds, otherwise false.
14function(libomp_check_fortran_flag flag boolean)
15  if(NOT DEFINED "${boolean}")
16    set(retval TRUE)
17    set(fortran_source
18"      program hello
19           print *, \"Hello World!\"
20      end program hello")
21
22    # Compiling as a part of runtimes introduces ARCH-unknown-linux-gnu as a
23    # part of a working directory.  So adding a guard for unknown.
24    set(failed_regexes "[Ee]rror;[Uu]nknown[^-];[Ss]kipping")
25    include(CheckFortranSourceCompiles)
26    check_fortran_source_compiles("${fortran_source}" ${boolean} FAIL_REGEX "${failed_regexes}")
27    set(${boolean} ${${boolean}} PARENT_SCOPE)
28  endif()
29endfunction()
30