Korchkidu
Korchkidu

Reputation: 4946

Generating a .bundle file with CMake on MAC OSX

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

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 -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.

What am I doing wrong here?

Upvotes: 8

Views: 10606

Answers (2)

Chris
Chris

Reputation: 141

For anyone who runs across this and is trying to build a library .bundle, this worked for me on 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.

Upvotes: 11

DLRdave
DLRdave

Reputation: 14280

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

Also, I think .app is only the default for executable targets. For library or module targets, .bundle should be the default value.

Did you try with a library target?

Upvotes: 8

Related Questions