Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate fbs header file through cmake during build flow #225

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,30 @@ CPMAddPackage(
GITHUB_REPOSITORY google/flatbuffers
GIT_TAG v24.3.25
OPTIONS
"FLATBUFFERS_BUILD_FLATC OFF"
"FLATBUFFERS_BUILD_FLATC ON"
"FLATBUFFERS_BUILD_TESTS OFF"
"FLATBUFFERS_SKIP_MONSTER_EXTRA ON"
"FLATBUFFERS_STRICT_MODE ON"
)
function(GENERATE_FBS_HEADER FBS_FILE)
get_filename_component(FBS_FILE_NAME ${FBS_FILE} NAME)
get_filename_component(FBS_FILE_DIR ${FBS_FILE} DIRECTORY)
set(FBS_GENERATED_HEADER "${CMAKE_BINARY_DIR}/${FBS_FILE_NAME}_generated.h")
add_custom_command(
OUTPUT
${FBS_GENERATED_HEADER}
COMMAND
flatc
ARGS
--cpp -o "${CMAKE_BINARY_DIR}/" ${FBS_FILE}
DEPENDS
flatc
${FBS_FILE}
COMMENT "Building C++ header for ${FBS_FILE}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set(FBS_GENERATED_HEADER ${FBS_GENERATED_HEADER} PARENT_SCOPE)
endfunction()

############################################################################################################################
# libuv (for process management)
Expand Down
6 changes: 6 additions & 0 deletions device/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set(POSITION_INDEPENDENT_CODE ON)

GENERATE_FBS_HEADER(${PROJECT_SOURCE_DIR}/device/simulation/tt_simulation_device.fbs)

set(UMD_DEVICE_SRCS
architecture_implementation.cpp
cpuset_lib.cpp
Expand All @@ -24,13 +26,17 @@ add_library(device SHARED ${UMD_DEVICE_SRCS})
add_library(${PROJECT_NAME}::device ALIAS device)
add_library(${PROJECT_NAME}_device ALIAS device) # For legacy I guess

target_sources(device PRIVATE ${FBS_GENERATED_HEADER})

target_include_directories(
device
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/device>
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)

# flatbuffers is public - exposed to tt_metal by tt_simulation_device_generated.h
Expand Down
215 changes: 0 additions & 215 deletions device/simulation/tt_simulation_device_generated.h

This file was deleted.

Loading