FLTK logo

[master] 70b84b4 - macOS + CMake: fix use of optional framework UniformTypeIdentifiers

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 70b84b4 - macOS + CMake: fix use of optional framework UniformTypeIdentifiers "ManoloFLTK" 06:32 May 03  
 
commit 70b84b491b889ecb528e46aae20b6105e0b96065
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri May 3 15:23:42 2024 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri May 3 15:23:42 2024 +0200

    macOS + CMake: fix use of optional framework UniformTypeIdentifiers

 CMake/setup.cmake                 | 14 +++++++++++++-
 src/Fl_Native_File_Chooser_MAC.mm |  3 ++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git CMake/setup.cmake CMake/setup.cmake
index 3b67084..5419fb7 100644
--- CMake/setup.cmake
+++ CMake/setup.cmake
@@ -123,7 +123,19 @@ if(APPLE)
     endif(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0))
   else()
     set(FLTK_COCOA_FRAMEWORKS "-framework Cocoa")
-    if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 20.0.0)) # a.k.a. macOS version â?¥ 11.0
+    set(UTI_CONDITION FALSE)
+    string(LENGTH "${CMAKE_OSX_DEPLOYMENT_TARGET}" TARGET_LEN)
+    string(LENGTH "${CMAKE_SYSTEM_VERSION}" SDK_LEN)
+    if(TARGET_LEN GREATER 0)
+      if( ${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_GREATER_EQUAL 11.0)
+        set(UTI_CONDITION TRUE)
+      endif()
+    elseif(SDK_LEN GREATER 0)
+      if( ${CMAKE_SYSTEM_VERSION} VERSION_GREATER_EQUAL 20.0 )
+        set(UTI_CONDITION TRUE)
+      endif()
+    endif()
+    if(UTI_CONDITION) # a.k.a. macOS version â?¥ 11.0
       if (NOT (CMAKE_OSX_ARCHITECTURES STREQUAL "ppc" OR CMAKE_OSX_ARCHITECTURES STREQUAL "i386"))
         list(APPEND FLTK_COCOA_FRAMEWORKS "-framework UniformTypeIdentifiers")
       endif()
diff --git src/Fl_Native_File_Chooser_MAC.mm src/Fl_Native_File_Chooser_MAC.mm
index a10aa6c..2317de9 100644
--- src/Fl_Native_File_Chooser_MAC.mm
+++ src/Fl_Native_File_Chooser_MAC.mm
@@ -532,7 +532,8 @@ static char *prepareMacFilter(int count, const char *filter, char **patterns) {
 - (void)control_allowed_types:(const char *)p
 {
   NSString *ext = [NSString stringWithUTF8String:p];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0 && \
+    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
   if (fl_mac_os_version >= 110000) {
     UTType *type = [UTType typeWithFilenameExtension:ext]; // 11.0 + framework UniformTypeIdentifiers
     [dialog setAllowedContentTypes:[NSArray arrayWithObject:type]]; // 11.0
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.