Skip to content

[offload] Fix enabling unittests in standalone builds #138418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 3, 2025

Conversation

mgorny
Copy link
Member

@mgorny mgorny commented May 3, 2025

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.

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`.
@llvmbot
Copy link
Member

llvmbot commented May 3, 2025

@llvm/pr-subscribers-offload

Author: Michał Górny (mgorny)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/138418.diff

1 Files Affected:

  • (modified) offload/CMakeLists.txt (+7-4)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 25c879710645c..ef10d9c949d0b 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -386,9 +386,12 @@ add_subdirectory(liboffload)
 add_subdirectory(test)
 
 # Add unit tests if GMock/GTest is present
-if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest)
-  if (NOT TARGET llvm_gtest)
-    add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
-  endif()
+if (NOT LLVM_THIRD_PARTY_DIR)
+  set(LLVM_THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../third-party")
+endif()
+if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest AND NOT TARGET llvm_gtest)
+  add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+endif()
+if (TARGET llvm_gtest)
   add_subdirectory(unittests)
 endif()

@mgorny mgorny merged commit d1e38ea into llvm:main May 3, 2025
7 of 9 checks passed
@mgorny mgorny deleted the offload-unittest branch May 3, 2025 18:06
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
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]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
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]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
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]>
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants