在git存储库之外的init git子模块

时间:2016-06-09 17:34:14

标签: git github restbed

首先,这个问题可能听起来很愚蠢,但我认为没有办法做到这一点。

对于其中一个工作项目,我需要添加一个依赖项。有一个脚本可以自动抓取tarball存档,解压缩,添加补丁并构建它。在我的例子中,我有一个github项目的tarball(restbed),它需要自己的依赖项,作为子模块(asio,openssl和catch)。主要问题是存档只包含restbed的源,而不包含依赖项。

希望存档中有.gitmodules文件

[submodule "dependency/asio"]
        path = dependency/asio
        url = https://github.com/corvusoft/asio-dependency
        branch = master
[submodule "dependency/catch"]
        path = dependency/catch
        url = https://github.com/corvusoft/catch-dependency
        branch = master
[submodule "dependency/openssl"]
        path = dependency/openssl
        url = https://github.com/corvusoft/openssl-dependency
        branch = OpenSSL_1_0_2-stable

所以我尝试了经典的git submodule init,它给了我fatal: Not a git repository (or any of the parent directories): .git

那么,有没有办法获得项目的依赖关系,还是我必须手动将它们添加到项目中?

感谢。

1 个答案:

答案 0 :(得分:0)

独立于Restbed安装和构建所需的依赖项。该项目有cmake find modules,可在构建过程中检测公共路径中所需的组件,请参阅下面的OpenSSL模块:

# Copyright 2013-2016, Corvusoft Ltd, All Rights Reserved.

find_library( ssl_LIBRARY ssl ssleay32 HINTS "${CMAKE_SOURCE_DIR}/dependency/openssl/out32dll" "${CMAKE_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_library( crypto_LIBRARY crypto libeay32 HINTS "${CMAKE_SOURCE_DIR}/dependency/openssl/out32dll" "${CMAKE_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_path( ssl_INCLUDE openssl/ssl.h HINTS "${CMAKE_SOURCE_DIR}/dependency/openssl/inc32" "${CMAKE_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/openssl/lib" "/usr/include" "/usr/local/include" "/opt/local/include" )

if ( ssl_INCLUDE AND ssl_LIBRARY AND crypto_LIBRARY )
    set( OPENSSL_FOUND TRUE )
    add_definitions( -DBUILD_SSL=TRUE )

    if ( APPLE AND BUILD_SSL )
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations" )
    endif( )

    message( STATUS "${Green}Found OpenSSL library at: ${ssl_LIBRARY}${Reset}" )
    message( STATUS "${Green}Found OpenSSL include at: ${ssl_INCLUDE}${Reset}" )
    message( STATUS "${Green}Found Crypto library at: ${crypto_LIBRARY}${Reset}" )
else ( )
    message( FATAL_ERROR "${Red}Failed to locate OpenSSL dependency. see restbed/dependency/openssl; ./config shared; make all${Reset}" )
endif ( )