1if (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 10add_custom_target(FlangUnitTests) 11set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests") 12 13function(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 35function(add_flang_unittest test_dirname) 36 add_unittest(FlangUnitTests ${test_dirname} ${ARGN}) 37 add_flang_unittest_offload_properties(${test_dirname}) 38endfunction() 39 40if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) 41 add_compile_options("-Wno-suggest-override") 42endif() 43 44function(add_flang_nongtest_unittest test_name) 45 cmake_parse_arguments(ARG 46 "SLOW_TEST" 47 "" 48 "" 49 ${ARGN}) 50 51 if(ARG_SLOW_TEST) 52 set(suffix .slow) 53 else() 54 set(suffix .test) 55 endif() 56 57 add_executable(${test_name}${suffix} ${test_name}.cpp) 58 set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang/Tests/Unit") 59 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}) 66 67 if(NOT ARG_SLOW_TEST) 68 add_dependencies(FlangUnitTests ${test_name}${suffix}) 69 endif() 70 71 add_flang_unittest_offload_properties(${test_name}${suffix}) 72endfunction() 73 74add_subdirectory(Optimizer) 75add_subdirectory(Common) 76add_subdirectory(Decimal) 77add_subdirectory(Evaluate) 78add_subdirectory(Runtime) 79add_subdirectory(Frontend) 80