Skip to content

Commit

Permalink
Merge pull request #100 from norberttak/mac-build-fixes
Browse files Browse the repository at this point in the history
Mac build fixes. This PR is created to be able to build the plugin on Mac. The testing of the plugin on Mac is still needs to be done.
  • Loading branch information
norberttak authored Apr 16, 2024
2 parents 90f2c61 + ad3bc05 commit 57cf4a0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion 3rdparty/SDK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ if (WIN32)
)
elseif (APPLE)
target_compile_definitions(xpsdk::xpsdk INTERFACE APL=1 IBM=0 LIN=0)
# TODO link
list(APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Mac")
find_library(XPLM_LIBRARY NAMES XPLM XPLM.framework)
find_library(XPWIDGETS_LIBRARY NAMES XPWidgets XPWidgets.framework)
target_link_libraries(xpsdk::xpsdk
INTERFACE
"-framework AppKit"
"-framework CoreFoundation"
"-framework IOKit"
${XPLM_LIBRARY}
${XPWIDGETS_LIBRARY}
)
elseif (UNIX)
target_compile_definitions(xpsdk::xpsdk INTERFACE APL=0 IBM=0 LIN=1)
endif()
2 changes: 1 addition & 1 deletion 3rdparty/hidapi/mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static struct hid_device_info *create_device_info_with_usage(IOHIDDeviceRef dev,
/* max value of entry_id(uint64_t) is 18446744073709551615 which is 20 characters long,
so for (max) "path" string 'DevSrvsID:18446744073709551615' we would need
9+1+20+1=31 bytes buffer, but allocate 32 for simple alignment */
cur_dev->path = calloc(1, 32);
cur_dev->path = (char *)calloc(1, 32);
if (cur_dev->path != NULL) {
/* Yes, compiler, we know that snprintf is preferable,
but we're not ready to abandon older macOS-es/SDKs where it is not yet available */
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ $ cmake --build build
$ cmake --install build
```

## macOS

Dependencies:
```
brew install lua
brew install pkg-config
```

Copy or link the `/tmp/xpanel-install/XPanel` directory into the X-Plane plugin folder.

## Report bugs
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ add_library(xpanel SHARED

target_include_directories(xpanel PRIVATE ./ core devices config-ui ../3rdparty/hidapi)

if (UNIX)
if (UNIX AND NOT APPLE)
include(FindPkgConfig)
pkg_check_modules(libudev REQUIRED IMPORTED_TARGET libudev)
find_library(HIDAPI_LIBRARY NAMES udev)
Expand Down

0 comments on commit 57cf4a0

Please sign in to comment.