@@ -30,6 +30,10 @@ if(NOT EXECUTORCH_ROOT)
30
30
set (EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /.. )
31
31
endif ()
32
32
33
+ if (NOT FLATC_EXECUTABLE )
34
+ set (FLATC_EXECUTABLE flatc )
35
+ endif ()
36
+
33
37
# Paths to headers generated from the .fbs files. set(_etdump_schemas
34
38
# etdump_schema_flatcc.fbs scalar_type.fbs)
35
39
@@ -38,12 +42,9 @@ set(_etdump_schema__srcs
38
42
${CMAKE_CURRENT_SOURCE_DIR} /etdump/scalar_type.fbs )
39
43
40
44
41
- set (_bundled_program_schema_dir
42
- ${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/schema )
43
-
44
45
set (_bundled_program_schema__srcs
45
- ${_bundled_program_schema_dir} /bundled_program_schema.fbs
46
- ${_bundled_program_schema_dir} /scalar_type.fbs )
46
+ ${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/schema /bundled_program_schema.fbs
47
+ ${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/schema /scalar_type.fbs )
47
48
48
49
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /../third-party/flatcc
49
50
${CMAKE_BINARY_DIR} /third-party/flatcc )
@@ -53,6 +54,7 @@ include(ExternalProject)
53
54
54
55
# The include directory that will contain the generated schema headers.
55
56
set (_program_schema__include_dir "${CMAKE_BINARY_DIR} /sdk/include" )
57
+ set (_bundled_schema__include_dir "${CMAKE_BINARY_DIR} /sdk/bundled_program" )
56
58
57
59
# Add the host project
58
60
# lint_cmake: -readability/wonkycase
@@ -75,7 +77,7 @@ set(_bundled_program_schema__outputs)
75
77
foreach (fbs_file ${_bundled_program_schema__srcs} )
76
78
string (REGEX REPLACE "[.]fbs$" "_generated.h" generated "${fbs_file} " )
77
79
list (APPEND _bundled_program_schema__outputs
78
- "${_program_schema__include_dir } /${generated} " )
80
+ "${_bundled_schema__include_dir } /${generated} " )
79
81
endforeach ()
80
82
81
83
add_library (etdump_schema INTERFACE ${_etdump_schema__outputs} )
@@ -104,23 +106,32 @@ add_custom_command(
104
106
COMMENT "Generating etdump headers"
105
107
VERBATIM )
106
108
107
- add_custom_command (
108
- OUTPUT ${_bundled_program_schema__outputs}
109
- COMMAND
110
- ${CMAKE_SOURCE_DIR} /third-party/flatcc/bin/flatcc -cwr -o
111
- ${_program_schema__include_dir} /executorch/sdk/bundled_program
112
- ${_bundled_program_schema__srcs}
113
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /sdk
114
- DEPENDS flatcc_project
115
- COMMENT "Generating bundled_program headers"
116
- VERBATIM )
117
-
118
- target_include_directories (
119
- etdump PUBLIC ${_program_schema__include_dir}
120
- ${CMAKE_SOURCE_DIR} /third-party/flatcc/include )
109
+ add_library (etdump ${CMAKE_CURRENT_SOURCE_DIR} /etdump/etdump_flatcc.cpp )
110
+ target_link_libraries (
111
+ etdump
112
+ PUBLIC etdump_schema
113
+ PRIVATE executorch )
114
+
115
+ add_custom_command (
116
+ OUTPUT ${_bundled_program_schema__outputs}
117
+ COMMAND
118
+ ${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o
119
+ "${_bundled_schema__include_dir} /executorch/sdk/bundled_program/schema" ${_bundled_program_schema__srcs}
120
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /sdk
121
+ DEPENDS ${FLATC_EXECUTABLE} ${_bundled_program_schema__srcs}
122
+ COMMENT "Generating bundled_program headers"
123
+ VERBATIM )
124
+
125
+ #add_library(bundled_program INTERFACE ${_bundled_program_schema__outputs})
126
+ add_library (bundled_program ${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/bundled_program.cpp )
127
+ target_link_libraries (bundled_program executorch bundled_program_schema )
121
128
122
129
set_target_properties (bundled_program PROPERTIES LINKER_LANGUAGE CXX )
123
130
target_include_directories (
124
131
bundled_program
125
- INTERFACE ${_program_schema__include_dir }
132
+ PUBLIC ${_bundled_schema__include_dir }
126
133
${EXECUTORCH_ROOT} /third-party/flatbuffers/include )
134
+
135
+ target_include_directories (
136
+ etdump PUBLIC ${_program_schema__include_dir}
137
+ ${CMAKE_SOURCE_DIR} /third-party/flatcc/include )
0 commit comments