如何从add_custom_target/命令调用CMake函数
How to call a CMake function from add_custom_target/command?
是否可以从add_custom_target
或add_custom_command
中调用CMake函数?
我知道我可以将CMake函数移到Python(或其他)脚本中,并从add_custom_target
/command
调用它,但我希望避免在现有的CMake基础结构旁边有大量的脚本。
我想要实现的是使用CPack生成二进制工件的zip包,并将它们发布在工件存储库中。对于发布部分,我已经创建了CMake函数,但现在我需要将打包和发布结合在一起。
感谢您提前提供的任何帮助/提示。
我在为BVLC/Caffe编写CMake构建系统时遇到了这个问题。我最后做的是将函数内容放入一个单独的CMake脚本中,并通过调用从add_custom_target
中调用它
add_custom_target(target_name
COMMAND ${CMAKE_COMMAND} -P path_to_script
)
使用-P
标志调用CMake使其充当脚本语言。您可以在脚本中放入任何CMake函数。
相关文章:
- Netbeans 10:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 链接器命令失败,macOS 上的退出代码为 1(使用 -v 查看调用)
- cmake add_custom_command + Xcode:多输出 = 多命令调用
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 如何修复 clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 从 C++ 调用 cURL 命令会返回意外的错误代码,如 1792 和 6656
- Xcode:链接器命令失败,退出代码为 1(使用 -v 查看调用)[C++]
- 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用):在 Macbook 上
- 使用参数 + stdout + stderr 从命令行调用 MFC 应用程序
- 如果调用 RtlSetProcessIsCritical,将使用 lstrcmpW 将命令行与值进行比较将使程序崩溃
- clang:错误:链接器命令失败,C++代码中的退出代码为 1(使用 -v 查看调用)
- 将 Linux system() 调用命令的输出重定向到仅可变的
- Xcode 10.0:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 使用系统命令调用可执行文件
- 在C++中,有没有一种简单的方法可以通过iostream::cin获取带有参数的命令调用
- 如何在C++中调用预编译可执行文件中的函数(通过命令调用)
- 为给定的命令调用适当的方法
- 如何从add_custom_target/命令调用CMake函数
- 在Mac上用汉字命令调用popen()
- 诊断系统(命令)调用的问题