Skip to content

Commit d1e38ea

Browse files
mgornyjhuber6
andauthored
[offload] Fix enabling unittests in standalone builds (#138418)
Modify the unittest logic in offload to only look for `third-party/unittest` directory when `llvm_gtest` is not provided by LLVM itself (in-tree or installed). This makes it possible to run unittests in sparse checkouts without the `third-party/unittest` tree. While at it, also make sure `LLVM_THIRD_PARTY_DIR` is actually set while performing standalone builds. The logic is copied from `compiler-rt`. --------- Co-authored-by: Joseph Huber <[email protected]>
1 parent ea08dd8 commit d1e38ea

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

offload/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,12 @@ add_subdirectory(liboffload)
386386
add_subdirectory(test)
387387

388388
# Add unit tests if GMock/GTest is present
389-
if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest)
390-
if (NOT TARGET llvm_gtest)
391-
add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
392-
endif()
389+
if(NOT LLVM_THIRD_PARTY_DIR)
390+
set(LLVM_THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../third-party")
391+
endif()
392+
if(EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest AND NOT TARGET llvm_gtest)
393+
add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
394+
endif()
395+
if(TARGET llvm_gtest)
393396
add_subdirectory(unittests)
394397
endif()

0 commit comments

Comments
 (0)