Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
af80ff94
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
af80ff94
编写于
5月 02, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow the case user sets CMAKE_C_COMPILER directly instead of standalone toolchain.
上级
39f9056c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
35 deletion
+58
-35
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+58
-35
未找到文件。
cmake/cross_compiling/android.cmake
浏览文件 @
af80ff94
...
@@ -41,7 +41,8 @@ IF(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN)
...
@@ -41,7 +41,8 @@ IF(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN)
CACHE PATH
"Folder holds the standalone toolchain of Android NDK"
)
CACHE PATH
"Folder holds the standalone toolchain of Android NDK"
)
ENDIF
()
ENDIF
()
IF
(
NOT ANDROID_STANDALONE_TOOLCHAIN
)
IF
(
NOT ANDROID_STANDALONE_TOOLCHAIN
)
MESSAGE
(
FATAL_ERROR
"Set ANDROID_STANDALONE_TOOLCHAIN to use a standalone toolchain.
\n
"
MESSAGE
(
WARNING
"It is recommened to set ANDROID_STANDALONE_TOOLCHAIN to "
"use a standalone toolchain.
\n
"
"To cross-compile for Android, you need to:
\n
"
"To cross-compile for Android, you need to:
\n
"
"1. Download an Android NDK from"
"1. Download an Android NDK from"
" https://developer.android.com/ndk/downloads/index.html
\n
"
" https://developer.android.com/ndk/downloads/index.html
\n
"
...
@@ -65,11 +66,6 @@ ENDIF()
...
@@ -65,11 +66,6 @@ ENDIF()
IF
(
NOT DEFINED ANDROID_ARM_MODE
)
IF
(
NOT DEFINED ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE ON
)
SET
(
ANDROID_ARM_MODE ON
)
ENDIF
()
ENDIF
()
IF
(
NOT DEFINED ANDROID_ARM_NEON
)
SET
(
ANDROID_ARM_NEON ON
)
ENDIF
()
IF
(
NOT ANDROID_ARM_MODE OR ANDROID_ARM_MODE STREQUAL
"thumb"
)
IF
(
NOT ANDROID_ARM_MODE OR ANDROID_ARM_MODE STREQUAL
"thumb"
)
SET
(
ANDROID_ARM_MODE OFF
)
SET
(
ANDROID_ARM_MODE OFF
)
SET
(
ANDROID_ARM_MODE_NAME
"thumb"
)
SET
(
ANDROID_ARM_MODE_NAME
"thumb"
)
...
@@ -78,6 +74,10 @@ ELSEIF(ANDROID_ARM_MODE OR ANDROID_ARM_MODE STREQUAL "arm")
...
@@ -78,6 +74,10 @@ ELSEIF(ANDROID_ARM_MODE OR ANDROID_ARM_MODE STREQUAL "arm")
SET
(
ANDROID_ARM_MODE_NAME
"arm"
)
SET
(
ANDROID_ARM_MODE_NAME
"arm"
)
ENDIF
()
ENDIF
()
IF
(
NOT DEFINED ANDROID_ARM_NEON
)
SET
(
ANDROID_ARM_NEON ON
)
ENDIF
()
IF
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.7.0"
)
IF
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.7.0"
)
IF
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.1.0"
)
IF
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.1.0"
)
SET
(
CMAKE_SYSTEM_NAME
"Linux"
)
SET
(
CMAKE_SYSTEM_NAME
"Linux"
)
...
@@ -85,47 +85,70 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
...
@@ -85,47 +85,70 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
MESSAGE
(
WARNING
"It is recommended to use CMake >= 3.7.0 (current version: "
MESSAGE
(
WARNING
"It is recommended to use CMake >= 3.7.0 (current version: "
"
${
CMAKE_VERSION
}
), when cross-compiling for Android."
)
"
${
CMAKE_VERSION
}
), when cross-compiling for Android."
)
SET
(
CMAKE_SYSROOT
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot"
)
IF
(
ANDROID_STANDALONE_TOOLCHAIN
)
SET
(
CMAKE_SYSROOT
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot"
)
IF
(
NOT CMAKE_SYSTEM_VERSION
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN_API
""
)
IF
(
NOT CMAKE_SYSTEM_VERSION
)
SET
(
ANDROID_API_LEVEL_H_REGEX
"^[
\t
]*#[
\t
]*define[
\t
]+__ANDROID_API__[
\t
]+([0-9]+)"
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN_API
""
)
FILE
(
STRINGS
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot/usr/include/android/api-level.h"
SET
(
ANDROID_API_LEVEL_H_REGEX
"^[
\t
]*#[
\t
]*define[
\t
]+__ANDROID_API__[
\t
]+([0-9]+)"
)
ANDROID_API_LEVEL_H_CONTENT REGEX
"
${
ANDROID_API_LEVEL_H_REGEX
}
"
)
FILE
(
STRINGS
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot/usr/include/android/api-level.h"
IF
(
ANDROID_API_LEVEL_H_CONTENT MATCHES
"
${
ANDROID_API_LEVEL_H_REGEX
}
"
)
ANDROID_API_LEVEL_H_CONTENT REGEX
"
${
ANDROID_API_LEVEL_H_REGEX
}
"
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN_API
"
${
CMAKE_MATCH_1
}
"
)
IF
(
ANDROID_API_LEVEL_H_CONTENT MATCHES
"
${
ANDROID_API_LEVEL_H_REGEX
}
"
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN_API
"
${
CMAKE_MATCH_1
}
"
)
ENDIF
()
SET
(
CMAKE_SYSTEM_VERSION
${
ANDROID_STANDALONE_TOOLCHAIN_API
}
)
ENDIF
()
ENDIF
()
SET
(
CMAKE_SYSTEM_VERSION
${
ANDROID_STANDALONE_TOOLCHAIN_API
}
)
ENDIF
()
# Toolchain
# Toolchain
SET
(
ANDROID_TOOLCHAIN
"gcc"
)
SET
(
ANDROID_TOOLCHAIN
"gcc"
)
SET
(
ANDROID_TOOLCHAIN_ROOT
${
ANDROID_STANDALONE_TOOLCHAIN
}
)
SET
(
ANDROID_TOOLCHAIN_ROOT
${
ANDROID_STANDALONE_TOOLCHAIN
}
)
IF
(
ANDROID_ABI MATCHES
"^armeabi(-v7a)?$"
)
IF
(
ANDROID_ABI MATCHES
"^armeabi(-v7a)?$"
)
SET
(
ANDROID_TOOLCHAIN_NAME arm-linux-androideabi
)
SET
(
ANDROID_TOOLCHAIN_NAME arm-linux-androideabi
)
IF
(
ANDROID_ABI STREQUAL
"armeabi"
)
IF
(
ANDROID_ABI STREQUAL
"armeabi"
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv5te
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv5te
)
ELSEIF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
ELSEIF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv7-a
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv7-a
)
ENDIF
()
ENDIF
()
ENDIF
()
SET
(
ANDROID_TOOLCHAIN_PREFIX
"
${
ANDROID_TOOLCHAIN_ROOT
}
/bin/
${
ANDROID_TOOLCHAIN_NAME
}
-"
)
ENDIF
()
ENDIF
()
SET
(
ANDROID_TOOLCHAIN_PREFIX
"
${
ANDROID_TOOLCHAIN_ROOT
}
/bin/
${
ANDROID_TOOLCHAIN_NAME
}
-"
)
IF
(
EXISTS
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
# C compiler
SET
(
CMAKE_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
CACHE PATH
"C compiler"
)
IF
(
NOT CMAKE_C_COMPILER
)
SET
(
ANDROID_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
ELSE
()
ELSE
()
MESSAGE
(
FATAL_ERROR
"Cannot found C compiler:
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
GET_FILENAME_COMPONENT
(
ANDROID_C_COMPILER_PATH
${
CMAKE_C_COMPILER
}
PROGRAM
)
SET
(
ANDROID_C_COMPILER
${
ANDROID_C_COMPILER_PATH
}
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_C_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot found C compiler:
${
ANDROID_C_COMPILER
}
"
)
ENDIF
()
ENDIF
()
IF
(
EXISTS
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
# CXX compiler
SET
(
CMAKE_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
CACHE PATH
"CXX compiler"
)
IF
(
NOT CMAKE_CXX_COMPILER
)
SET
(
ANDROID_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
ELSE
()
ELSE
()
MESSAGE
(
FATAL_ERROR
"Cannot found CXX compiler:
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
GET_FILENAME_COMPONENT
(
ANDROID_CXX_COMPILER_PATH
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
SET
(
ANDROID_CXX_COMPILER
${
ANDROID_CXX_COMPILER_PATH
}
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_CXX_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot found CXX compiler:
${
ANDROID_CXX_COMPILER
}
"
)
ENDIF
()
ENDIF
()
IF
(
EXISTS
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gfortran"
)
# Fortran compiler
SET
(
CMAKE_Fortran_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gfortran"
CACHE PATH
"Fortran compiler"
)
IF
(
NOT CMAKE_Fortran_COMPILER
)
SET
(
ANDROID_Fortran_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gfortran"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_Fortran_COMPILER_PATH
${
CMAKE_Fortran_COMPILER
}
)
SET
(
ANDROID_Fortran_COMPILER
${
ANDROID_Fortran_COMPILER_PATH
}
)
ENDIF
()
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_Fortran_COMPILER
}
)
SET
(
ANDROID_Fortran_COMPILER
""
)
ENDIF
()
SET
(
CMAKE_C_COMPILER
${
ANDROID_C_COMPILER
}
CACHE PATH
"C compiler"
FORCE
)
SET
(
CMAKE_CXX_COMPILER
${
ANDROID_CXX_COMPILER
}
CACHE PATH
"CXX compiler"
FORCE
)
SET
(
CMAKE_Fortran_COMPILER
${
ANDROID_Fortran_COMPILER
}
CACHE PATH
"Fortran compiler"
FORCE
)
# Toolchain and ABI specific flags.
# Toolchain and ABI specific flags.
SET
(
ANDROID_COMPILER_FLAGS
"-ffunction-sections -fdata-sections -finline-limit=64"
)
SET
(
ANDROID_COMPILER_FLAGS
"-ffunction-sections -fdata-sections -finline-limit=64"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录