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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:52:22  来源:igfitidea点击:

Generating a .bundle file with CMake on MAC OSX

xcodemacoscmake

提问by Korchkidu

I want to generate an executable in a .bundlefile on Mac OSX 10.6.8using CMake. My CMakeLists.txt file looks like:

我想.bundleMac 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.appfile instead of a TEST.bundlefile.

但是,当我用 编译这个程序时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 MODULEnot SHARED. For some reason, CMake ignores the BUNDLEproperty otherwise.

关键是使用MODULEnot SHARED。出于某种原因,CMakeBUNDLE否则会忽略该属性。