oc-cmake
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
@interface AppDel : NSObject<NSApplicationDelegate>
@end
@implementation AppDel
-(void) applicationDidFinishLaunching:(NSNotification *)notification
{
NSRect rect = NSMakeRect(35, 35, 1024, 800);
NSWindowStyleMask style = NSWindowStyleMaskClosable | NSWindowStyleMaskTitled | NSWindowStyleMaskResizable;
NSWindow* window = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO];
[NSApp beginModalSessionForWindow:window];
}
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return TRUE;
}
@end
int main(int argc, const char ** argv)
{
@autoreleasepool {
AppDel * del = [[AppDel alloc] init];
[[NSApplication sharedApplication] setDelegate: del];
NSApplicationMain(argc, argv);
}
}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSPrincipalClass</key> <string>NSApplication</string> <key>BuildMachineOSBuild</key> <string>17G14019</string> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>ObjectStudy</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleLongVersionString</key> <string></string> <key>CFBundleName</key> <string>ObjectStudy</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleSupportedPlatforms</key> <array> <string>MacOSX</string> </array> <key>CFBundleVersion</key> <string></string> <key>CSResourcesFileMapped</key> <true/> <key>DTCompiler</key> <string>com.apple.compilers.llvm.clang.1_0</string> <key>DTPlatformBuild</key> <string>10B61</string> <key>DTPlatformVersion</key> <string>GM</string> <key>DTSDKBuild</key> <string>18B71</string> <key>DTSDKName</key> <string>macosx10.14</string> <key>DTXcode</key> <string>1010</string> <key>DTXcodeBuild</key> <string>10B61</string> <key>NSHumanReadableCopyright</key> <string></string> </dict> </plist>
cmake_minimum_required(VERSION 2.8) set(PRINCIPAL_CLASS "NSApplication") project(ObjectStudy) set(SRC main.m Info.plist ) set(CMAKE_C_FLAGS "-x objective-c") set(CMAKE_CXX_FLAGS "-x objective-c++") set(CMAKE_EXE_LINKER_FLAGS "-framework Cocoa -framework AppKit -framework CoreData -framework Foundation") add_executable(ObjectStudy ${SRC} ) set_target_properties(ObjectStudy PROPERTIES MACOSX_BUNDLE TRUE # PRINCIPAL_CLASS "" #MACOSX_BUNDLE_BUNDLE_NAME "" MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist )