Slava Zakharin | 9a53afd | 2023-07-13 18:18:58 | [diff] [blame] | 1 | if (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) |
| 8 | endif() |
| 9 | |
sameeran joshi | 93f602b | 2020-06-02 17:15:44 | [diff] [blame] | 10 | add_custom_target(FlangUnitTests) |
| 11 | set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang Unit Tests") |
| 12 | |
Slava Zakharin | 9a53afd | 2023-07-13 18:18:58 | [diff] [blame] | 13 | function(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() |
| 33 | endfunction() |
| 34 | |
sameeran joshi | 93f602b | 2020-06-02 17:15:44 | [diff] [blame] | 35 | function(add_flang_unittest test_dirname) |
| 36 | add_unittest(FlangUnitTests ${test_dirname} ${ARGN}) |
Slava Zakharin | 9a53afd | 2023-07-13 18:18:58 | [diff] [blame] | 37 | add_flang_unittest_offload_properties(${test_dirname}) |
sameeran joshi | 93f602b | 2020-06-02 17:15:44 | [diff] [blame] | 38 | endfunction() |
| 39 | |
Logan Smith | 77e0e9e | 2020-07-23 00:44:52 | [diff] [blame] | 40 | if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) |
| 41 | add_compile_options("-Wno-suggest-override") |
| 42 | endif() |
| 43 | |
David Truby | 4ef2e59 | 2020-07-16 13:15:07 | [diff] [blame] | 44 | function(add_flang_nongtest_unittest test_name) |
Serge Guelton | cde06f7 | 2020-10-05 19:35:38 | [diff] [blame] | 45 | cmake_parse_arguments(ARG |
| 46 | "SLOW_TEST" |
| 47 | "" |
| 48 | "" |
| 49 | ${ARGN}) |
David Truby | 4ef2e59 | 2020-07-16 13:15:07 | [diff] [blame] | 50 | |
Serge Guelton | cde06f7 | 2020-10-05 19:35:38 | [diff] [blame] | 51 | if(ARG_SLOW_TEST) |
| 52 | set(suffix .slow) |
| 53 | else() |
| 54 | set(suffix .test) |
| 55 | endif() |
David Truby | 4ef2e59 | 2020-07-16 13:15:07 | [diff] [blame] | 56 | |
Serge Guelton | cde06f7 | 2020-10-05 19:35:38 | [diff] [blame] | 57 | 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 Zakharin | 9a53afd | 2023-07-13 18:18:58 | [diff] [blame] | 69 | |
| 70 | add_flang_unittest_offload_properties(${test_name}${suffix}) |
David Truby | 4ef2e59 | 2020-07-16 13:15:07 | [diff] [blame] | 71 | endfunction() |
| 72 | |
sameeran joshi | 93f602b | 2020-06-02 17:15:44 | [diff] [blame] | 73 | add_subdirectory(Optimizer) |
Peter Klausler | 73b193a | 2022-02-16 21:26:44 | [diff] [blame] | 74 | add_subdirectory(Common) |
CarolineConcatto | 64ab330 | 2020-02-25 15:11:52 | [diff] [blame] | 75 | add_subdirectory(Decimal) |
| 76 | add_subdirectory(Evaluate) |
| 77 | add_subdirectory(Runtime) |
Andrzej Warzynski | 7b73ca3 | 2021-07-12 08:44:38 | [diff] [blame] | 78 | add_subdirectory(Frontend) |