@@ -86,6 +86,14 @@ if(ANDROID OR IOS)
8686 "Disable MKLDNN when cross-compiling for Android and iOS" FORCE)
8787 set (WITH_MKLML OFF CACHE STRING
8888 "Disable MKLML package when cross-compiling for Android and iOS" FORCE)
89+
90+ # Compile PaddlePaddle mobile inference library
91+ if (NOT WITH_C_API)
92+ set (WITH_C_API ON CACHE STRING
93+ "Always compile the C_API when cross-compiling for Android and iOS" FORCE)
94+ endif ()
95+ set (MOBILE_INFERENCE ON )
96+ add_definitions (-DPADDLE_MOBILE_INFERENCE)
8997endif ()
9098
9199set (THIRD_PARTY_PATH "${CMAKE_BINARY_DIR} /third_party" CACHE STRING
@@ -97,6 +105,12 @@ if (WITH_C_API AND WITH_PYTHON)
97105 "different Python interpreter from compiling." )
98106endif ()
99107
108+ if (MOBILE_INFERENCE)
109+ set (THIRD_PARTY_BUILD_TYPE MinSizeRel)
110+ else ()
111+ set (THIRD_PARTY_BUILD_TYPE Release)
112+ endif ()
113+
100114########################################################################################
101115
102116include (external/mklml) # download mklml package
@@ -160,9 +174,11 @@ endif(USE_NNPACK)
160174
161175add_subdirectory (proto)
162176
163- # "add_subdirectory(go)" should be placed after the following loine,
164- # because it depends on paddle/optimizer.
165- add_subdirectory (paddle/optimizer)
177+ if (NOT MOBILE_INFERENCE)
178+ # "add_subdirectory(go)" should be placed after the following loine,
179+ # because it depends on paddle/optimizer.
180+ add_subdirectory (paddle/optimizer)
181+ endif ()
166182
167183# "add_subdirectory(paddle)" and "add_subdirectory(python)" should be
168184# placed after this block, because they depends on it.
0 commit comments