xcode 在 MAC OSX 上使用 CMake 生成 .bundle 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15120951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Generating a .bundle file with CMake on MAC OSX
提问by Korchkidu
I want to generate an executable in a .bundle
file on Mac OSX 10.6.8
using CMake
. My CMakeLists.txt file looks like:
我想.bundle
在Mac OSX 10.6.8
使用CMake
. 我的 CMakeLists.txt 文件如下所示:
cmake_minimum_required(VERSION 2.8)
PROJECT(TESTProject)
SET(MACOSX_BUNDLE_BUNDLE_NAME TEST)
ADD_EXECUTABLE(TEST MACOSX_BUNDLE main.cpp)
SET_TARGET_PROPERTIES(TEST PROPERTIES MACOSX_BUNDLE TRUE)
Then I call CMake:
然后我打电话给 CMake:
CMake -G"Xcode" .
However, when I compile this program with Xcode 3.2.1
, I constantly get a TEST.app
file instead of a TEST.bundle
file.
但是,当我用 编译这个程序时Xcode 3.2.1
,我经常得到一个TEST.app
文件而不是一个TEST.bundle
文件。
What am I doing wrong here?
我在这里做错了什么?
采纳答案by DLRdave
Use the BUNDLE_EXTENSION target property to get a different extension than the default. http://www.cmake.org/cmake/help/v2.8.10/cmake.html#prop_tgt:BUNDLE_EXTENSION
使用 BUNDLE_EXTENSION 目标属性获取与默认值不同的扩展名。http://www.cmake.org/cmake/help/v2.8.10/cmake.html#prop_tgt:BUNDLE_EXTENSION
Also, I think .app is only the default for executable targets. For library or module targets, .bundle should be the default value.
另外,我认为 .app 只是可执行目标的默认值。对于库或模块目标,.bundle 应该是默认值。
Did you try with a library target?
您是否尝试使用库目标?
回答by Chris
For anyone who runs across this and is trying to build a library .bundle, this worked for me on CMake 3.0:
对于遇到此问题并试图构建库 .bundle 的任何人,这在 CMake 3.0 上对我有用:
add_library(Foo MODULE ${SOURCES} ${HEADERS})
set_target_properties(Foo PROPERTIES BUNDLE TRUE)
The key is to use MODULE
not SHARED
. For some reason, CMake ignores the BUNDLE
property otherwise.
关键是使用MODULE
not SHARED
。出于某种原因,CMakeBUNDLE
否则会忽略该属性。