Skip to content

Commit

Permalink
Install headers as part of default cmake install (#742)
Browse files Browse the repository at this point in the history
* Install headers as part of default cmake install

* install mlir shared lib + third party deps as well

* install rpath ORIGIN + --component SharedLib
  • Loading branch information
nsmithtt authored Sep 19, 2024
1 parent 3ab9f8b commit b3994af
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
9 changes: 9 additions & 0 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
add_subdirectory(ttmlir)

install(DIRECTORY ttmlir ttmlir-c ${TTMLIR_BINARY_DIR}/include/ttmlir
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT SharedLib
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.inc"
PATTERN "*.td"
)
7 changes: 7 additions & 0 deletions lib/SharedLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set(TTNN_RUNTIME_LIBS TTRuntime TTRuntimeTTNN TTBinary)

# Dependency libs from tt-metal/ttnn project for ttnn runtime
set(TTNN_LIBS TTMETAL_LIBRARY TTNN_LIBRARY)
if (TT_RUNTIME_ENABLE_PERF_TRACE)
list(APPEND TTNN_LIBS TRACY_LIBRARY)
endif()

# Libs from tt-mlir project
set(TTMLIR_LIBS
Expand Down Expand Up @@ -49,3 +52,7 @@ target_link_libraries(TTMLIR PRIVATE
)

target_link_directories(TTMLIR PRIVATE ${TTMLIR_TOOLCHAIN_DIR}/lib)

set_target_properties(TTMLIR PROPERTIES INSTALL_RPATH "$ORIGIN")

install(TARGETS TTMLIR DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT SharedLib)
9 changes: 9 additions & 0 deletions runtime/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ target_link_libraries(TTRuntime
)

add_dependencies(TTRuntime TTBinary TTRuntimeSysDesc TTRuntimeDebug FBS_GENERATION)

if (TTMLIR_ENABLE_RUNTIME)
set_target_properties(TTRuntime PROPERTIES PUBLIC_HEADER "../include/tt/runtime/runtime.h;../include/tt/runtime/types.h;../include/tt/runtime/utils.h")
install(TARGETS TTRuntime
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tt/runtime
COMPONENT SharedLib
)
endif()
17 changes: 14 additions & 3 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ set(TTMETAL_INCLUDE_DIRS
set(TTMETAL_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/third_party/tt-metal/src/tt-metal-build/lib)
set(TTNN_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/_ttnn.so)
set(TTMETAL_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/libtt_metal.so)
set(TRACY_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/libtracy.so)
if (TT_RUNTIME_ENABLE_PERF_TRACE)
set(TRACY_LIBRARY_PATH ${TTMETAL_LIBRARY_DIR}/libtracy.so)
else()
set(TRACY_LIBRARY_PATH "")
endif()

set(TTMETAL_LIBRARY_DIR ${TTMETAL_LIBRARY_DIR} PARENT_SCOPE)
set(TTNN_LIBRARY_PATH ${TTNN_LIBRARY_PATH} PARENT_SCOPE)
Expand All @@ -59,11 +63,18 @@ ExternalProject_Add(

set_target_properties(tt-metal PROPERTIES EXCLUDE_FROM_ALL TRUE)

list(APPEND library_names TTNN_LIBRARY TTMETAL_LIBRARY TRACY_LIBRARY)
list(APPEND library_paths ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH} ${TRACY_LIBRARY_PATH})
list(APPEND library_names TTNN_LIBRARY TTMETAL_LIBRARY)
list(APPEND library_paths ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH})

if (TT_RUNTIME_ENABLE_PERF_TRACE)
list(APPEND library_names TRACY_LIBRARY)
list(APPEND library_paths ${TRACY_LIBRARY_PATH})
endif()

foreach(lib_name lib_path IN ZIP_LISTS library_names library_paths)
add_library(${lib_name} SHARED IMPORTED GLOBAL)
set_target_properties(${lib_name} PROPERTIES EXCLUDE_FROM_ALL TRUE IMPORTED_LOCATION ${lib_path})
add_dependencies(${lib_name} tt-metal)
endforeach()

install(FILES ${library_paths} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT SharedLib)

0 comments on commit b3994af

Please sign in to comment.