本文介绍了如何在 CMake execute_process 中使用 find -exec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 CMake install(DIRECTORIES...) 表单在安装时复制标题:

I use CMake install(DIRECTORIES...) form to copy headers on install:

install(DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}
  DESTINATION include
  FILES_MATCHING PATTERN "*.h")

但是,此命令 确实会创建空目录(那些没有找到标题的地方).因此,我想在安装过程中找到并删除那些空目录:

However, this command does create empty directories (those where no headers are found). Thus, I want to find and delete those empty directories during the install process:

install(CODE "execute_process(
  COMMAND find -type d -empty -exec rmdir '{}' ';'
  WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
  ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/prune_empty_dirs.err)")

使用上面的命令,文件 prune_empty_dirs.err 包含:

With the command above, the file prune_empty_dirs.err contains:

find: missing argument to `-exec'

我试图摆脱大括号,但它产生了相同的行为.我究竟做错了什么?谢谢,

I tried to escape the braces but it yields the same behavior. What am I doing wrong? Thanks,

推荐答案

我找到了解决方案.它不是{}"而不是分隔符;".以下语法对我有用(CMake 2.8.9):

I found the solution. It is not the "{}" rather than the delemiting ";". The following syntax worked for me (CMake 2.8.9):

--exec rm {} ";"

这篇关于如何在 CMake execute_process 中使用 find -exec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 11:21
查看更多