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
10 add_custom_target(FlangUnitTests)
11 set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
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
20 # Enable OpenMP offload during linking. We may need to replace
21 # LINK_OPTIONS with COMPILE_OPTIONS when there are OpenMP offload
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"
35 function(add_flang_unittest test_dirname)
36 add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
37 add_flang_unittest_offload_properties(${test_dirname})
40 if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
41 add_compile_options("-Wno-suggest-override")
44 function(add_flang_nongtest_unittest test_name)
45 cmake_parse_arguments(ARG
57 add_executable(${test_name}${suffix} ${test_name}.cpp)
58 set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang/Tests/Unit")
60 if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
63 llvm_map_components_to_libnames(llvm_libs Support)
65 target_link_libraries(${test_name}${suffix} ${llvm_libs} ${ARG_UNPARSED_ARGUMENTS})
68 add_dependencies(FlangUnitTests ${test_name}${suffix})
71 add_flang_unittest_offload_properties(${test_name}${suffix})
74 add_subdirectory(Optimizer)
75 add_subdirectory(Common)
76 add_subdirectory(Decimal)
77 add_subdirectory(Evaluate)
78 add_subdirectory(Runtime)
79 add_subdirectory(Frontend)