我试图依赖非cmake,仅限标头的git库。以下似乎有效:
include(ExternalProject)
ExternalProject_Add(${REPO}-external
GIT_REPOSITORY [... path to repo ... ]
GIT_TAG [... some git tag ... ]
SOURCE_DIR external/${REPO}
BUILD_COMMAND ""
INSTALL_COMMAND ""
CONFIGURE_COMMAND "")
add_library(${REPO} INTERFACE)
add_dependencies(${REPO} ${REPO}-external)
target_include_directories(${REPO} SYSTEM INTERFACE external/${REPO}/include)
但这看起来真的很复杂,我希望我只是缺少一些关于如何正确使用这个功能的基础知识。有更直接的方法吗?