Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c89fe83a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
c89fe83a
编写于
6月 23, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the problem that protobuf cannot be used as a DEPS argument in cc_library.
上级
08d0b1d9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
49 addition
and
12 deletion
+49
-12
cmake/external/protobuf.cmake
cmake/external/protobuf.cmake
+49
-12
未找到文件。
cmake/external/protobuf.cmake
浏览文件 @
c89fe83a
...
...
@@ -14,11 +14,41 @@
INCLUDE
(
ExternalProject
)
# Print and set the protobuf library information,
# finish this cmake process and exit from this file.
macro
(
PROMPT_PROTOBUF_LIB
)
SET
(
protobuf_DEPS
${
ARGN
}
)
MESSAGE
(
STATUS
"Protobuf protoc executable:
${
PROTOBUF_PROTOC_EXECUTABLE
}
"
)
MESSAGE
(
STATUS
"Protobuf library:
${
PROTOBUF_LIBRARY
}
"
)
MESSAGE
(
STATUS
"Protobuf version:
${
PROTOBUF_VERSION
}
"
)
INCLUDE_DIRECTORIES
(
${
PROTOBUF_INCLUDE_DIR
}
)
# Assuming that all the protobuf libraries are of the same type.
IF
(
${
PROTOBUF_LIBRARY
}
MATCHES
"
${
STATIC_LIBRARY_SUFFIX
}
$"
)
SET
(
protobuf_LIBTYPE STATIC
)
ELSEIF
(
${
PROTOBUF_LIBRARY
}
MATCHES
"
${
DYNAMIC_LIBRARY_SUFFIX
}
$"
)
SET
(
protobuf_LIBTYPE SHARED
)
ELSE
()
MESSAGE
(
FATAL_ERROR
"Unknown library type:
${
PROTOBUF_LIBRARY
}
"
)
ENDIF
()
ADD_LIBRARY
(
protobuf
${
protobuf_LIBTYPE
}
IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET protobuf PROPERTY IMPORTED_LOCATION
${
PROTOBUF_LIBRARY
}
)
ADD_LIBRARY
(
protobuf_lite
${
protobuf_LIBTYPE
}
IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET protobuf_lite PROPERTY IMPORTED_LOCATION
${
PROTOBUF_LITE_LIBRARY
}
)
ADD_LIBRARY
(
protoc
${
protobuf_LIBTYPE
}
IMPORTED GLOBAL
)
SET_PROPERTY
(
TARGET protoc PROPERTY IMPORTED_LOCATION
${
PROTOC_LIBRARY
}
)
FOREACH
(
dep
${
protobuf_DEPS
}
)
ADD_DEPENDENCIES
(
protobuf
${
dep
}
)
ADD_DEPENDENCIES
(
protobuf_lite
${
dep
}
)
ADD_DEPENDENCIES
(
protoc
${
dep
}
)
ENDFOREACH
()
LIST
(
APPEND external_project_dependencies protobuf
)
RETURN
()
endmacro
()
macro
(
SET_PROTOBUF_VERSION
)
...
...
@@ -43,8 +73,9 @@ if (NOT "${PROTOBUF_ROOT}" STREQUAL "")
endif
()
FUNCTION
(
build_protobuf TARGET_NAME BUILD_FOR_HOST
)
SET
(
PROTOBUF_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/
${
TARGET_NAME
}
)
SET
(
PROTOBUF_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/
${
TARGET_NAME
}
)
STRING
(
REPLACE
"extern_"
""
TARGET_DIR_NAME
"
${
TARGET_NAME
}
"
)
SET
(
PROTOBUF_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/
${
TARGET_DIR_NAME
}
)
SET
(
PROTOBUF_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/
${
TARGET_DIR_NAME
}
)
SET
(
${
TARGET_NAME
}
_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
PARENT_SCOPE
)
SET
(
PROTOBUF_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
PARENT_SCOPE
)
...
...
@@ -109,6 +140,8 @@ IF(NOT CMAKE_CROSSCOMPILING)
SET_PROTOBUF_VERSION
()
IF
(
"
${
PROTOBUF_VERSION
}
"
VERSION_LESS
"3.1.0"
)
SET
(
PROTOBUF_FOUND OFF
)
ELSE
()
PROMPT_PROTOBUF_LIB
()
ENDIF
()
ENDIF
(
PROTOBUF_FOUND
)
ELSE
()
...
...
@@ -120,18 +153,22 @@ ELSE()
ENDIF
()
IF
(
NOT PROTOBUF_FOUND
)
build_protobuf
(
protobuf FALSE
)
LIST
(
APPEND external_project_dependencies protobuf
)
build_protobuf
(
extern_protobuf FALSE
)
SET
(
PROTOBUF_INCLUDE_DIR
${
protobuf_INCLUDE_DIR
}
SET
(
PROTOBUF_INCLUDE_DIR
${
extern_
protobuf_INCLUDE_DIR
}
CACHE PATH
"protobuf include directory."
FORCE
)
IF
(
NOT CMAKE_CROSSCOMPILING
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
${
protobuf_PROTOC_EXECUTABLE
}
SET
(
PROTOBUF_LITE_LIBRARY
${
extern_protobuf_LITE_LIBRARY
}
CACHE FILEPATH
"protobuf lite library."
FORCE
)
SET
(
PROTOBUF_LIBRARY
${
extern_protobuf_LIBRARY
}
CACHE FILEPATH
"protobuf library."
FORCE
)
SET
(
PROTOBUF_PROTOC_LIBRARY
${
extern_protobuf_PROTOC_LIBRARY
}
CACHE FILEPATH
"protoc library."
FORCE
)
IF
(
CMAKE_CROSSCOMPILING
)
PROMPT_PROTOBUF_LIB
(
protobuf_host extern_protobuf
)
ELSE
()
SET
(
PROTOBUF_PROTOC_EXECUTABLE
${
extern_protobuf_PROTOC_EXECUTABLE
}
CACHE FILEPATH
"protobuf executable."
FORCE
)
PROMPT_PROTOBUF_LIB
(
extern_protobuf
)
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
)
PROMPT_PROTOBUF_LIB
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录