lin*_*123 7 cmake external-project
git 命令理解的 URL 可以是 HTTPS 或 SSH 格式。
在 CMake 中,可以使用 git 命令理解的任何 URLExternalProject_Add来指定指定的GIT_REPOSITORYURL。
必须提供使用 HTTPS 用户凭据才能“克隆”私有存储库。对于ExternalProject_Add,这种机制以 的形式HTTP_USERNAME和HTTP_PASSWORD使用时存在DOWNLOAD_COMMAND。
因为GIT_REPOSITORY似乎没有这样的方法。使用时:
include( ExternalProject )
ExternalProject_Add(test
GIT_REPOSITORY git@github.com:myuser/myprivaterepo.git
GIT_REMOTE_NAME origin
)
Run Code Online (Sandbox Code Playgroud)
在私有存储库上,给出以下错误:
fatal: could not read Username for 'https://github.com': No such device or address
Run Code Online (Sandbox Code Playgroud)
GIT_REPOSITORY在使用 HTTPS 连接到私有存储库时,如何让 CMake 请求密码ExternalProject_Add?
虽然 CMake 没有提供用于提供用户凭据的显式 Git 选项(例如HTTP_USERNAME和HTTP_PASSWORD),但您可以操作 Git URL,以便系统提示您输入登录密码,如此处所述。只需在 URL 中指定您username的:@
ExternalProject_Add(test
GIT_REPOSITORY https://username@github.com/myuser/myprivaterepo.git
GIT_REMOTE_NAME origin
USES_TERMINAL_DOWNLOAD ON
)
Run Code Online (Sandbox Code Playgroud)
请注意,您可能还需要启用允许USES_TERMINAL_DOWNLOAD终端输入的选项来输入您的凭据。您还可以直接在 URL 本身中提供密码,但最佳实践不建议这样做:
ExternalProject_Add(test
GIT_REPOSITORY https://username:password@github.com/myuser/myprivaterepo.git
GIT_REMOTE_NAME origin
USES_TERMINAL_DOWNLOAD ON
)
Run Code Online (Sandbox Code Playgroud)
作为奖励,这也适用于 Bitbucket 帐户。
| 归档时间: |
|
| 查看次数: |
305 次 |
| 最近记录: |