[OpenACC] Enable 'attach' clause for combined constructs
[llvm-project.git] / flang / unittests / CMakeLists.txt
blob945067fed4f82d0ffc5916dfb58f7d7a2b4ab006
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()
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
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()
35 function(add_flang_unittest test_dirname)
36   add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
37   add_flang_unittest_offload_properties(${test_dirname})
38 endfunction()
40 if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
41   add_compile_options("-Wno-suggest-override")
42 endif()
44 function(add_flang_nongtest_unittest test_name)
45   cmake_parse_arguments(ARG
46     "SLOW_TEST"
47     ""
48     ""
49     ${ARGN})
51   if(ARG_SLOW_TEST)
52       set(suffix .slow)
53   else()
54       set(suffix .test)
55   endif()
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)
61     set(llvm_libs LLVM)
62   else()
63     llvm_map_components_to_libnames(llvm_libs Support)
64   endif()
65   target_link_libraries(${test_name}${suffix} ${llvm_libs} ${ARG_UNPARSED_ARGUMENTS})
67   if(NOT ARG_SLOW_TEST)
68     add_dependencies(FlangUnitTests ${test_name}${suffix})
69   endif()
71   add_flang_unittest_offload_properties(${test_name}${suffix})
72 endfunction()
74 add_subdirectory(Optimizer)
75 add_subdirectory(Common)
76 add_subdirectory(Decimal)
77 add_subdirectory(Evaluate)
78 add_subdirectory(Runtime)
79 add_subdirectory(Frontend)