[英]Two subprojects A and B, A depends on B and checks for features present in B
I'm trying to create a CMake project that integrates 2 sub-projects, specifically botan and rnpgp .我试图创建一个CMake的项目,集成了2个子项目,特别是牡丹和rnpgp 。 The build system of rnpgp is CMake-based, botan uses a Python configure script to generate a Makefile.
rnpgp 的构建系统是基于 CMake 的,botan 使用 Python 配置脚本生成 Makefile。 The problem is that during the CMake run rnpgp checks for features in botan, so it requires a compiled botan library.
问题是在 CMake 运行期间 rnpgp 检查 botan 中的功能,因此它需要一个编译的 botan 库。 But, botan doesn't get built until I actually call
make
, which I can't do because rnpgp fails to configure because botan isn't built yet.但是,在我实际调用
make
,botan 不会构建,我不能这样做,因为 rnpgp 无法配置,因为 botan 尚未构建。
What's the right way to specify such a dependency in CMake?在 CMake 中指定这种依赖项的正确方法是什么?
You could use CMake's execute_process()
to run the botan Python script and run make
during the CMake configure stage.您可以使用 CMake 的
execute_process()
来运行 botan Python 脚本并在 CMake 配置阶段运行make
。 This way, the botan library will be built and available to reference when running the mpgp CMake:这样,在运行 mpgp CMake 时,botan 库将被构建并可供参考:
# Run the Python script to configure the botan Makefile.
execute_process(COMMAND
python ${CMAKE_SOURCE_DIR}/botan/configure.py
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
# Run 'make' from the botan directory where the 'Makefile' was created.
execute_process(COMMAND
make
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/botan/build"
)
This is a rough example of what it could look like.这是它可能是什么样子的粗略示例。 You may have to modify the paths a bit to match where you have botan on your system, and where botan generates its build artifacts (ie location of the Makefile).
您可能需要稍微修改路径以匹配系统上有 botan 的位置以及 botan 生成其构建工件的位置(即 Makefile 的位置)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.