[libc-commits] [libc] 1dfb0cd - [libc] Fix wrappergen_test.cpp on runtimes build
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Sun Dec 11 14:43:13 PST 2022
Author: Joseph Huber
Date: 2022-12-11T16:43:06-06:00
New Revision: 1dfb0cd703fe1ada21681283fd75e6aba4b7f216
URL: https://github.com/llvm/llvm-project/commit/1dfb0cd703fe1ada21681283fd75e6aba4b7f216
DIFF: https://github.com/llvm/llvm-project/commit/1dfb0cd703fe1ada21681283fd75e6aba4b7f216.diff
LOG: [libc] Fix wrappergen_test.cpp on runtimes build
The `tools` directory depends on `llvm_gtest` which is not immediately
availible with a runtimes build. This patch builds the `llvm_gtest`
target if it isn't present. Additionally, we use the CMake binary
directory to find the tool binary, which is different when using a
runtimes build. Using the LLVM binary directory should match both build
conditions.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D139348
Added:
Modified:
libc/test/utils/tools/CMakeLists.txt
libc/test/utils/tools/WrapperGen/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/test/utils/tools/CMakeLists.txt b/libc/test/utils/tools/CMakeLists.txt
index d685f27754cd4..5819f3933912d 100644
--- a/libc/test/utils/tools/CMakeLists.txt
+++ b/libc/test/utils/tools/CMakeLists.txt
@@ -33,4 +33,10 @@ function(add_libc_tool_unittest target_name)
target_link_libraries(${target_name} PRIVATE LLVMSupport)
endfunction()
+# Build the gtest library needed for unittests if we do not have it already.
+if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest AND NOT TARGET llvm_gtest)
+ include_directories(${LLVM_LIBC_INCLUDE_DIRS})
+ add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest third-party/unittest)
+endif()
+
add_subdirectory(WrapperGen)
diff --git a/libc/test/utils/tools/WrapperGen/CMakeLists.txt b/libc/test/utils/tools/WrapperGen/CMakeLists.txt
index 8f41badd48c46..0454f9ed81ee9 100644
--- a/libc/test/utils/tools/WrapperGen/CMakeLists.txt
+++ b/libc/test/utils/tools/WrapperGen/CMakeLists.txt
@@ -4,7 +4,7 @@ add_libc_tool_unittest(
wrappergen_test.cpp
ARGS
--path=${LIBC_SOURCE_DIR}
- --tool=${CMAKE_BINARY_DIR}/bin/libc-wrappergen
+ --tool=${LLVM_BINARY_DIR}/bin/libc-wrappergen
--api=${LIBC_SOURCE_DIR}/test/utils/tools/WrapperGen/testapi.td
)
More information about the libc-commits
mailing list