cmake第三方步骤依赖

cmake third party step dependency

我们在源代码中使用供应商代码作为第三方项目。此派对项目托管在不同的服务器上。

我们的应用程序需要包含来自第三方项目的头文件。到目前为止,应用程序 cmake 依赖于外部项目,直到外部项目安装完成,应用程序才会开始构建。

从逻辑上讲,应用程序可以在下载第三方项目并且头文件可用后开始构建。 为了实现同样的目标,我可以有一个步骤取决于 configure/download

ExternalProject_Add_Step(CopyHeaderFileStep DEPENDS configure)

然而,由于它只是一个步骤,而不是目标,我无法在我的应用程序 CMake 中指定 CopyHeaderFileStep 的依赖项。

我仔细查看了 cmake 第三方文档,但没有帮助。这里有什么出路吗?

However since it is just a step, not target, I am not able to specify dependecy of CopyHeaderFileStep in my application CMake.

正是为了这个目的,有一个函数 ExternalProject_Add_StepTargets,它为 ExternalProject 的步骤创建正常的 CMake 目标。来自 documentation:

ExternalProject_Add_StepTargets() function generates targets for the steps listed. The name of each created target will be of the form <name>-<step>.

示例:

# Create targets for steps
ExternalProject_Add_StepTargets(extProject # External project name
    CopyHeaderFileStep # List of steps, for which targets will be created
)

# Depend on these targets in outer code
add_dependencies(myApp extProject-CopyHeaderFileStep)