Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
c6090035
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c6090035
编写于
4月 28, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support the auto-compiling for host protoc when cross-compiling.
上级
d7d2a4f7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
83 addition
and
41 deletion
+83
-41
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+16
-3
cmake/external/protobuf.cmake
cmake/external/protobuf.cmake
+67
-38
未找到文件。
cmake/cross_compiling/android.cmake
浏览文件 @
c6090035
...
@@ -110,9 +110,22 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
...
@@ -110,9 +110,22 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.7.0")
ENDIF
()
ENDIF
()
ENDIF
()
ENDIF
()
SET
(
ANDROID_TOOLCHAIN_PREFIX
"
${
ANDROID_TOOLCHAIN_ROOT
}
/bin/
${
ANDROID_TOOLCHAIN_NAME
}
-"
)
SET
(
ANDROID_TOOLCHAIN_PREFIX
"
${
ANDROID_TOOLCHAIN_ROOT
}
/bin/
${
ANDROID_TOOLCHAIN_NAME
}
-"
)
SET
(
CMAKE_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
IF
(
EXISTS
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
SET
(
CMAKE_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
SET
(
CMAKE_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Cannot find C compiler:
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
ENDIF
()
IF
(
EXISTS
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
SET
(
CMAKE_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Cannot find CXX compiler:
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
ENDIF
()
IF
(
EXISTS
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gfortran"
)
SET
(
CMAKE_Fortran_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gfortran"
)
ENDIF
()
# 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"
)
...
...
cmake/external/protobuf.cmake
浏览文件 @
c6090035
...
@@ -14,42 +14,41 @@
...
@@ -14,42 +14,41 @@
INCLUDE
(
ExternalProject
)
INCLUDE
(
ExternalProject
)
set
(
PROTOBUF_VERSION 3.1
)
FUNCTION
(
build_protobuf TARGET_NAME BUILD_FOR_HOST
)
FIND_PACKAGE
(
Protobuf
${
PROTOBUF_VERSION
}
)
SET
(
PROTOBUF_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/
${
TARGET_NAME
}
)
SET
(
PROTOBUF_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/
${
TARGET_NAME
}
)
IF
(
PROTOBUF_FOUND
)
SET
(
${
TARGET_NAME
}
_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
PARENT_SCOPE
)
EXEC_PROGRAM
(
${
PROTOBUF_PROTOC_EXECUTABLE
}
ARGS --version OUTPUT_VARIABLE PROTOBUF_VERSION
)
SET
(
${
TARGET_NAME
}
_LITE_LIBRARY
STRING
(
REGEX MATCH
"[0-9]+.[0-9]+"
PROTOBUF_VERSION
"
${
PROTOBUF_VERSION
}
"
)
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf-lite
${
STATIC_LIBRARY_SUFFIX
}
"
IF
(
${
PROTOBUF_VERSION
}
VERSION_LESS
"3.1.0"
)
PARENT_SCOPE
)
SET
(
PROTOBUF_FOUND OFF
)
SET
(
${
TARGET_NAME
}
_LIBRARY
ENDIF
()
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf
${
STATIC_LIBRARY_SUFFIX
}
"
ENDIF
(
PROTOBUF_FOUND
)
PARENT_SCOPE
)
SET
(
${
TARGET_NAME
}
_PROTOC_LIBRARY
IF
(
NOT PROTOBUF_FOUND
)
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotoc
${
STATIC_LIBRARY_SUFFIX
}
"
SET
(
PROTOBUF_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/protobuf
)
PARENT_SCOPE
)
SET
(
PROTOBUF_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/protobuf
)
SET
(
${
TARGET_NAME
}
_PROTOC_EXECUTABLE
SET
(
PROTOBUF_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
CACHE PATH
"protobuf include directory."
FORCE
)
"
${
PROTOBUF_INSTALL_DIR
}
/bin/protoc
${
EXECUTABLE_SUFFIX
}
"
PARENT_SCOPE
)
IF
(
WIN32
)
SET
(
OPTIONAL_CACHE_ARGS
""
)
SET
(
PROTOBUF_LITE_LIBRARY
SET
(
OPTIONAL_ARGS
""
)
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf-lite.lib"
CACHE FILEPATH
"protobuf lite library."
FORCE
)
IF
(
BUILD_FOR_HOST
)
SET
(
PROTOBUF_LIBRARY
SET
(
OPTIONAL_ARGS
"-Dprotobuf_WITH_ZLIB=OFF"
)
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf.lib"
CACHE FILEPATH
"protobuf library."
FORCE
)
ELSE
()
SET
(
PROTOBUF_PROTOC_LIBRARY
SET
(
OPTIONAL_ARGS
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotoc.lib"
CACHE FILEPATH
"protoc library."
FORCE
)
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
SET
(
PROTOBUF_PROTOC_EXECUTABLE
"
${
PROTOBUF_INSTALL_DIR
}
/bin/protoc.exe"
CACHE FILEPATH
"protobuf executable."
FORCE
)
"-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
"
ELSE
(
WIN32
)
"-DCMAKE_CXX_FLAGS=
${
CMAKE_CXX_FLAGS
}
"
SET
(
PROTOBUF_LITE_LIBRARY
"-DCMAKE_C_FLAGS=
${
CMAKE_C_FLAGS
}
"
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf-lite.a"
CACHE FILEPATH
"protobuf lite library."
FORCE
)
"-Dprotobuf_WITH_ZLIB=ON"
SET
(
PROTOBUF_LIBRARY
"-DZLIB_ROOT:FILEPATH=
${
ZLIB_ROOT
}
"
)
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf.a"
CACHE FILEPATH
"protobuf library."
FORCE
)
SET
(
OPTIONAL_CACHE_ARGS
"-DZLIB_ROOT:STRING=
${
ZLIB_ROOT
}
"
)
SET
(
PROTOBUF_PROTOC_LIBRARY
ENDIF
()
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotoc.a"
CACHE FILEPATH
"protoc library."
FORCE
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
"
${
PROTOBUF_INSTALL_DIR
}
/bin/protoc"
CACHE FILEPATH
"protobuf executable."
FORCE
)
ENDIF
(
WIN32
)
ExternalProject_Add
(
ExternalProject_Add
(
protobuf
${
TARGET_NAME
}
${
EXTERNAL_PROJECT_LOG_ARGS
}
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
PROTOBUF_SOURCES_DIR
}
PREFIX
${
PROTOBUF_SOURCES_DIR
}
UPDATE_COMMAND
""
UPDATE_COMMAND
""
...
@@ -57,11 +56,9 @@ IF(NOT PROTOBUF_FOUND)
...
@@ -57,11 +56,9 @@ IF(NOT PROTOBUF_FOUND)
GIT_REPOSITORY
"https://github.com/google/protobuf.git"
GIT_REPOSITORY
"https://github.com/google/protobuf.git"
GIT_TAG
"9f75c5aa851cd877fb0d93ccc31b8567a6706546"
GIT_TAG
"9f75c5aa851cd877fb0d93ccc31b8567a6706546"
CONFIGURE_COMMAND
CONFIGURE_COMMAND
${
CMAKE_COMMAND
}
${
PROTOBUF_SOURCES_DIR
}
/src/protobuf/cmake
${
CMAKE_COMMAND
}
${
PROTOBUF_SOURCES_DIR
}
/src/
${
TARGET_NAME
}
/cmake
${
OPTIONAL_ARGS
}
-Dprotobuf_BUILD_TESTS=OFF
-Dprotobuf_BUILD_TESTS=OFF
-DZLIB_ROOT:FILEPATH=
${
ZLIB_ROOT
}
-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=
${
PROTOBUF_INSTALL_DIR
}
-DCMAKE_INSTALL_PREFIX=
${
PROTOBUF_INSTALL_DIR
}
...
@@ -71,10 +68,42 @@ IF(NOT PROTOBUF_FOUND)
...
@@ -71,10 +68,42 @@ IF(NOT PROTOBUF_FOUND)
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DZLIB_ROOT:STRING=
${
ZLIB_ROOT
}
${
OPTIONAL_CACHE_ARGS
}
)
)
LIST
(
APPEND external_project_dependencies protobuf
)
LIST
(
APPEND external_project_dependencies
${
TARGET_NAME
}
PARENT_SCOPE
)
ENDFUNCTION
()
IF
(
NOT CMAKE_CROSSCOMPILING
)
SET
(
PROTOBUF_VERSION 3.1
)
FIND_PACKAGE
(
Protobuf
${
PROTOBUF_VERSION
}
)
IF
(
PROTOBUF_FOUND
)
EXEC_PROGRAM
(
${
PROTOBUF_PROTOC_EXECUTABLE
}
ARGS --version OUTPUT_VARIABLE PROTOBUF_VERSION
)
STRING
(
REGEX MATCH
"[0-9]+.[0-9]+"
PROTOBUF_VERSION
"
${
PROTOBUF_VERSION
}
"
)
IF
(
${
PROTOBUF_VERSION
}
VERSION_LESS
"3.1.0"
)
SET
(
PROTOBUF_FOUND OFF
)
ENDIF
()
ENDIF
(
PROTOBUF_FOUND
)
ELSE
()
build_protobuf
(
protobuf_host TRUE
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
${
protobuf_host_PROTOC_EXECUTABLE
}
CACHE FILEPATH
"protobuf executable."
FORCE
)
ENDIF
()
IF
(
NOT PROTOBUF_FOUND
)
build_protobuf
(
protobuf FALSE
)
SET
(
PROTOBUF_INCLUDE_DIR
${
protobuf_INCLUDE_DIR
}
CACHE PATH
"protobuf include directory."
FORCE
)
IF
(
NOT CMAKE_CROSSCOMPILING
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
${
protobuf_PROTOC_EXECUTABLE
}
CACHE FILEPATH
"protobuf executable."
FORCE
)
ENDIF
()
SET
(
PROTOBUF_LITE_LIBRARY
${
protobuf_LITE_LIBRARY
}
CACHE FILEPATH
"protobuf lite library."
FORCE
)
SET
(
PROTOBUF_LIBRARY
${
protobuf_LIBRARY
}
CACHE FILEPATH
"protobuf library."
FORCE
)
SET
(
PROTOBUF_PROTOC_LIBRARY
${
protobuf_PROTOC_LIBRARY
}
CACHE FILEPATH
"protoc library."
FORCE
)
ENDIF
(
NOT PROTOBUF_FOUND
)
ENDIF
(
NOT PROTOBUF_FOUND
)
MESSAGE
(
STATUS
"Protobuf protoc executable:
${
PROTOBUF_PROTOC_EXECUTABLE
}
"
)
MESSAGE
(
STATUS
"Protobuf library:
${
PROTOBUF_LIBRARY
}
"
)
INCLUDE_DIRECTORIES
(
${
PROTOBUF_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
PROTOBUF_INCLUDE_DIR
}
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录