@@ -5,24 +5,29 @@ set(AAPT2_PROTO_DIR ${SRC}/base/tools/aapt2)
5
5
6
6
file (GLOB_RECURSE PROTO_FILES ${AAPT2_PROTO_DIR} /*.proto)
7
7
8
+ find_package (Protobuf)
9
+
10
+ if (NOT EXISTS ${Protobuf_PROTOC_EXECUTABLE} )
11
+ message (FATAL_ERROR "Invalid protoc: ${Protobuf_PROTOC_EXECUTABLE} " )
12
+ endif ()
13
+
14
+
8
15
foreach (proto ${PROTO_FILES} )
9
16
get_filename_component (FIL_WE ${proto} NAME_WE )
10
17
11
- if (DEFINED PROTOC_PATH)
12
- # Execute the protoc command to generate the proto targets for host arch.
13
- execute_process (
14
- COMMAND ${PROTOC_COMPILER} ${proto}
15
- --proto_path=${AAPT2_PROTO_DIR}
16
- --cpp_out=${AAPT2_PROTO_DIR}
17
- COMMAND_ECHO STDOUT
18
- RESULT_VARIABLE RESULT
19
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
20
- )
21
-
22
- if (RESULT EQUAL 0)
23
- message (STATUS "generate cpp file ${TARGET_CPP_FILE} " )
24
- message (STATUS "generate head file ${TARGET_HEAD_FILE} " )
25
- endif ()
18
+ # Execute the protoc command to generate the proto targets for host arch.
19
+ execute_process (
20
+ COMMAND ${Protobuf_PROTOC_EXECUTABLE} ${proto}
21
+ --proto_path=${AAPT2_PROTO_DIR}
22
+ --cpp_out=${AAPT2_PROTO_DIR}
23
+ COMMAND_ECHO STDOUT
24
+ RESULT_VARIABLE RESULT
25
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
26
+ )
27
+
28
+ if (RESULT EQUAL 0)
29
+ message (STATUS "generate cpp file ${TARGET_CPP_FILE} " )
30
+ message (STATUS "generate head file ${TARGET_HEAD_FILE} " )
26
31
endif ()
27
32
28
33
set (TARGET_CPP_FILE "${AAPT2_PROTO_DIR} /${FIL_WE} .pb.cc" )
@@ -34,10 +39,9 @@ foreach(proto ${PROTO_FILES})
34
39
endif ()
35
40
endforeach ()
36
41
37
- if (DEFINED PROTOC_PATH)
38
- set_source_files_properties (${AAPT2_PROTO_SRC} PROPERTIES GENERATED TRUE )
39
- set_source_files_properties (${AAPT2_PROTO_HDRS} PROPERTIES GENERATED TRUE )
40
- endif ()
42
+ set_source_files_properties (${AAPT2_PROTO_SRC} PROPERTIES GENERATED TRUE )
43
+ set_source_files_properties (${AAPT2_PROTO_HDRS} PROPERTIES GENERATED TRUE )
44
+
41
45
set_source_files_properties (${AAPT2_PROTO_SRC} ${AAPT2_PROTO_HDRS}
42
46
PROPERTIES GENERATED TRUE )
43
47
# ========================= aapt2 proto ============================
0 commit comments