Skip to content

[MPS] Fix mps_executor_runner build when using cmake #1216

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

Closed
Closed
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
32 changes: 31 additions & 1 deletion examples/apple/mps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ endif()

include(${EXECUTORCH_ROOT}/build/Utils.cmake)

set(_bundled_program_schema_dir
${EXECUTORCH_ROOT}/sdk/bundled_program/schema)

set(_bundled_program_schema__srcs
${_bundled_program_schema_dir}/bundled_program_schema.fbs
${_bundled_program_schema_dir}/scalar_type.fbs)

# The include directory that will contain the generated schema headers.
set(_program_schema__include_dir
"${CMAKE_BINARY_DIR}/schema/include/executorch/sdk/bundled_program/schema")

set(_bundled_program_schema__outputs)
foreach(fbs_file ${_bundled_program_schema__srcs})
string(REGEX REPLACE "[.]fbs$" "_generated.h" generated "${fbs_file}")
list(APPEND _bundled_program_schema__outputs
"${generated}")
endforeach()

add_custom_command(
OUTPUT ${_bundled_program_schema__outputs}
COMMAND
${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o
${_program_schema__include_dir} ${_bundled_program_schema__srcs}
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
DEPENDS ${FLATC_EXECUTABLE} ${_bundled_program_schema__srcs}
COMMENT "Generating bundled_program headers"
VERBATIM)

# ios can only build library but not binary
if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*iOS\.cmake$")
#
Expand All @@ -42,7 +70,9 @@ set(mps_executor_runner_libs "-framework Foundation"
"-weak_framework MetalPerformanceShadersGraph"
"-weak_framework Metal")
list(TRANSFORM _mps_executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
add_executable(mps_executor_runner ${_mps_executor_runner__srcs})
add_executable(mps_executor_runner
${_mps_executor_runner__srcs}
${_bundled_program_schema__outputs})
target_include_directories(
mps_executor_runner INTERFACE ${CMAKE_BINARY_DIR}/schema/include/
${EXECUTORCH_ROOT}/third-party/flatbuffers/include)
Expand Down