[英]exporting cmake build options to external project
I have got a C++ Library A. A can be installed in a multitude of ways depending on which external dependencies are used. 我有一个C ++库A。A可以以多种方式安装,具体取决于所使用的外部依赖项。 This also changes depending on whether the library is build in debug or release mode.
这也取决于库是在调试模式还是发行模式下生成的。 This means that some features might not be available or some types/defines need to be changed in order to link to the library.
这意味着某些功能可能不可用,或者某些类型/定义需要更改才能链接到库。
Now I want to link A to a local project B. I have set up a ProjectConfig.cmake file for A which is located at /path/lib/CMake/A/AConfig.cmake which is found and works fine in a minimal build. 现在,我想将A链接到本地项目B。我为A建立了一个ProjectConfig.cmake文件,该文件位于/path/lib/CMake/A/AConfig.cmake,该文件可以在最小的构建中找到并正常工作。 However as soon as I add definitions to the compilation or include some packages, this information is not automatically exported.
但是,一旦我在编译中添加定义或包括一些软件包,该信息就不会自动导出。 This makes linking to A hard as for example I need to know that OpenMP was used to have a coherent build.
这使得链接到A变得很困难,例如,我需要知道OpenMP曾用于构建一致的版本。
Is there a way to export this information the same way the ProjectConfig.cmake does it? 有没有一种方法可以像ProjectConfig.cmake一样导出此信息?
Generate the ProjectConfig.cmake file to contain what you need it to contain. 生成ProjectConfig.cmake文件以包含您需要包含的内容。
http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
Note that if you set the usage requirements of the targets, you have less need to generate the file. 请注意,如果您设置了目标的使用要求,则生成文件的需求将更少。
http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.