mirror of https://github.com/llvm/circt.git
[cmake][CI] Use llvm_gtest target directly. (#5804)
Upstream now has option for installing these components for use in downstream standalone builds: llvm/llvm-project@0807986 . Look for (and prefer) this approach, and update our LLVM builds that we install to use this.
This commit is contained in:
parent
faf03b832b
commit
50cdf443ba
|
@ -57,7 +57,8 @@ jobs:
|
|||
-DLLVM_ENABLE_PROJECTS=mlir -DLLVM_BUILD_EXAMPLES=OFF `
|
||||
-DLLVM_TARGETS_TO_BUILD="host" `
|
||||
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON `
|
||||
-DLLVM_INSTALL_UTILS=ON -DCMAKE_INSTALL_PREFIX="$(pwd)/../install"
|
||||
-DLLVM_INSTALL_GTEST=ON -DLLVM_INSTALL_UTILS=ON `
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/../install"
|
||||
cmake --build . --target install --config Release
|
||||
# Grab llvm-lit.py from build tree, we need it.
|
||||
cp -v bin/llvm-lit.py ../install/bin/
|
||||
|
|
|
@ -84,12 +84,16 @@ endif ()
|
|||
# Handle unittests when building out-of-tree against an installed version of
|
||||
# LLVM/MLIR (not a build tree). Adapted from `llvm/flang/CMakeLists.txt`.
|
||||
set(CIRCT_GTEST_AVAILABLE 0)
|
||||
set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest)
|
||||
if (NOT EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
||||
set(UNITTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/llvm/third-party/unittest)
|
||||
endif()
|
||||
if (EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
||||
if (NOT TARGET llvm_gtest)
|
||||
if (TARGET llvm_gtest)
|
||||
# Installed gtest, via LLVM_INSTALL_GTEST. Preferred.
|
||||
message(STATUS "LLVM GTest found, enabling unittests")
|
||||
set(CIRCT_GTEST_AVAILABLE 1)
|
||||
else()
|
||||
set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest)
|
||||
if (NOT EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
||||
set(UNITTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/llvm/third-party/unittest)
|
||||
endif()
|
||||
if (EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
||||
find_package(Threads)
|
||||
add_llvm_library(llvm_gtest
|
||||
${UNITTEST_DIR}/googletest/src/gtest-all.cc
|
||||
|
@ -112,12 +116,12 @@ endif ()
|
|||
LINK_COMPONENTS Support # llvm::cl
|
||||
BUILDTREE_ONLY
|
||||
)
|
||||
set(CIRCT_GTEST_AVAILABLE 1)
|
||||
else()
|
||||
message(WARNING "Skipping unittests since LLVM install does not include \
|
||||
gtest headers and libraries")
|
||||
set(CIRCT_GTEST_AVAILABLE 0)
|
||||
endif()
|
||||
set(CIRCT_GTEST_AVAILABLE 1)
|
||||
else()
|
||||
message(WARNING "Skipping unittests since LLVM install does not include \
|
||||
gtest headers and libraries")
|
||||
set(CIRCT_GTEST_AVAILABLE 0)
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
|
|
@ -36,6 +36,7 @@ cmake ../llvm \
|
|||
-DLLVM_ENABLE_OCAMLDOC=OFF \
|
||||
-DLLVM_ENABLE_PROJECTS='mlir' \
|
||||
-DLLVM_INSTALL_UTILS=ON \
|
||||
-DLLVM_INSTALL_GTEST=ON \
|
||||
-DLLVM_OPTIMIZED_TABLEGEN=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="host" \
|
||||
$EXTRA_ARGS
|
||||
|
|
Loading…
Reference in New Issue