Skip to content

Commit

Permalink
Move custom command out of function
Browse files Browse the repository at this point in the history
  • Loading branch information
blozano-tt committed Nov 30, 2024
1 parent b3b5f1a commit b8df0e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
21 changes: 2 additions & 19 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,8 @@ function(fetch_dependencies)
"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_CURRENT_BINARY_DIR}/${FBS_FILE_NAME}_generated.h")
add_custom_command(
OUTPUT
${FBS_GENERATED_HEADER}
COMMAND
flatc
ARGS
--cpp -o "${CMAKE_CURRENT_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()

set(FLATC_EXE ${flatbuffers_BINARY_DIR}/flatc PARENT_SCOPE)

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

generate_fbs_header(${PROJECT_SOURCE_DIR}/device/simulation/tt_simulation_device.fbs)
set(FBS_FILE ${PROJECT_SOURCE_DIR}/device/simulation/tt_simulation_device.fbs)
get_filename_component(FBS_FILE_NAME ${FBS_FILE} NAME)
set(FBS_GENERATED_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${FBS_FILE_NAME}_generated.h")
add_custom_command(
OUTPUT
${FBS_GENERATED_HEADER}
COMMAND
${FLATC_EXE}
ARGS
--cpp -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FBS_FILE}
DEPENDS
flatc
COMMENT "Generating FlatBuffers header ${FBS_GENERATED_HEADER}"
VERBATIM
)

add_library(device SHARED)
add_library(${PROJECT_NAME}::device ALIAS device)
Expand Down

0 comments on commit b8df0e3

Please sign in to comment.