Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7bce40d7
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看板
提交
7bce40d7
编写于
6月 21, 2017
作者:
G
gangliao
提交者:
GitHub
6月 21, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2538 from wangkuiyi/generic.cmake-comments
Rewrite tutorial comments in generic.cmake
上级
603fd43d
252ef0cb
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
54 addition
and
62 deletion
+54
-62
cmake/generic.cmake
cmake/generic.cmake
+54
-62
未找到文件。
cmake/generic.cmake
浏览文件 @
7bce40d7
...
@@ -12,9 +12,11 @@
...
@@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
#
#
# To simplify the build process of PaddlePaddle, we defined couple of
# fundamental abstractions, e.g., how to build library, binary and
# test in C++, CUDA and Go.
# generic.cmake defines CMakes functions that look like Bazel's
# building rules (https://bazel.build/).
#
#
#
# -------------------------------------------
# -------------------------------------------
# C++ CUDA C++ Go
# C++ CUDA C++ Go
...
@@ -24,67 +26,57 @@
...
@@ -24,67 +26,57 @@
# cc_test nv_test go_test
# cc_test nv_test go_test
# -------------------------------------------
# -------------------------------------------
#
#
#
cmake_parse_arguments can help us to achieve this goal.
#
To build a static library example.a from example.cc using the system
#
https://cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html
#
compiler (like GCC):
#
#
#
cc_library|nv_library(<target_name> [STATIC SHARED] SRCS <file>... DEPS <libs>...
)
#
cc_library(example SRCS example.cc
)
#
#
#
cc_library and nv_library can generate *.a, or *.so
#
To build a static library example.a from multiple source files
#
if the corresponding keyword STATIC or SHARED is specified.
#
example{1,2,3}.cc:
#
#
#
cc_binary|nv_binary(<target_name> SRCS <file>... DEPS <libs>...
)
#
cc_library(example SRCS example1.cc example2.cc example3.cc
)
#
#
# cc_binary and nv_binary can build souce code and link the dependent
# To build a shared library example.so from example.cc:
# libraries to generate a binary.
#
#
#
cc_test|nv_test(<target_name> SRCS <file>... DEPS <libs>...
)
#
cc_library(example SHARED SRCS example.cc
)
#
#
#
cc_test and nv_test can build test code, link gtest and other dependent
#
To build a library using Nvidia's NVCC from .cu file(s), use the nv_
#
libraries to generate test suite.
#
prefixed version:
#
#
# For example, in one folder, it contains
# nv_library(example SRCS example.cu)
# ddim{.h, .cc, _test.cc, _test.cu}
# place{.h, cc, _test.cc}
#
#
#
We can add build script as follows:
#
To specify that a library new_example.a depends on other libraies:
#
#
#
cc_library(place STATIC SRCS place.cc
)
#
cc_library(new_example SRCS new_example.cc DEPS example
)
#
#
# place.cc -> place.a
# Static libraries can be composed of other static libraries:
# cc_library's STATIC OPTION will generate libplace.a.
#
#
# cc_test(place_test
# cc_library(composed DEPS dependent1 dependent2 dependent3)
# SRCS place_test.cc
# DEPS place glog gflags)
#
#
# place_test.cc, place, glog, gflags -> place_test
# To build an executable binary file from some source files and
# cc_test will combine place_test.cc, libplace.a with libglog.a.
# dependent libraries:
# and libgflags.a to generate place_test.
#
#
#
cc_library(ddim STATIC SRCS ddim.cc
)
#
cc_binary(example SRCS main.cc something.cc DEPS example1 example2
)
#
#
#
ddim.cc -> ddim.a
#
To build an executable binary file using NVCC, use the nv_ prefixed
#
cc_library's STATIC OPTION will generate libddim.a.
#
version:
#
#
# cc_test(ddim_test
# nv_binary(example SRCS main.cc something.cu DEPS example1 example2)
# SRCS ddim_test.cc
# DEPS ddim)
#
#
#
ddim_test.cc, ddim.a -> ddim_test
#
To build a unit test binary, which is an executable binary with
#
cc_test will build ddim_test.cc with libddim.a to generate ddim_test.
#
GoogleTest linked:
#
#
# nv_test(dim_test
# cc_test(example_test SRCS example_test.cc DEPS example)
# SRCS dim_test.cu
# DEPS ddim)
#
#
# dim_test.cu, ddim.a -> dim_test
# To build a unit test binary using NVCC, use the nv_ prefixed version:
# nv_test will build dim_test.cu with libddim.a to generate dim_test.
#
#
#
cc_library(framework DEPS place ddim
)
#
nv_test(example_test SRCS example_test.cu DEPS example
)
#
#
# place.a, ddim.a -> framework.a
# It is pretty often that executable and test binaries depend on
# If no SRCS exists, merging libplace.a and libddim.a to generate libframework.a.
# pre-defined external libaries like glog and gflags defined in
# /cmake/external/*.cmake:
#
#
# cc_test(example_test SRCS example_test.cc DEPS example glog gflags)
if
(
NOT APPLE
)
if
(
NOT APPLE
)
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录