Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a .bundle file with CMake on MAC OSX

Tags:

xcode

macos

cmake

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?

like image 805
Korchkidu Avatar asked Feb 27 '13 19:02

Korchkidu


2 Answers

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.

like image 89
Chris Avatar answered Sep 17 '22 13:09

Chris


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?

like image 38
DLRdave Avatar answered Sep 20 '22 13:09

DLRdave