This repository was archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Add CMakeLists.txt for the inference demo. #13
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a860f7f
Add CMakeLists.txt for the inference demo.
hedaoyuan 5b041ea
Fix Android.
hedaoyuan 4874aa6
Merge branch 'master' of github.com:hedaoyuan/Mobile
hedaoyuan f2b01dc
Bug fix.
hedaoyuan 7e8f83d
Fix CMakeLists.txt.
hedaoyuan a0b099d
Follow comments
hedaoyuan 7cdcf80
Refine the README.md of inference.
hedaoyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.DS_Store | ||
*.pyc | ||
build/ | ||
build_*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/") | ||
|
||
|
||
if(ANDROID_ABI) | ||
set(ANDROID_COMPILER_FLAGS -ffunction-sections -fdata-sections) | ||
set(ANDROID_LINKER_FLAGS -Wl,--gc-sections) | ||
|
||
if(ANDROID_ABI STREQUAL "armeabi-v7a") | ||
set(CMAKE_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot") | ||
set(ANDROID_TOOLCHAIN_PREFIX | ||
"${ANDROID_STANDALONE_TOOLCHAIN}/bin/arm-linux-androideabi") | ||
list(APPEND ANDROID_COMPILER_FLAGS -mfpu=neon) | ||
list(APPEND ANDROID_LINKER_FLAGS -Wl,--fix-cortex-a8) | ||
elseif(ANDROID_ABI STREQUAL "arm64-v8a") | ||
set(CMAKE_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot") | ||
set(ANDROID_TOOLCHAIN_PREFIX | ||
"${ANDROID_STANDALONE_TOOLCHAIN}/bin/aarch64-linux-android") | ||
list(APPEND ANDROID_COMPILER_FLAGS -march=armv8-a) | ||
endif() | ||
string(REPLACE ";" " " ANDROID_COMPILER_FLAGS "${ANDROID_COMPILER_FLAGS}") | ||
string(REPLACE ";" " " ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS "${ANDROID_COMPILER_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING "C flags") | ||
set(CMAKE_CXX_FLAGS "${ANDROID_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING "CXX flags") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "shared linker flags") | ||
set(CMAKE_EXE_LINKER_FLAGS "-pie -fPIE ${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "executable linker flags") | ||
|
||
set(CMAKE_C_COMPILER ${ANDROID_TOOLCHAIN_PREFIX}-gcc CACHE PATH "C compiler" FORCE) | ||
set(CMAKE_CXX_COMPILER ${ANDROID_TOOLCHAIN_PREFIX}-g++ CACHE PATH "CXX compiler" FORCE) | ||
endif() | ||
project(inference CXX C) | ||
include(FindPaddle) | ||
|
||
aux_source_directory(. SRC_LIST) | ||
add_executable(${PROJECT_NAME} ${SRC_LIST}) | ||
|
||
if(ANDROID_ABI) | ||
target_link_libraries(${PROJECT_NAME} | ||
-Wl,--start-group -Wl,--whole-archive -lpaddle_capi_layers | ||
-Wl,--no-whole-archive -lpaddle_capi_engine -Wl,--end-group | ||
${THIRD_PARTY_LIBRARYS}) | ||
else() | ||
target_link_libraries(${PROJECT_NAME} | ||
-Wl,--start-group -Wl,--whole-archive -lpaddle_capi_whole | ||
-Wl,--no-whole-archive -Wl,--end-group | ||
${THIRD_PARTY_LIBRARYS} -lrt -ldl -lpthread) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
set(PADDLE_ROOT $ENV{PADDLE_ROOT} CACHE PATH "Paddle Path") | ||
find_path(PADDLE_INC NAMES capi.h PATHS ${PADDLE_ROOT}/include/paddle) | ||
find_library(PADDLE_LIB NAMES paddle_capi_shared PATHS ${PADDLE_ROOT}/lib/${ANDROID_ABI}) | ||
if(PADDLE_INC AND PADDLE_LIB) | ||
message("Found") | ||
else() | ||
message(${PADDLE_ROOT}) | ||
message("Not Found") | ||
endif() | ||
include_directories(${PADDLE_ROOT}/include) | ||
set(THIRD_PARTY_LIBRARYS) | ||
list(APPEND THIRD_PARTY_LIBRARYS -lglog -lgflags -lprotobuf -lopenblas -lz) | ||
link_directories(${PADDLE_ROOT}/lib/${ANDROID_ABI}) | ||
link_directories(${PADDLE_ROOT}/third_party/gflags/lib/${ANDROID_ABI}) | ||
link_directories(${PADDLE_ROOT}/third_party/glog/lib/${ANDROID_ABI}) | ||
link_directories(${PADDLE_ROOT}/third_party/protobuf/lib/${ANDROID_ABI}) | ||
link_directories(${PADDLE_ROOT}/third_party/openblas/lib/${ANDROID_ABI}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes, there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
link_directories(${PADDLE_ROOT}/third_party/zip/lib/${ANDROID_ABI}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to use
message(STATUS ...)
, and the message should be more detail, such asThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.