|
6 | 6 | # |
7 | 7 | #===------------------------------------------------------------------------===# |
8 | 8 |
|
| 9 | +# Target that depends on all unittests |
| 10 | +add_custom_target(FlangRTUnitTests) |
| 11 | +set_target_properties(FlangRTUnitTests PROPERTIES FOLDER "Flang-RT/Meta") |
| 12 | + |
9 | 13 | # LLVM uses a modified version of GTest that uses LLVMSupport for console |
10 | | -# output. Therefore it also needs to include files from LLVM. Unfortunately, |
11 | | -# LLVM/GTest doesn't add the include search path itself. Limiting the scope |
12 | | -# using target_include_directories does not work because with |
13 | | -# LLVM_INSTALL_GTEST=ON, as llvm_gtest is an IMPORT library. |
14 | | -include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}") |
15 | | - |
16 | | -# Add GTest if not already present. |
17 | | -# Using a function so LLVM_SUBPROJECT_TITLE does not propagate. |
18 | | -function (build_gtest) |
19 | | - set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test") |
20 | | - add_subdirectory("${LLVM_THIRD_PARTY_DIR}/unittest" "${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest") |
21 | | -endfunction () |
| 14 | +# output. We are using the pre-compiled GTest library from the LLVM build, |
| 15 | +# if available. Otherwise, do nothing. |
| 16 | + |
| 17 | +if (CMAKE_CROSSCOMPILING) |
| 18 | + # TODO: It is possible that LLVM_GTEST_RUN_UNDER defines an emulator or |
| 19 | + # ssh remote command invocation; for this case provide an option to |
| 20 | + # enable unittests. |
| 21 | + message(STATUS "Flang-RT unittests disabled because we are cross-compiling") |
| 22 | + return () |
| 23 | +endif () |
| 24 | + |
22 | 25 | if (NOT TARGET llvm_gtest) |
23 | | - build_gtest() |
| 26 | + message(WARNING "Flang-RT unittests disabled due to GTest being unavailable; " |
| 27 | + "Try LLVM_INSTALL_GTEST=ON for the LLVM build") |
| 28 | + return () |
24 | 29 | endif () |
25 | 30 |
|
| 31 | + |
| 32 | +add_dependencies(flang-rt-test-depends |
| 33 | + FlangRTUnitTests |
| 34 | + flang_rt.runtime.unittest |
| 35 | +) |
| 36 | + |
26 | 37 | if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) |
27 | 38 | add_compile_options("-Wno-suggest-override") |
28 | 39 | endif() |
29 | 40 |
|
30 | 41 |
|
31 | | -# Target that depends on all unittests |
32 | | -add_custom_target(FlangRTUnitTests) |
33 | | -set_target_properties(FlangRTUnitTests PROPERTIES FOLDER "Flang-RT/Meta") |
34 | | - |
35 | | - |
36 | 42 | function(add_flangrt_unittest_offload_properties target) |
37 | 43 | # Set CUDA_RESOLVE_DEVICE_SYMBOLS. |
38 | 44 | if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA") |
|
0 commit comments