Skip to content

Add the automatic update of submodules in cmake. #951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ find_package(Git REQUIRED)
# version.cmake will get the current PADDLE_VERSION
include(version)
add_definitions(-DPADDLE_VERSION=${PADDLE_VERSION})
include(submodules)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

名字叫submodules,以后的第三方模块意思是都写里面?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个,其实我不确定,原来有考虑要不要写一个通用的。不过,也许以后也不会再有submodule了。


if(NOT WITH_GPU)
add_definitions(-DPADDLE_ONLY_CPU)
Expand Down
28 changes: 28 additions & 0 deletions cmake/submodules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Automatically init submodules
if(EXISTS ${PROJECT_SOURCE_DIR}/.gitmodules)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROJECT_SOURCE_DIR => ${PROJ_ROOT}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

# warp-ctc
function(FindWarpCTC)
set(WARPCTC_ROOT $ENV{WARPCTC_ROOT} CACHE PATH "Folder contains warp-ctc")
find_path(WARPCTC_INCLUDE_DIR ctc.h PATHS
${WARPCTC_ROOT}/include ${PROJECT_SOURCE_DIR}/warp-ctc/include)
endfunction(FindWarpCTC)

FindWarpCTC()
if(NOT WARPCTC_INCLUDE_DIR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是可以不用FindWarpCTC()?

if(EXISTS ${PROJECT_SOURCE_DIR}/.gitmodules)
execute_process(
       COMMAND ${GIT_EXECUTABLE} submodule update --init -- warp-ctc
       WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
       OUTPUT_VARIABLE GIT_OUTPUT
       RESULT_VARIABLE GIT_RESULT)
       message(STATUS ${GIT_OUTPUT})

if(${GIT_RESULT})
...
else()
fatal...
endif()
endif()

另外modules一次性 --recursive 有什么区别?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我其实对于这个GIT_RESULT做了挺多次实验,发现有时候,执行git submodule update --init -- warp-ctc并没有把warp-ctc拉下来,返回结果一直都是0。

Copy link
Contributor

@gangliao gangliao Dec 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可否用 @gangliaohttps://github.com/gangliao/CodeCoverageCMake/blob/master/cmake/third_party.cmake 这里使用的 ExternalProject_Add,而不是自己写代码去 git pull warp-ctc 呢?

execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init -- warp-ctc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_OUTPUT
RESULT_VARIABLE GIT_RESULT)
message(STATUS ${GIT_OUTPUT})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECK GIT_RESULT is ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我其实对于这个GIT_RESULT做了挺多次实验,发现有时候,执行git submodule update --init -- warp-ctc并没有把warp-ctc拉下来,返回结果一直都是0。不知道是不是我哪里弄得不对。。。

FindWarpCTC()
endif()

if(NOT WARPCTC_INCLUDE_DIR)
message(FATAL_ERROR "warp-ctc must be set."
"Try set WARPCTC_ROOT or run command git submodule --init -- warp-ctc.")
else()
message(STATUS "Found warp-ctc (include: ${WARPCTC_INCLUDE_DIR})")
endif()
include_directories(${WARPCTC_INCLUDE_DIR})
endif()
2 changes: 1 addition & 1 deletion paddle/cuda/include/hl_warpctc_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License. */
#ifndef HL_WARPCTC_WRAP_H_
#define HL_WARPCTC_WRAP_H_

#include "ctc.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是还是原来的写法(`#include "warp-ctc/include/ctc.h")更清晰,能体现出头文件到底在哪里。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

增加了一个WARPCTC_ROOT的cmake选项,原意是如果用户机器上已经安装过warp-ctc,则可以直接使用已经安装好的这个版本。看是否需要支持这种情况吧。

#include "hl_base.h"
#include "warp-ctc/include/ctc.h"

typedef ctcStatus_t hl_warpctc_status_t;
typedef ctcOptions hl_warpctc_options_t;
Expand Down