本文介绍了如何从add_custom_target /命令调用CMake函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 是否可以从add_custom_target或add_custom_command中调用一个CMake函数?我知道我可以将CMake函数移动到一个Python(或任何)脚本,并从add_custom_target /命令调用它,但我想避免在现有的CMake infra旁边有大量的脚本。 我想要实现的是使用CPack生成二进制工件的zip包并将它们发布在工件存储库中。对于发布部分,我已经创建了CMake函数,但现在我需要将打包和发布结合在一起。 感谢任何帮助/提示。 > Martin 解决方案在编写CMake构建系统时遇到此问题 BVLC / Caffe 。我最后做的是我把函数内容放入一个单独的CMake脚本,并通过调用 add_custom_target 中调用它: add_custom_target(target_name COMMAND $ {CMAKE_COMMAND} -P path_to_script ) b $ b 使用 -P 标志调用CMake使其成为脚本语言。您可以在脚本中放置任何CMake函数。 is it possible to call a CMake function out of an add_custom_target or add_custom_command? I know I could move the CMake function to a Python (or whatever) script and call it from add_custom_target/command but I would like to avoid having tons of script next to the existing CMake infra.What I want to achieve is to use CPack for generating a zip package of binary artifacts and publish them in an artifact repository. For the publishing part I have already the CMake function created but now I need to combine the packaging and publishing together.Thanks for any help/hints in advance.Martin 解决方案 I encountered this issue while writing a CMake build system for BVLC/Caffe. What I finally did is I put the function content into a separate CMake script and called it from within add_custom_target by invoking:add_custom_target(target_name COMMAND ${CMAKE_COMMAND} -P path_to_script)Invoking CMake with -P flag makes it act as a scripting language. You can put any CMake functions inside the script. 这篇关于如何从add_custom_target /命令调用CMake函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-12 05:52