diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 86152401..3501eeaa 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -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) diff --git a/device/CMakeLists.txt b/device/CMakeLists.txt index 592de0e4..4b3a90b9 100644 --- a/device/CMakeLists.txt +++ b/device/CMakeLists.txt @@ -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)