Skip to content

Commit

Permalink
#9332: fetch gtest via CPM
Browse files Browse the repository at this point in the history
  • Loading branch information
TT-billteng committed Jun 11, 2024
1 parent 4a10bfb commit d0f1d5c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 32 deletions.
9 changes: 0 additions & 9 deletions .github/actions/install-metal-dev-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ runs:
tar -xvf doxygen-1.9.6.linux.bin.tar.gz
cd doxygen-1.9.6
sudo make install
- name: Install gtest
shell: bash
run: |
curl -L "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz" -o v1.13.0.tar.gz
tar -xvf v1.13.0.tar.gz
cd googletest-1.13.0
cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON .
make
sudo make install
- name: Install Clang-17
shell: bash
run: |
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ CHECK_COMPILERS()
# Find all required libraries to build
############################################################################################################################
include(${PROJECT_SOURCE_DIR}/cmake/CPM_boost.cmake)
find_package(GTest REQUIRED)
find_package (Python3 COMPONENTS Interpreter Development)
find_library(NUMA_LIBRARY NAMES numa)
if (NOT NUMA_LIBRARY)
message(FATAL_ERROR "NUMA library not found")
endif()

CPMAddPackage(
NAME googletest
GITHUB_REPOSITORY google/googletest
GIT_TAG release-1.12.1
VERSION 1.12.1
OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt ON"
)


############################################################################################################################
# Setting build type flags
# Will default to assert build, unless CONFIG env variable is set or manually set -DCMAKE_BUILD_TYPE
Expand Down
2 changes: 0 additions & 2 deletions INSTALLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,3 @@ sudo apt install git git-lfs cmake=3.16.3-1ubuntu1.20.04.1 pandoc libtbb-dev lib
```

2. Download and install [Doxygen](https://www.doxygen.nl/download.html), (v1.9 or higher, but less than v1.10)

3. Download and install [gtest](https://github.com/google/googletest) from source (v1.13)
3 changes: 1 addition & 2 deletions dockerfile/ubuntu-20.04-amd64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive
ENV GTEST_VERSION=1.13.0
ENV DOXYGEN_VERSION=1.9.6

# Install build and runtime deps
Expand All @@ -19,7 +18,7 @@ RUN apt-get -y update \

## Test Related Dependencies
COPY /scripts/docker/install_test_deps.sh /opt/tt_metal_infra/scripts/docker/install_test_deps.sh
RUN /bin/bash /opt/tt_metal_infra/scripts/docker/install_test_deps.sh ${GTEST_VERSION} ${DOXYGEN_VERSION}
RUN /bin/bash /opt/tt_metal_infra/scripts/docker/install_test_deps.sh ${DOXYGEN_VERSION}

# Copy remaining convenience scripts
COPY /scripts /opt/tt_metal_infra/scripts
Expand Down
17 changes: 3 additions & 14 deletions scripts/docker/install_test_deps.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
#!/bin/bash

# Check if two arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <gtest_version> <doxygen_version>"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <doxygen_version>"
exit 1
fi

GTEST_VERSION=$1
DOXYGEN_VERSION=$2

# Installs Google test
mkdir -p /opt/tt_metal_infra/googletest
chmod ugo+w /opt/tt_metal_infra/googletest
wget -O /opt/tt_metal_infra/googletest/googletest-release-${GTEST_VERSION}.tar.gz https://github.com/google/googletest/archive/refs/tags/v${GTEST_VERSION}.tar.gz
tar -xzf /opt/tt_metal_infra/googletest/googletest-release-${GTEST_VERSION}.tar.gz -C /opt/tt_metal_infra/googletest/
cd /opt/tt_metal_infra/googletest/googletest-${GTEST_VERSION}
cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON .
make
make install
DOXYGEN_VERSION=$1

# Install doxygen
mkdir -p /opt/tt_metal_infra/doxygen
Expand Down
3 changes: 0 additions & 3 deletions scripts/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ apt-utils
dialog
software-properties-common=0.99.9.12
build-essential=12.8ubuntu1.1
libgoogle-glog-dev=0.4.0-1build1
libyaml-cpp-dev=0.6.2-4ubuntu1
git
git-lfs
libboost-all-dev=1.71.0.0ubuntu2
libsndfile1=1.0.28-7ubuntu0.2
pandoc
libtbb-dev
libcapstone-dev
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

enable_testing()
include(GoogleTest)
add_library(test_common_libs INTERFACE)
target_link_libraries(test_common_libs INTERFACE pthread stdc++fs GTest::GTest GTest::Main)
target_link_libraries(test_common_libs INTERFACE pthread stdc++fs gtest gtest_main)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tt_metal/tt_metal)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tt_eager)
Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ target_include_directories(unit_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
${CMAKE_CURRENT_SOURCE_DIR}/circular_buffer
${gtest_SOURCE_DIR}/include
)
set_target_properties(unit_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal)
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/unit_tests_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ target_include_directories(unit_tests_common_o PUBLIC
${PROJECT_SOURCE_DIR}/tt_metal/common
${PROJECT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}/common
${gtest_SOURCE_DIR}/include
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ target_include_directories(unit_tests_fast_dispatch PRIVATE
${PROJECT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
${gtest_SOURCE_DIR}/include
)
set_target_properties(unit_tests_fast_dispatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal)
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ target_include_directories(unit_tests_fast_dispatch_single_chip_multi_queue PRIV
${PROJECT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
${gtest_SOURCE_DIR}/include
)
set_target_properties(unit_tests_fast_dispatch_single_chip_multi_queue PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal)
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/unit_tests_frequent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ target_include_directories(unit_tests_frequent PRIVATE
${PROJECT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
${gtest_SOURCE_DIR}/include
)
set_target_properties(unit_tests_frequent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal)
1 change: 1 addition & 0 deletions tests/ttnn/unit_tests/gtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ target_include_directories(unit_tests_ttnn PRIVATE
${PROJECT_SOURCE_DIR}/tt_metal
${PROJECT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}
${gtest_SOURCE_DIR}/include
)
set_target_properties(unit_tests_ttnn PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/ttnn)

0 comments on commit d0f1d5c

Please sign in to comment.