如何使用CMake添加额外的plist属性? [英] How to add an extra plist property using CMake?

查看:193
本文介绍了如何使用CMake添加额外的plist属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加商品

<key>UIStatusBarHidden</key><true/>

到我的由CMake自动生成的plist中.对于某些键,似乎有预定义的添加项的方法;例如:

to my plist that's auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; for example:

set(MACOSX_BUNDLE_ICON_FILE ${ICON})

但是我找不到添加任意属性的方法.

But I can't find a way to add an arbitrary property.

我尝试使用MACOSX_BUNDLE_INFO_PLIST目标属性,如下所示:我希望生成的plist与旧的plist相同,除了我想要的新属性外,因此我只复制了自动生成的plist并将其设置为作为我的模板.但是plist使用了一些Xcode变量,它们看起来也像${foo},并且CMake对此抱怨:

I tried using the MACOSX_BUNDLE_INFO_PLIST target property as follows: I'd like the resulting plist to be identical to the old one, except with the new property I want, so I just copied the auto-generated plist and set that as my template. But the plist uses some Xcode variables, which also look like ${foo}, and CMake grumbles about this:

cmake代码中的语法错误 解析字符串

Syntax error in cmake code when parsing string

  <string>com.bedaire.${PRODUCT_NAME:identifier}</string>

语法错误,意外的cal_SYMBOL, 期待}(47)

syntax error, unexpected cal_SYMBOL, expecting } (47)

未设置策略CMP0010:错误 变量引用语法是错误的. 运行"cmake --help-policy CMP0010" 有关政策的详细信息.使用 cmake_policy命令设置 采取政策并禁止此警告.这 警告是针对项目开发人员的. 使用-Wno-dev抑制它.

Policy CMP0010 is not set: Bad variable reference syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it.

无论如何,我什至不确定这是正确的做法.我找不到一个很好的例子或任何有关此的很好的文档.理想情况下,我只是让CMake像以前一样生成所有内容,并只添加一条额外的行.我该怎么办?

In any case, I'm not even sure that this is the right thing to do. I can't find a good example or any good documentation about this. Ideally, I'd just let CMake generate everything as before, and just add a single extra line. What can I do?

推荐答案

您是否考虑过将相关的*.plist.in文件复制到/opt/local/share/cmake-2.8/Modules(例如MacOSXBundleInfo.plist.in)中,对其进行编辑以放入<key>UIStatusBarHidden</key><true/>(或@VAR_TO_REPLACE_BY_CMAKE@),然后将已编辑版本的目录添加到CMAKE_MODULE_PATH?

Have you looked into copying the relevant *.plist.in file in /opt/local/share/cmake-2.8/Modules (such as MacOSXBundleInfo.plist.in), editing it to put <key>UIStatusBarHidden</key><true/> (or @VAR_TO_REPLACE_BY_CMAKE@), and adding the directory of the edited version in the CMAKE_MODULE_PATH?

如果您已将CMake作为应用程序捆绑包安装,则该文件的位置为/Applications/CMake.app/Contents/share/cmake-N.N/Modules

If you have CMake installed as an app bundle, then the location of that file is /Applications/CMake.app/Contents/share/cmake-N.N/Modules

这篇关于如何使用CMake添加额外的plist属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆