forked from rpavlik/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckMacHIDAPI.cmake
73 lines (66 loc) · 2.22 KB
/
CheckMacHIDAPI.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# - Script to check if the signature for a mac HID callback uses UInt32 or uint32_t
# Requires that the associated CPP file be present: CheckMacHIDAPI.cpp.
#
# MACOSX_HID_UINT32T, set according to the results of our test.
#
# Use add_definitions(-DMACOSX_HID_UINT32T=${MACOSX_HID_UINT32T}) in your
# listfile and the following prototype for the function you'd like to
# register using setInterruptReportHandlerCallback:
# void ReaderReportCallback(
# void *target,
# IOReturn result,
# void *refcon,
# void *sender,
# MACOSX_HID_UINT32T size
# )
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(APPLE)
if(NOT MACOSX_HID_UINT32T)
get_filename_component(_moddir ${CMAKE_CURRENT_LIST_FILE} PATH)
try_compile(_HID_uint32t
${CMAKE_BINARY_DIR}
${_moddir}/CheckMacHIDAPI.cpp
OUTPUT_VARIABLE
_HID_uint32t_OUTPUT
COMPILE_DEFINITIONS
-DMACOSX_HID_UINT32T=uint32_t)
message(STATUS
"Checking uint32_t in HID callback signature... ${_HID_uint32t}")
try_compile(_HID_UInt32
${CMAKE_BINARY_DIR}
${_moddir}/CheckMacHIDAPI.cpp
OUTPUT_VARIABLE
_HID_UInt32_OUTPUT
COMPILE_DEFINITIONS
-DMACOSX_HID_UINT32T=UInt32)
message(STATUS
"Checking UInt32 in HID callback signature... ${_HID_UInt32}")
if(_HID_uint32t)
set(MACOSX_HID_UINT32T
"uint32_t"
CACHE
STRING
"The 32-bit uint type desired in the callback set by setInterruptReportHandlerCallback")
mark_as_advanced(MACOSX_HID_UINT32T)
elseif(_HID_UInt32)
set(MACOSX_HID_UINT32T
"UInt32"
CACHE
STRING
"The 32-bit uint type desired in the callback set by setInterruptReportHandlerCallback")
mark_as_advanced(MACOSX_HID_UINT32T)
else()
message(SEND_ERROR
"ERROR: Could not detect appropriate Mac HID uint32 type!")
endif()
endif()
endif()