简体   繁体   English

两个子项目 A 和 B,A 依赖于 B 并检查 B 中存在的功能

[英]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.

相关问题 如何构建依赖于目标 A 的执行和输出的目标 B - How to build target B which depends on target A's execution and output 项目A依赖共享库B,B依赖C,A不依赖C。当我使用B的API时,警告B找不到C - Project A rely on shared library B, B rely on C, A don't rely on C. When I use an API of B, warning B can't find C cmake.-B build - 编译神经图形基元 - cmake . -B build - Compiling Neural Graphic Primitives CMake在子模块B中不包含子模块A的头文件目录 - CMake doesn't include header directory of submodule A within submodule B CMake:如何将库 A 链接到库 B,然后将可执行文件链接到库 A - CMake: How to link library A to library B, then link executable to library A 在RaspberryPi 3B +问题上交叉编译ROS Melodic - Cross-Compiling ROS Melodic on RaspberryPi 3B+ Problem cmake:子目录B中的目标需要传递的子目录A中的生成头 - cmake: generated header in subdir A needed transitively by target in subdir B 一个项目A依赖共享库B,B依赖C,A不依赖C,为什么我需要A的CMakelist.txt中的find_package和targe_link C? - a project A rely on shared library B, B rely on C, A don't rely on C, why I need to find_package and targe_link C in CMakelist.txt of A? 在构建add_subdirectory(B)之前安装add_subdirectory(A)头文件 - Install add_subdirectory(A) header files before building add_subdirectory(B) Windows上的OpenCL库出现0xc000007b加载时间错误 - 0xc000007b load-time error with OpenCL library on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM