build: added script for creating MacOSX app bundle

This change makes it possible to create a MacOSX app bundle of either Debug or Release builds:
* The script setup/MacOSX/bundle_install.sh is configured by cmake to be placed in the apps Debug and Release folders.
* Execution of bundle_install.sh creates the bundle file structure and copies binaries, libs, frameworks and resources
into it.
* The script uses install_name_tool to reconfigure the dynamic library paths and framework paths of the binary, so they
won't point to the system libraries, but to the locations in the bundle instead.
* An Info.plist file is also configured by cmake and placed in the bundle by the script. Note: It is named
bundle_info.plist in the Debug and Release folders after configuration so the start of the binary during developement
does not use it.
* When opening the bundle it is assured via setup() in src/app/platform_includes/includesMac.h that the working
directory of the binary is set to .app/Contents/Resources so the paths to the data files are evaluated correctly.

fortune cookie message = Dein Einsatz wird in Kürze belohnt werden.
This commit is contained in:
Eberhard Graether
2014-07-16 13:53:34 +02:00
parent 886171cb2a
commit 40ca86a172
10 changed files with 229 additions and 18 deletions
+4 -1
View File
@@ -1,6 +1,10 @@
add_files(
APP_FILES
platform_includes/includesDefault.h
platform_includes/includesMac.h
platform_includes/includesWindows.h
qt/element/QtCodeFile.cpp
qt/element/QtCodeFile.h
qt/element/QtButton.cpp
@@ -39,6 +43,5 @@ add_files(
qt/QtWidgetWrapper.cpp
qt/QtWidgetWrapper.h
includesWindows.h
main.cpp
)
-7
View File
@@ -1,7 +0,0 @@
#ifndef INCLUDES_H
#define INCLUDES_H
// platform specific includes
@PLATFORM_INCLUDES@
#endif // INCLUDES_H
+3 -1
View File
@@ -3,12 +3,14 @@
#include <QApplication>
#include "Application.h"
#include "includes.h"
#include "includes.h" // defines 'void setup()'
#include "qt/QtGuiFactory.h"
#include "qt/utility/utilityQt.h"
int main(int argc, char *argv[])
{
setup();
QApplication qtApp(argc, argv);
QtGuiFactory guiFactory;
+9
View File
@@ -0,0 +1,9 @@
#ifndef INCLUDES_H
#define INCLUDES_H
void setup();
// platform specific include
#include "platform_includes/@PLATFORM_INCLUDE@"
#endif // INCLUDES_H
@@ -0,0 +1,8 @@
#ifndef INCLUDES_DEFAULT_H
#define INCLUDES_DEFAULT_H
void setup()
{
}
#endif // INCLUDES_DEFAULT_H
+34
View File
@@ -0,0 +1,34 @@
#ifndef INCLUDES_MAC_H
#define INCLUDES_MAC_H
#include <CoreFoundation/CoreFoundation.h>
void setup()
{
// ----------------------------------------------------------------------------
// This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle
// source: http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
CFBundleRef mainBundle = CFBundleGetMainBundle();
if (!mainBundle)
{
return;
}
CFStringRef bundleIdentifier = CFBundleGetIdentifier(mainBundle);
// std::cout << CFStringGetCStringPtr(id, kCFStringEncodingASCII) << std::endl;
if (!bundleIdentifier)
{
return;
}
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{
chdir(path);
}
CFRelease(resourcesURL);
// ----------------------------------------------------------------------------
}
#endif // INCLUDES_MAC_H
@@ -3,4 +3,8 @@
#include "vld.h"
void setup()
{
}
#endif // INCLUDES_WINDOWS_H