Files
acceptance-tests
data
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
nuget
openmp
cmake
libomptarget
offload
runtime
cmake
LibompCheckFortranFlag.cmake
LibompCheckLinkerFlag.cmake
LibompDefinitions.cmake
LibompExports.cmake
LibompGetArchitecture.cmake
LibompHandleFlags.cmake
LibompMicroTests.cmake
LibompUtils.cmake
config-ix.cmake
doc
src
test
tools
.clang-format
CMakeLists.txt
README.txt
www
.arcconfig
.gitignore
CMakeLists.txt
CREDITS.txt
LICENSE.txt
README.rst
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm-project/openmp/runtime/cmake/LibompCheckFortranFlag.cmake

74 lines
2.7 KiB
CMake
Raw Normal View History

#
#//===----------------------------------------------------------------------===//
#//
#// The LLVM Compiler Infrastructure
#//
#// This file is dual licensed under the MIT and the University of Illinois Open
#// Source Licenses. See LICENSE.txt for details.
#//
#//===----------------------------------------------------------------------===//
#
# Checking a fortran compiler flag
# There is no real trivial way to do this in CMake, so we implement it here
# this will have ${boolean} = TRUE if the flag succeeds, otherwise false.
function(libomp_check_fortran_flag flag boolean)
if(NOT DEFINED "${boolean}")
set(retval TRUE)
set(fortran_source
" program hello
print *, \"Hello World!\"
end program hello")
set(failed_regexes "[Ee]rror;[Uu]nknown;[Ss]kipping")
if(CMAKE_VERSION VERSION_GREATER 3.1 OR CMAKE_VERSION VERSION_EQUAL 3.1)
include(CheckFortranSourceCompiles)
check_fortran_source_compiles("${fortran_source}" ${boolean} FAIL_REGEX "${failed_regexes}")
set(${boolean} ${${boolean}} PARENT_SCOPE)
return()
else()
# Our manual check for cmake versions that don't have CheckFortranSourceCompiles
set(base_dir ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/fortran_flag_check)
file(MAKE_DIRECTORY ${base_dir})
file(WRITE ${base_dir}/fortran_source.f "${fortran_source}")
message(STATUS "Performing Test ${boolean}")
execute_process(
COMMAND ${CMAKE_Fortran_COMPILER} "${flag}" ${base_dir}/fortran_source.f
WORKING_DIRECTORY ${base_dir}
RESULT_VARIABLE exit_code
OUTPUT_VARIABLE OUTPUT
ERROR_VARIABLE OUTPUT
)
if(${exit_code} EQUAL 0)
foreach(regex IN LISTS failed_regexes)
if("${OUTPUT}" MATCHES ${regex})
set(retval FALSE)
endif()
endforeach()
else()
set(retval FALSE)
endif()
if(${retval})
set(${boolean} 1 CACHE INTERNAL "Test ${boolean}")
message(STATUS "Performing Test ${boolean} - Success")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing Fortran Compiler Flag test ${boolean} succeeded with the following output:\n"
"${OUTPUT}\n"
"Source file was:\n${fortran_source}\n")
else()
set(${boolean} "" CACHE INTERNAL "Test ${boolean}")
message(STATUS "Performing Test ${boolean} - Failed")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Fortran Compiler Flag test ${boolean} failed with the following output:\n"
"${OUTPUT}\n"
"Source file was:\n${fortran_source}\n")
endif()
endif()
set(${boolean} ${retval} PARENT_SCOPE)
endif()
endfunction()