Cmake:如何生成<project> Targets- <configuration> .cmake文件? (例如,MyLibTargets-debug.cmake)</configuration> </project>

时间:2014-05-15 14:17:43

标签: cmake

标题说明了一切。如何生成<Project>Targets-<configuration>.cmake文件?通过哪个命令? (注意:通过配置,我的意思是CMAKE_BUILD_TYPE变量的内容,即debug,release等。


注意:我知道install(EXPORT fooTargets FILE "FooTargets.cmake" DESTINATION lib/foo)(其中foo是我的自定义库,而fooTargetsinstall(TARGETS foo EXPORT fooTargets ...)的导出值)会创建基本的<Project>Targets.cmake文件,但是它还需要配置/构建类型文件,我找不到更多相关信息。


更新

看起来这个文件是使用install(EXPORT ...)命令生成的,但在Windows版本的cpack中是一个bug,在运行cpack时会忽略它。如果我有时间,我会做更多的研究,然后发布结果。

1 个答案:

答案 0 :(得分:1)

您需要删除FILE子选项:

install(EXPORT fooTargets DESTINATION lib/foo)

来自documentation

By default the generated file will be called <export-name>.cmake but the FILE
option may be used to specify a different name.

看看这个项目:https://github.com/forexample/package-example

相关问题