Skip to content

Commit

Permalink
macOS: Check for macOS 10.10 using kCFCoreFoundationVersionNumber ins…
Browse files Browse the repository at this point in the history
…tead of AppKit (libusb#611)

Effectivelty removes the dependency on AppKit for HIDAPI.

Fixes: libusb#587
  • Loading branch information
mrpippy committed Aug 27, 2023
1 parent 8a4de63 commit 4009466
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ case $host in
backend="mac"
os="darwin"
threads="pthreads"
LIBS="${LIBS} -framework IOKit -framework CoreFoundation -framework AppKit"
LIBS="${LIBS} -framework IOKit -framework CoreFoundation"
;;
*-freebsd*)
AC_MSG_RESULT([ (FreeBSD back-end)])
Expand Down
2 changes: 1 addition & 1 deletion dist/hidapi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Pod::Spec.new do |spec|

spec.public_header_files = "hidapi/hidapi.h", "mac/hidapi_darwin.h"

spec.frameworks = "IOKit", "CoreFoundation", "AppKit"
spec.frameworks = "IOKit", "CoreFoundation"

end
2 changes: 1 addition & 1 deletion mac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ find_package(Threads REQUIRED)
target_link_libraries(hidapi_darwin
PUBLIC hidapi_include
PRIVATE Threads::Threads
PRIVATE "-framework IOKit" "-framework CoreFoundation" "-framework AppKit"
PRIVATE "-framework IOKit" "-framework CoreFoundation"
)

set_target_properties(hidapi_darwin
Expand Down
2 changes: 1 addition & 1 deletion mac/Makefile-manual
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CC=gcc
COBJS=hid.o ../hidtest/test.o
OBJS=$(COBJS)
CFLAGS+=-I../hidapi -I. -Wall -g -c
LIBS=-framework IOKit -framework CoreFoundation -framework AppKit
LIBS=-framework IOKit -framework CoreFoundation


hidtest: $(OBJS)
Expand Down
5 changes: 1 addition & 4 deletions mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@

#include "hidapi_darwin.h"

/* As defined in AppKit.h, but we don't need the entire AppKit for a single constant. */
extern const double NSAppKitVersionNumber;

/* Barrier implementation because Mac OSX doesn't have pthread_barrier.
It also doesn't have clock_gettime(). So much for POSIX and SUSv2.
This implementation came from Brent Priddy and was posted on
Expand Down Expand Up @@ -466,7 +463,7 @@ int HID_API_EXPORT hid_init(void)
register_global_error(NULL);

if (!hid_mgr) {
is_macos_10_10_or_greater = (NSAppKitVersionNumber >= 1343); /* NSAppKitVersionNumber10_10 */
is_macos_10_10_or_greater = (kCFCoreFoundationVersionNumber >= 1151.16); /* kCFCoreFoundationVersionNumber10_10 */
hid_darwin_set_open_exclusive(1); /* Backward compatibility */
return init_hid_manager();
}
Expand Down

0 comments on commit 4009466

Please sign in to comment.