Updated Objective-C implementation to use ARC; removed i386 support
This commit is contained in:
parent
ac28902b57
commit
0d47056132
@ -40,7 +40,7 @@ sfml_set_option(SFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentatio
|
||||
if(SFML_OS_MACOSX)
|
||||
# add an option to build frameworks instead of dylibs (release only)
|
||||
sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
||||
|
||||
|
||||
# add an option to let the user specify a custom directory for frameworks installation (SFML, sndfile, ...)
|
||||
sfml_set_option(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" STRING "Frameworks installation directory")
|
||||
|
||||
@ -101,6 +101,12 @@ if(SFML_OS_MACOSX)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Objective-C ARC requires a 64 bit runtime.
|
||||
if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
|
||||
message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES should be 'x86_64' to support ARC")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
@ -161,7 +167,7 @@ else()
|
||||
add_library(SFML ${SFML_SOURCES})
|
||||
|
||||
# edit target properties
|
||||
set_target_properties(SFML PROPERTIES
|
||||
set_target_properties(SFML PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.SFML
|
||||
@ -170,14 +176,14 @@ else()
|
||||
PUBLIC_HEADER "${SFML_HEADERS}")
|
||||
|
||||
# add the remaining headers
|
||||
add_custom_command(TARGET SFML
|
||||
add_custom_command(TARGET SFML
|
||||
POST_BUILD
|
||||
COMMAND cp -r ${PROJECT_SOURCE_DIR}/include/SFML/* SFML.framework/Versions/${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}/Headers)
|
||||
|
||||
# adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
|
||||
# NOTE : it's not required to link agains SFML.framework
|
||||
set_target_properties(SFML PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
set_target_properties(SFML PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
INSTALL_NAME_DIR "@executable_path/../Frameworks")
|
||||
|
||||
# install rule
|
||||
|
@ -61,6 +61,11 @@ macro(sfml_add_library target)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# On OS X, use Objective-C ARC
|
||||
if(SFML_OS_MACOSX)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
@ -70,17 +75,17 @@ macro(sfml_add_library target)
|
||||
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS)
|
||||
if(SFML_BUILD_FRAMEWORKS)
|
||||
# adapt target to build frameworks instead of dylibs
|
||||
set_target_properties(${target} PROPERTIES
|
||||
set_target_properties(${target} PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
|
||||
# adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
|
||||
set_target_properties(${target} PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
set_target_properties(${target} PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
INSTALL_NAME_DIR "@executable_path/../Frameworks")
|
||||
endif()
|
||||
|
||||
@ -92,7 +97,7 @@ macro(sfml_add_library target)
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
|
||||
|
||||
|
@ -114,8 +114,6 @@ elseif(SFML_OS_MACOSX)
|
||||
${SRCROOT}/OSX/WindowImplCocoa.hpp
|
||||
${SRCROOT}/OSX/WindowImplCocoa.mm
|
||||
${SRCROOT}/OSX/WindowImplDelegateProtocol.h
|
||||
${SRCROOT}/OSX/AutoreleasePoolWrapper.h
|
||||
${SRCROOT}/OSX/AutoreleasePoolWrapper.mm
|
||||
)
|
||||
source_group("mac" FILES ${PLATFORM_SRC})
|
||||
endif()
|
||||
|
@ -57,7 +57,7 @@ namespace priv
|
||||
////////////////////////////////////////////////////////////
|
||||
SFOpenGLView* getSFOpenGLViewFromSFMLWindow(const Window& window)
|
||||
{
|
||||
id nsHandle = (id)window.getSystemHandle();
|
||||
id nsHandle = (__bridge id)window.getSystemHandle();
|
||||
|
||||
// Get our SFOpenGLView from ...
|
||||
SFOpenGLView* view = nil;
|
||||
|
@ -63,17 +63,17 @@
|
||||
|
||||
// Application Menu (aka Apple Menu)
|
||||
NSMenuItem* appleItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
NSMenu* appleMenu = [[SFApplication createAppleMenu] autorelease];
|
||||
NSMenu* appleMenu = [SFApplication createAppleMenu];
|
||||
[appleItem setSubmenu:appleMenu];
|
||||
|
||||
// File Menu
|
||||
NSMenuItem* fileItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
NSMenu* fileMenu = [[SFApplication createFileMenu] autorelease];
|
||||
NSMenu* fileMenu = [SFApplication createFileMenu];
|
||||
[fileItem setSubmenu:fileMenu];
|
||||
|
||||
// Window menu
|
||||
NSMenuItem* windowItem = [mainMenu addItemWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
NSMenu* windowMenu = [[SFApplication createWindowMenu] autorelease];
|
||||
NSMenu* windowMenu = [SFApplication createWindowMenu];
|
||||
[windowItem setSubmenu:windowMenu];
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
}
|
||||
@ -120,7 +120,7 @@
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
// SERVICES
|
||||
NSMenu* serviceMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
|
||||
NSMenu* serviceMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
NSMenuItem* serviceItem = [appleMenu addItemWithTitle:@"Services"
|
||||
action:nil
|
||||
keyEquivalent:@""];
|
||||
@ -174,7 +174,6 @@
|
||||
action:@selector(performClose:)
|
||||
keyEquivalent:@"w"];
|
||||
[fileMenu addItem:closeItem];
|
||||
[closeItem release];
|
||||
|
||||
return fileMenu;
|
||||
}
|
||||
@ -199,7 +198,6 @@
|
||||
action:@selector(performMiniaturize:)
|
||||
keyEquivalent:@"m"];
|
||||
[windowMenu addItem:minimizeItem];
|
||||
[minimizeItem release];
|
||||
|
||||
// ZOOM
|
||||
[windowMenu addItemWithTitle:@"Zoom"
|
||||
|
@ -30,8 +30,6 @@
|
||||
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
@ -43,9 +41,6 @@ SFContext::SFContext(SFContext* shared) :
|
||||
m_view(0),
|
||||
m_window(0)
|
||||
{
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Create the context
|
||||
createContext(shared,
|
||||
VideoMode::getDesktopMode().bitsPerPixel,
|
||||
@ -59,9 +54,6 @@ SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
||||
m_view(0),
|
||||
m_window(0)
|
||||
{
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Create the context.
|
||||
createContext(shared, bitsPerPixel, settings);
|
||||
|
||||
@ -80,9 +72,6 @@ m_window(0)
|
||||
// Ensure the process is setup in order to create a valid window.
|
||||
WindowImplCocoa::setUpProcess();
|
||||
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Create the context.
|
||||
createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
|
||||
|
||||
@ -102,12 +91,6 @@ m_window(0)
|
||||
SFContext::~SFContext()
|
||||
{
|
||||
[m_context clearDrawable];
|
||||
[m_context release];
|
||||
|
||||
[m_view release]; // Might be nil but we don't care.
|
||||
[m_window release]; // Idem.
|
||||
|
||||
releasePool();
|
||||
}
|
||||
|
||||
|
||||
@ -210,9 +193,6 @@ void SFContext::createContext(SFContext* shared,
|
||||
if (m_context == nil)
|
||||
sf::err() << "Error. Unable to create the context." << std::endl;
|
||||
|
||||
// Free up.
|
||||
[pixFmt release];
|
||||
|
||||
// Save the settings. (OpenGL version is updated elsewhere.)
|
||||
m_settings = settings;
|
||||
}
|
||||
|
@ -292,14 +292,7 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
// Unregister
|
||||
[self removeTrackingArea:m_trackingArea];
|
||||
|
||||
// Release attributes
|
||||
[m_hiddenTextView release];
|
||||
[m_silentResponder release];
|
||||
[m_trackingArea release];
|
||||
|
||||
[self setRequesterTo:0];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
m_requester = 0;
|
||||
|
||||
// Retain the view for our own use.
|
||||
m_view = [view retain];
|
||||
m_view = view;
|
||||
|
||||
if (m_view == nil)
|
||||
{
|
||||
@ -81,11 +81,6 @@
|
||||
-(void)dealloc
|
||||
{
|
||||
[self closeWindow];
|
||||
|
||||
[m_view release];
|
||||
[m_oglView release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +96,7 @@
|
||||
////////////////////////////////////////////////////////
|
||||
-(sf::WindowHandle)getSystemHandle
|
||||
{
|
||||
return m_view;
|
||||
return (__bridge sf::WindowHandle)m_view;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
||||
m_fullscreenMode = new sf::VideoMode();
|
||||
|
||||
// Retain the window for our own use.
|
||||
m_window = [window retain];
|
||||
m_window = window;
|
||||
|
||||
if (m_window == nil)
|
||||
{
|
||||
@ -254,12 +254,7 @@
|
||||
[self closeWindow];
|
||||
[NSMenu setMenuBarVisible:YES];
|
||||
|
||||
[m_window release];
|
||||
[m_oglView release];
|
||||
|
||||
delete m_fullscreenMode;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@ -279,7 +274,7 @@
|
||||
////////////////////////////////////////////////////////
|
||||
-(sf::WindowHandle)getSystemHandle
|
||||
{
|
||||
return m_window;
|
||||
return (__bridge sf::WindowHandle)m_window;
|
||||
}
|
||||
|
||||
|
||||
@ -446,10 +441,6 @@
|
||||
|
||||
// Set app icon.
|
||||
[[SFApplication sharedApplication] setApplicationIconImage:icon];
|
||||
|
||||
// Free up.
|
||||
[icon release];
|
||||
[bitmap release];
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <SFML/System/String.hpp>
|
||||
|
||||
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
|
||||
#import <SFML/Window/OSX/cpp_objc_conversion.h>
|
||||
#import <SFML/Window/OSX/SFApplication.h>
|
||||
#import <SFML/Window/OSX/SFApplicationDelegate.h>
|
||||
@ -50,11 +49,8 @@ namespace priv
|
||||
WindowImplCocoa::WindowImplCocoa(WindowHandle handle) :
|
||||
m_showCursor(true)
|
||||
{
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
// Treat the handle as it real type
|
||||
id nsHandle = (id)handle;
|
||||
id nsHandle = (__bridge id)handle;
|
||||
if ([nsHandle isKindOfClass:[NSWindow class]])
|
||||
{
|
||||
// We have a window.
|
||||
@ -95,9 +91,6 @@ m_showCursor(true)
|
||||
// Transform the app process.
|
||||
setUpProcess();
|
||||
|
||||
// Ask for a pool.
|
||||
retainPool();
|
||||
|
||||
m_delegate = [[SFWindowController alloc] initWithMode:mode andStyle:style];
|
||||
[m_delegate changeTitle:sfStringToNSString(title)];
|
||||
[m_delegate setRequesterTo:this];
|
||||
@ -112,18 +105,10 @@ WindowImplCocoa::~WindowImplCocoa()
|
||||
{
|
||||
[m_delegate closeWindow];
|
||||
|
||||
[m_delegate release];
|
||||
|
||||
// Put the next window in front, if any.
|
||||
NSArray* windows = [NSApp orderedWindows];
|
||||
if ([windows count] > 0)
|
||||
[[windows objectAtIndex:0] makeKeyAndOrderFront:nil];
|
||||
|
||||
releasePool();
|
||||
|
||||
drainPool(); // Make sure everything was freed
|
||||
// This solve some issue when sf::Window::Create is called for the
|
||||
// second time (nothing was render until the function was called again)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user