소스 검색

Cocoa: Add QuartzCore as a link-time dependency

Camilla Löwy 1 년 전
부모
커밋
97892c6037
4개의 변경된 파일10개의 추가작업 그리고 16개의 파일을 삭제
  1. 1 0
      README.md
  2. 3 3
      docs/build.md
  3. 3 2
      src/CMakeLists.txt
  4. 3 11
      src/cocoa_window.m

+ 1 - 0
README.md

@@ -123,6 +123,7 @@ information on what to include when reporting a bug.
 
  - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
    the limit of the mouse button tokens to be reported (#2423)
+ - [Cocoa] Added `QuartzCore` framework as link-time dependency
  - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
  - [Wayland] Bugfix: The fractional scaling related objects were not destroyed
  - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517)

+ 3 - 3
docs/build.md

@@ -390,8 +390,8 @@ If you are using the dynamic library version of GLFW, add it to the project
 dependencies.
 
 If you are using the static library version of GLFW, add it and the Cocoa,
-OpenGL and IOKit frameworks to the project as dependencies.  They can all be
-found in `/System/Library/Frameworks`.
+OpenGL, IOKit and QuartzCore frameworks to the project as dependencies.  They
+can all be found in `/System/Library/Frameworks`.
 
 
 ### With command-line or makefile on macOS {#build_link_osx}
@@ -405,7 +405,7 @@ command-line yourself using the `-l` and `-framework` switches.
 If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:
 
 ```sh
-cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit
+cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework QuartzCore
 ```
 
 If you are using the static library, named `libglfw3.a`, substitute `-lglfw3`

+ 3 - 2
src/CMakeLists.txt

@@ -151,10 +151,11 @@ endif()
 if (GLFW_BUILD_COCOA)
     target_link_libraries(glfw PRIVATE "-framework Cocoa"
                                        "-framework IOKit"
-                                       "-framework CoreFoundation")
+                                       "-framework CoreFoundation"
+                                       "-framework QuartzCore")
 
     set(glfw_PKG_DEPS "")
-    set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
+    set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework QuartzCore")
 endif()
 
 if (GLFW_BUILD_WAYLAND)

+ 3 - 11
src/cocoa_window.m

@@ -28,6 +28,8 @@
 
 #if defined(_GLFW_COCOA)
 
+#import <QuartzCore/CAMetalLayer.h>
+
 #include <float.h>
 #include <string.h>
 #include <assert.h>
@@ -1948,18 +1950,8 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
 {
     @autoreleasepool {
 
-    // HACK: Dynamically load Core Animation to avoid adding an extra
-    //       dependency for the majority who don't use MoltenVK
-    NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
-    if (!bundle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to find QuartzCore.framework");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
     // NOTE: Create the layer here as makeBackingLayer should not return nil
-    window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
+    window->ns.layer = [CAMetalLayer layer];
     if (!window->ns.layer)
     {
         _glfwInputError(GLFW_PLATFORM_ERROR,