Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
de77faf5
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
de77faf5
编写于
6月 27, 2017
作者:
G
gangliao
提交者:
GitHub
6月 27, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2583 from gangliao/go_generic
FIX: Polish go library
上级
718eff9b
4bfd757e
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
48 addition
and
217 deletion
+48
-217
cmake/generic.cmake
cmake/generic.cmake
+45
-32
cmake/system.cmake
cmake/system.cmake
+1
-0
go/cmake/CMakeDetermineGoCompiler.cmake
go/cmake/CMakeDetermineGoCompiler.cmake
+0
-44
go/cmake/CMakeGoCompiler.cmake.in
go/cmake/CMakeGoCompiler.cmake.in
+0
-8
go/cmake/CMakeGoInformation.cmake
go/cmake/CMakeGoInformation.cmake
+0
-7
go/cmake/CMakeTestGoCompiler.cmake
go/cmake/CMakeTestGoCompiler.cmake
+0
-1
go/cmake/flags.cmake
go/cmake/flags.cmake
+0
-45
go/cmake/golang.cmake
go/cmake/golang.cmake
+0
-48
go/pserver/cclient/CMakeLists.txt
go/pserver/cclient/CMakeLists.txt
+0
-11
go/pserver/cclient/test/CMakeLists.txt
go/pserver/cclient/test/CMakeLists.txt
+2
-21
未找到文件。
cmake/generic.cmake
浏览文件 @
de77faf5
...
...
@@ -77,6 +77,15 @@
# /cmake/external/*.cmake:
#
# cc_test(example_test SRCS example_test.cc DEPS example glog gflags)
#
# To build a go static library using Golang, use the go_ prefixed version:
#
# go_library(example STATIC)
#
# To build a go shared library using Golang, use the go_ prefixed version:
#
# go_library(example SHARED)
#
if
(
NOT APPLE
)
find_package
(
Threads REQUIRED
)
...
...
@@ -246,42 +255,53 @@ endfunction(nv_test)
set
(
GOPATH
"
${
CMAKE_CURRENT_BINARY_DIR
}
/go"
)
file
(
MAKE_DIRECTORY
${
GOPATH
}
)
set
(
PADDLE_IN_GOPATH
"
${
GOPATH
}
/src/github.com/PaddlePaddle/Paddle"
)
# Because api.go defines a GO wrapper to ops and tensor, it depends on
# both. This implies that if any of tensor.{h,cc}, ops.{h,cu}, or
# api.go is changed, api need to be re-built.
# go_library(api
# SRCS
# api.go
# DEPS
# tensor # Because ops depend on tensor, this line is optional.
# ops)
function
(
go_library TARGET_NAME
)
set
(
options
OPTIONAL
)
set
(
options
STATIC static SHARED shared
)
set
(
oneValueArgs
""
)
set
(
multiValueArgs
SRCS
DEPS
)
set
(
multiValueArgs DEPS
)
cmake_parse_arguments
(
go_library
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
if
(
${
go_library_OPTIONAL
}
STREQUAL
"SHARED"
)
if
(
go_library_SHARED OR go_library_shared
)
set
(
BUILD_MODE
"-buildmode=c-shared"
)
if
(
APPLE
)
set
(
LIB_NAME
"lib
${
TARGET_NAME
}
.dylib"
)
else
()
set
(
LIB_NAME
"lib
${
TARGET_NAME
}
.so"
)
endif
()
set
(
LIB_NAME
"
${
CMAKE_SHARED_LIBRARY_PREFIX
}${
TARGET_NAME
}${
CMAKE_SHARED_LIBRARY_SUFFIX
}
"
)
else
()
set
(
BUILD_MODE
"-buildmode=c-archive"
)
set
(
LIB_NAME
"
lib
${
TARGET_NAME
}
.a
"
)
set
(
LIB_NAME
"
${
CMAKE_STATIC_LIBRARY_PREFIX
}${
TARGET_NAME
}${
CMAKE_STATIC_LIBRARY_SUFFIX
}
"
)
endif
()
add_custom_command
(
OUTPUT
${
TARGET_NAME
}
_timestamp
# Add dummy code to support `make target_name` under Terminal Command
set
(
dummyfile
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
TARGET_NAME
}
_dummy.c
)
file
(
WRITE
${
dummyfile
}
"const char * dummy =
\"
${
dummyfile
}
\"
;"
)
if
(
go_library_SHARED OR go_library_shared
)
add_library
(
${
TARGET_NAME
}
SHARED
${
dummyfile
}
)
else
()
add_library
(
${
TARGET_NAME
}
STATIC
${
dummyfile
}
)
endif
()
if
(
go_library_DEPS
)
add_dependencies
(
${
TARGET_NAME
}
${
go_library_DEPS
}
)
endif
(
go_library_DEPS
)
# we need to symlink Paddle directory into GOPATH. If we
# don't do it and we have code that depends on Paddle, go
# get ./... will download a new Paddle repo from Github,
# without the changes in our current Paddle repo that we
# want to build.
file
(
GLOB GO_SOURCE RELATIVE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"*.go"
)
add_custom_command
(
TARGET
${
TARGET_NAME
}
POST_BUILD
COMMAND rm
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
LIB_NAME
}
"
# Symlink Paddle directory into GOPATH
COMMAND mkdir -p
${
PADDLE_IN_GOPATH
}
COMMAND rm -rf
${
PADDLE_IN_GOPATH
}
COMMAND ln -sf
${
CMAKE_SOURCE_DIR
}
${
PADDLE_IN_GOPATH
}
# Automatically get all dependencies specified in the source code
COMMAND env GOPATH=
${
GOPATH
}
${
CMAKE_Go_COMPILER
}
get -d ./..
# Golang build source code
COMMAND env GOPATH=
${
GOPATH
}
${
CMAKE_Go_COMPILER
}
build
${
BUILD_MODE
}
-o
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
LIB_NAME
}
"
${
go_library_SRCS
}
${
GO_SOURCE
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
)
add_custom_target
(
${
TARGET_NAME
}
_lib ALL DEPENDS
${
TARGET_NAME
}
_timestamp
${
go_library_DEPS
}
)
add_library
(
${
TARGET_NAME
}
STATIC IMPORTED
)
set_property
(
TARGET
${
TARGET_NAME
}
PROPERTY
IMPORTED_LOCATION
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
LIB_NAME
}
"
)
add_dependencies
(
${
TARGET_NAME
}
${
TARGET_NAME
}
_lib
)
endfunction
(
go_library
)
function
(
go_binary TARGET_NAME
)
...
...
@@ -311,10 +331,3 @@ function(go_test TARGET_NAME)
add_custom_target
(
${
TARGET_NAME
}
ALL DEPENDS
${
TARGET_NAME
}
_timestamp
${
go_test_DEPS
}
)
add_test
(
${
TARGET_NAME
}
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
TARGET_NAME
}
)
endfunction
(
go_test
)
# go_extern will download extern go project.
# go_extern(target_name extern_source)
# go_extern(go_redis github.com/hoisie/redis)
function
(
go_extern TARGET_NAME
)
add_custom_target
(
${
TARGET_NAME
}
env GOPATH=
${
GOPATH
}
${
CMAKE_Go_COMPILER
}
get
${
ARGN
}
)
endfunction
(
go_extern
)
cmake/system.cmake
浏览文件 @
de77faf5
...
...
@@ -33,6 +33,7 @@ ELSE(WIN32)
SET
(
CMAKE_OSX_DEPLOYMENT_TARGET
${
MACOS_VERSION
}
CACHE STRING
"Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value."
)
ENDIF
()
set
(
CMAKE_EXE_LINKER_FLAGS
"-framework CoreFoundation -framework Security"
)
ELSE
(
APPLE
)
IF
(
EXISTS
"/etc/issue"
)
...
...
go/cmake/CMakeDetermineGoCompiler.cmake
已删除
100644 → 0
浏览文件 @
718eff9b
if
(
NOT CMAKE_Go_COMPILER
)
if
(
NOT $ENV{GO_COMPILER} STREQUAL
""
)
get_filename_component
(
CMAKE_Go_COMPILER_INIT $ENV{GO_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Go_FLAGS_ENV_INIT
)
if
(
CMAKE_Go_FLAGS_ENV_INIT
)
set
(
CMAKE_Go_COMPILER_ARG1
"
${
CMAKE_Go_FLAGS_ENV_INIT
}
"
CACHE STRING
"First argument to Go compiler"
)
endif
()
if
(
NOT EXISTS
${
CMAKE_Go_COMPILER_INIT
}
)
message
(
SEND_ERROR
"Could not find compiler set in environment variable GO_COMPILER:
\n
$ENV{GO_COMPILER}."
)
endif
()
endif
()
set
(
Go_BIN_PATH
$ENV{GOPATH}
$ENV{GOROOT}
$ENV{GOROOT}/../bin
$ENV{GO_COMPILER}
/usr/bin
/usr/local/bin
)
if
(
CMAKE_Go_COMPILER_INIT
)
set
(
CMAKE_Go_COMPILER
${
CMAKE_Go_COMPILER_INIT
}
CACHE PATH
"Go Compiler"
)
else
()
find_program
(
CMAKE_Go_COMPILER
NAMES go
PATHS
${
Go_BIN_PATH
}
)
EXEC_PROGRAM
(
${
CMAKE_Go_COMPILER
}
ARGS version OUTPUT_VARIABLE GOLANG_VERSION
)
STRING
(
REGEX MATCH
"go[0-9]+.[0-9]+.[0-9]+[ /A-Za-z0-9]*"
VERSION
"
${
GOLANG_VERSION
}
"
)
message
(
"-- The Golang compiler identification is
${
VERSION
}
"
)
message
(
"-- Check for working Golang compiler:
${
CMAKE_Go_COMPILER
}
"
)
endif
()
endif
()
mark_as_advanced
(
CMAKE_Go_COMPILER
)
configure_file
(
${
CMAKE_MODULE_PATH
}
/CMakeGoCompiler.cmake.in
${
CMAKE_PLATFORM_INFO_DIR
}
/CMakeGoCompiler.cmake @ONLY
)
set
(
CMAKE_Go_COMPILER_ENV_VAR
"GO_COMPILER"
)
go/cmake/CMakeGoCompiler.cmake.in
已删除
100644 → 0
浏览文件 @
718eff9b
set(CMAKE_Go_COMPILER "@CMAKE_Go_COMPILER@")
set(CMAKE_Go_COMPILER_LOADED 1)
set(CMAKE_Go_SOURCE_FILE_EXTENSIONS go)
set(CMAKE_Go_LINKER_PREFERENCE 40)
set(CMAKE_Go_OUTPUT_EXTENSION .o)
set(CMAKE_Go_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_Go_COMPILER_ENV_VAR "GO_COMPILER")
go/cmake/CMakeGoInformation.cmake
已删除
100644 → 0
浏览文件 @
718eff9b
if
(
NOT CMAKE_Go_COMPILE_OBJECT
)
set
(
CMAKE_Go_COMPILE_OBJECT
"go tool compile -l -N -o <OBJECT> <SOURCE> "
)
endif
()
if
(
NOT CMAKE_Go_LINK_EXECUTABLE
)
set
(
CMAKE_Go_LINK_EXECUTABLE
"go tool link -o <TARGET> <OBJECTS> "
)
endif
()
go/cmake/CMakeTestGoCompiler.cmake
已删除
100644 → 0
浏览文件 @
718eff9b
set
(
CMAKE_Go_COMPILER_WORKS 1 CACHE INTERNAL
""
)
go/cmake/flags.cmake
已删除
100644 → 0
浏览文件 @
718eff9b
# Setting Paddle Compile Flags
include
(
CheckCXXCompilerFlag
)
include
(
CheckCCompilerFlag
)
include
(
CheckCXXSymbolExists
)
include
(
CheckTypeSize
)
function
(
CheckCompilerCXX11Flag
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
if
(
${
CMAKE_CXX_COMPILER_VERSION
}
VERSION_LESS 4.8
)
message
(
FATAL_ERROR
"Unsupported GCC version. GCC >= 4.8 required."
)
endif
()
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
OR CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
# cmake >= 3.0 compiler id "AppleClang" on Mac OS X, otherwise "Clang"
# Apple Clang is a different compiler than upstream Clang which havs different version numbers.
# https://gist.github.com/yamaya/2924292
if
(
APPLE
)
# cmake < 3.0 compiler id "Clang" on Mac OS X
if
(
${
CMAKE_CXX_COMPILER_VERSION
}
VERSION_LESS 5.1
)
message
(
FATAL_ERROR
"Unsupported AppleClang version. AppleClang >= 5.1 required."
)
endif
()
else
()
if
(
${
CMAKE_CXX_COMPILER_VERSION
}
VERSION_LESS 3.3
)
message
(
FATAL_ERROR
"Unsupported Clang version. Clang >= 3.3 required."
)
endif
()
endif
()
endif
()
endfunction
()
CheckCompilerCXX11Flag
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
# Common gpu architectures: Kepler, Maxwell
foreach
(
capability 30 35 50
)
list
(
APPEND __arch_flags
" -gencode arch=compute_
${
capability
}
,code=sm_
${
capability
}
"
)
endforeach
()
if
(
CUDA_VERSION VERSION_GREATER
"7.0"
OR CUDA_VERSION VERSION_EQUAL
"7.0"
)
list
(
APPEND __arch_flags
" -gencode arch=compute_52,code=sm_52"
)
endif
()
# Modern gpu architectures: Pascal
if
(
CUDA_VERSION VERSION_GREATER
"8.0"
OR CUDA_VERSION VERSION_EQUAL
"8.0"
)
list
(
APPEND __arch_flags
" -gencode arch=compute_60,code=sm_60"
)
endif
()
set
(
CUDA_NVCC_FLAGS
${
__arch_flags
}
${
CUDA_NVCC_FLAGS
}
)
go/cmake/golang.cmake
已删除
100644 → 0
浏览文件 @
718eff9b
set
(
GOPATH
"
${
CMAKE_CURRENT_BINARY_DIR
}
/go"
)
file
(
MAKE_DIRECTORY
${
GOPATH
}
)
set
(
PADDLE_IN_GOPATH
"
${
GOPATH
}
/src/github.com/PaddlePaddle"
)
file
(
MAKE_DIRECTORY
${
PADDLE_IN_GOPATH
}
)
function
(
GO_LIBRARY NAME BUILD_TYPE
)
if
(
BUILD_TYPE STREQUAL
"STATIC"
)
set
(
BUILD_MODE -buildmode=c-archive
)
set
(
LIB_NAME
"lib
${
NAME
}
.a"
)
else
()
set
(
BUILD_MODE -buildmode=c-shared
)
if
(
APPLE
)
set
(
LIB_NAME
"lib
${
NAME
}
.dylib"
)
else
()
set
(
LIB_NAME
"lib
${
NAME
}
.so"
)
endif
()
endif
()
file
(
GLOB GO_SOURCE RELATIVE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"*.go"
)
file
(
RELATIVE_PATH rel
${
CMAKE_CURRENT_BINARY_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
# find Paddle directory.
get_filename_component
(
PARENT_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
DIRECTORY
)
get_filename_component
(
PARENT_DIR
${
PARENT_DIR
}
DIRECTORY
)
get_filename_component
(
PADDLE_DIR
${
PARENT_DIR
}
DIRECTORY
)
# automatically get all dependencies specified in the source code
# for given target.
add_custom_target
(
${
NAME
}
_goGet env GOPATH=
${
GOPATH
}
${
CMAKE_Go_COMPILER
}
get -d
${
rel
}
/...
)
# make a symlink that references Paddle inside $GOPATH, so go get
# will use the local changes in Paddle rather than checkout Paddle
# in github.
add_custom_target
(
${
NAME
}
_copyPaddle
COMMAND rm -rf
${
PADDLE_IN_GOPATH
}
/Paddle
COMMAND ln -sf
${
PADDLE_DIR
}
${
PADDLE_IN_GOPATH
}
/Paddle
)
add_dependencies
(
${
NAME
}
_goGet
${
NAME
}
_copyPaddle
)
add_custom_command
(
OUTPUT
${
OUTPUT_DIR
}
/.timestamp
COMMAND env GOPATH=
${
GOPATH
}
${
CMAKE_Go_COMPILER
}
build
${
BUILD_MODE
}
-o
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
LIB_NAME
}
"
${
CMAKE_GO_FLAGS
}
${
GO_SOURCE
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
)
add_custom_target
(
${
NAME
}
ALL DEPENDS
${
OUTPUT_DIR
}
/.timestamp
${
ARGN
}
)
add_dependencies
(
${
NAME
}
${
NAME
}
_goGet
)
endfunction
(
GO_LIBRARY
)
go/pserver/cclient/CMakeLists.txt
浏览文件 @
de77faf5
cmake_minimum_required
(
VERSION 3.0
)
get_filename_component
(
PARENT_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
DIRECTORY
)
get_filename_component
(
PARENT_DIR
${
PARENT_DIR
}
DIRECTORY
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
PARENT_DIR
}
/cmake"
)
project
(
cxx_go C Go
)
include
(
golang
)
include
(
flags
)
go_library
(
paddle_pserver_cclient STATIC
)
add_subdirectory
(
test
)
go/pserver/cclient/test/CMakeLists.txt
浏览文件 @
de77faf5
cmake_minimum_required
(
VERSION 3.0
)
add_executable
(
main main.c
)
add_dependencies
(
main paddle_pserver_cclient
)
add_executable
(
test_cclient test_cclient.c
)
add_dependencies
(
test_cclient paddle_pserver_cclient
)
if
(
APPLE
)
set
(
CMAKE_EXE_LINKER_FLAGS
"-framework CoreFoundation -framework Security"
)
else
()
set
(
CMAKE_EXE_LINKER_FLAGS
"-pthread"
)
endif
()
if
(
PROJ_ROOT
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
/..
)
target_link_libraries
(
main
${
CMAKE_CURRENT_BINARY_DIR
}
/../libpaddle_pserver_cclient.a pthread
)
target_link_libraries
(
test_cclient
${
CMAKE_CURRENT_BINARY_DIR
}
/../libpaddle_pserver_cclient.a pthread
)
else
(
PROJ_ROOT
)
include_directories
(
${
CMAKE_BINARY_DIR
}
)
target_link_libraries
(
main
${
CMAKE_BINARY_DIR
}
/libpaddle_pserver_cclient.a pthread
)
target_link_libraries
(
test_cclient
${
CMAKE_BINARY_DIR
}
/libpaddle_pserver_cclient.a pthread
)
endif
(
PROJ_ROOT
)
cc_library
(
main SRCS main.c DEPS paddle_pserver_cclient
)
cc_test
(
test_cclient SRCS test_cclient.c DEPS paddle_pserver_cclient
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录