blob: 72d37ebeb853c5ba1d295b01d2cd70e2f6973c2b [file] [log] [blame]
Slava Zakharin9a53afd2023-07-13 18:18:581if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
2 # If Fortran runtime is built as CUDA library, the linking
3 # of targets that link FortranRuntime must be done
4 # with CUDA_RESOLVE_DEVICE_SYMBOLS.
5 # CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS
6 # to take effect.
7 enable_language(CUDA)
8endif()
9
sameeran joshi93f602b2020-06-02 17:15:4410add_custom_target(FlangUnitTests)
11set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang Unit Tests")
12
Slava Zakharin9a53afd2023-07-13 18:18:5813function(add_flang_unittest_offload_properties target)
14 # Set CUDA_RESOLVE_DEVICE_SYMBOLS.
15 if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
16 set_target_properties(${target}
17 PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON
18 )
19 endif()
20 # Enable OpenMP offload during linking. We may need to replace
21 # LINK_OPTIONS with COMPILE_OPTIONS when there are OpenMP offload
22 # unittests.
23 #
24 # FIXME: replace 'native' in --offload-arch option with the list
25 # of targets that Fortran Runtime was built for.
26 # Common code must be moved from flang/runtime/CMakeLists.txt.
27 if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
28 set_target_properties(${target}
29 PROPERTIES LINK_OPTIONS
30 "-fopenmp;--offload-arch=native"
31 )
32 endif()
33endfunction()
34
sameeran joshi93f602b2020-06-02 17:15:4435function(add_flang_unittest test_dirname)
36 add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
Slava Zakharin9a53afd2023-07-13 18:18:5837 add_flang_unittest_offload_properties(${test_dirname})
sameeran joshi93f602b2020-06-02 17:15:4438endfunction()
39
Logan Smith77e0e9e2020-07-23 00:44:5240if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
41 add_compile_options("-Wno-suggest-override")
42endif()
43
David Truby4ef2e592020-07-16 13:15:0744function(add_flang_nongtest_unittest test_name)
Serge Gueltoncde06f72020-10-05 19:35:3845 cmake_parse_arguments(ARG
46 "SLOW_TEST"
47 ""
48 ""
49 ${ARGN})
David Truby4ef2e592020-07-16 13:15:0750
Serge Gueltoncde06f72020-10-05 19:35:3851 if(ARG_SLOW_TEST)
52 set(suffix .slow)
53 else()
54 set(suffix .test)
55 endif()
David Truby4ef2e592020-07-16 13:15:0756
Serge Gueltoncde06f72020-10-05 19:35:3857 add_executable(${test_name}${suffix} ${test_name}.cpp)
58
59 if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
60 set(llvm_libs LLVM)
61 else()
62 llvm_map_components_to_libnames(llvm_libs Support)
63 endif()
64 target_link_libraries(${test_name}${suffix} ${llvm_libs} ${ARG_UNPARSED_ARGUMENTS})
65
66 if(NOT ARG_SLOW_TEST)
67 add_dependencies(FlangUnitTests ${test_name}${suffix})
68 endif()
Slava Zakharin9a53afd2023-07-13 18:18:5869
70 add_flang_unittest_offload_properties(${test_name}${suffix})
David Truby4ef2e592020-07-16 13:15:0771endfunction()
72
sameeran joshi93f602b2020-06-02 17:15:4473add_subdirectory(Optimizer)
Peter Klausler73b193a2022-02-16 21:26:4474add_subdirectory(Common)
CarolineConcatto64ab3302020-02-25 15:11:5275add_subdirectory(Decimal)
76add_subdirectory(Evaluate)
77add_subdirectory(Runtime)
Andrzej Warzynski7b73ca32021-07-12 08:44:3878add_subdirectory(Frontend)