-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
101 lines (97 loc) · 3.93 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Put Fortran module files in separate directories.
#
# Several Fortran tests build modules with the same name at build-time.
# To avoid module filename conflict, this function forces module files
# to be put in per-executable directories.
#
# This function should be called after llvm_singlesource in the per-
# directory CMakeLists.txt. This has effect for all executables added
# by llvm_singlesource.
#
# This feature may be integrated to the llvm_singlesource function once
# the Fujitsu Compiler Test Suite is integrated to the LLVM test-suite.
function(llvm_set_own_fortran_module_directory)
get_directory_property(targets BUILDSYSTEM_TARGETS)
foreach(target ${targets})
set_target_properties(${target} PROPERTIES Fortran_MODULE_DIRECTORY "${target}.d")
endforeach()
endfunction()
# Set test programs in a directory as compile-only.
#
# Each source file in the specified directory is compiled into an executable
# but it is not run.
#
# This function should be called instead of llvm_singlesource in the per-
# directory CMakeLists.txt.
function(llvm_singlesource_compile_only_directory)
# Optional `PREFIX` argument. Same as llvm_singlesource.
cmake_parse_arguments(_LSARG "" "PREFIX" "" ${ARGN})
# If the `Source` list variable is defined, compile only the specified
# source files. If not, find C/C++/Fortran source files. Same as
# llvm_singlesource.
if(DEFINED Source)
set(sources ${Source})
else()
file(GLOB sources
*.c *.cpp *.cc
*.for *.FOR *.fpp *.FPP *.[fF] *.[fF]90 *.[fF]95 *.[fF]03 *.[fF]08)
endif()
foreach(source ${sources})
basename(name ${source})
set(target ${_LSARG_PREFIX}${name})
llvm_test_executable_no_test(${target} ${source})
endforeach()
endfunction()
# Set a test program as compile-only.
#
# The specified source file is compiled into an executable but it is
# not run.
#
# This function should be called before llvm_singlesource in the per-
# directory CMakeLists.txt because this function sets `Source` variable
# and which is used in llvm_singlesource.
function(llvm_singlesource_compile_only_file filename)
# Optional `PREFIX` argument. Same as llvm_singlesource.
cmake_parse_arguments(_LSARG "" "PREFIX" "" ${ARGN})
# If the `Source` list variable is defined, llvm_singlesource will use
# it as a set of source files to compile and run. If it is defined,
# we need to remove the specified source file from it. If not, we need
# to set it to source files other than the specified source file.
if(DEFINED Source)
set(sources ${Source})
else()
file(GLOB sources
*.c *.cpp *.cc
*.for *.FOR *.fpp *.FPP *.[fF] *.[fF]90 *.[fF]95 *.[fF]03 *.[fF]08)
endif()
foreach(source ${sources})
get_filename_component(fname ${source} NAME)
if(fname STREQUAL filename)
basename(name ${source})
set(target ${_LSARG_PREFIX}${name})
llvm_test_executable_no_test(${target} ${source})
list(REMOVE_ITEM sources "${source}")
endif()
endforeach()
set(Source "${sources}" PARENT_SCOPE)
endfunction()
option(TEST_SUITE_FUJITSU_FORCE_UNSUPPORTED_PLATFORM
"Force to enable the Fujitsu Compiler Test Suite on unsupported platforms. Currently only Linux/AArch64 is supported."
OFF)
# Most test programs in this test suite will be able to run on many
# platforms (OS/CPU). However, because it was originally developed
# for Fujitsu C/C++/Fortran compilers, which target Linux/AArch64,
# it may contain test programs which don't run on platforms other than
# Linux/AArch64.
if(LINUX OR TEST_SUITE_FUJITSU_FORCE_UNSUPPORTED_PLATFORM)
if(ARCH STREQUAL "AArch64" OR TEST_SUITE_FUJITSU_FORCE_UNSUPPORTED_PLATFORM)
add_subdirectory(C)
if(TEST_SUITE_FORTRAN)
# CMake supports LLVM Flang since 3.24.0 and supports `.f03` and `.f08`
# filename suffixes since 3.27.0.
cmake_minimum_required(VERSION 3.27.0)
add_subdirectory(Fortran)
endif()
file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif()
endif()