diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 1f2e181c..0b5cd972 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -5,20 +5,27 @@ set(TT_MLIR_VERSION "4d28d1522647c51da4bd026fdf3e9f9cdde07f32") -if (TOOLCHAIN STREQUAL "ON") +if (BUILD_TOOLCHAIN) cmake_minimum_required(VERSION 3.20) project(ttmlir-toolchain LANGUAGES CXX C) + if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir) + execute_process( + COMMAND git clone --recursive https://github.com/tenstorrent/tt-mlir.git ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir + ) + endif() execute_process( - COMMAND git clone --recursive https://github.com/tenstorrent/tt-mlir.git ${PROJECT_SOURCE_DIR}/tt-mlir/src/tt-mlir - RESULT_VARIABLE result1 - OUTPUT_VARIABLE output1 - ERROR_VARIABLE error_output1 + COMMAND /bin/bash -c "git checkout ${TT_MLIR_VERSION}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir ) - if (NOT ${result1} EQUAL 0) - message(FATAL_ERROR "Failed to clone tt-mlir: ${error_output1}") - endif() + + execute_process( + COMMAND pwd + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir + ) + execute_process( - COMMAND /bin/bash -c "cd ${PROJECT_SOURCE_DIR}/tt-mlir/src/tt-mlir && git checkout ${TT_MLIR_VERSION}" + COMMAND /bin/bash ../../../build_mlir_env.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tt-mlir/src/tt-mlir ) else() set(TT_RUNTIME_DEBUG OFF CACHE BOOL "Enable runtime debugging") diff --git a/third_party/build_mlir_env.sh b/third_party/build_mlir_env.sh new file mode 100644 index 00000000..4e67f1ec --- /dev/null +++ b/third_party/build_mlir_env.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC +# +# SPDX-License-Identifier: Apache-2.0 + +cmake -B env/build env +cmake --build env/build