summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CheckConstantExists.cmake38
-rw-r--r--Modules/FindUSB.cmake2
-rw-r--r--usbmuxd/CMakeLists.txt21
-rw-r--r--usbmuxd/usb-linux.c11
4 files changed, 59 insertions, 13 deletions
diff --git a/Modules/CheckConstantExists.cmake b/Modules/CheckConstantExists.cmake
new file mode 100644
index 0000000..3d6d97e
--- /dev/null
+++ b/Modules/CheckConstantExists.cmake
@@ -0,0 +1,38 @@
+# - Check if the given constant exists (as an enum, define, or whatever)
+# CHECK_CONSTANT_EXISTS (CONSTANT HEADER VARIABLE)
+#
+# CONSTANT - the name of the constant you are interested in
+# HEADER - the header(s) where the prototype should be declared
+# VARIABLE - variable to store the result
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+# CMAKE_REQUIRED_FLAGS = string of compile command line flags
+# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+# CMAKE_REQUIRED_INCLUDES = list of include directories
+#
+# Example: CHECK_CONSTANT_EXISTS(O_NOFOLLOW fcntl.h HAVE_O_NOFOLLOW)
+
+
+INCLUDE(CheckCSourceCompiles)
+
+MACRO (CHECK_CONSTANT_EXISTS _CONSTANT _HEADER _RESULT)
+ SET(_INCLUDE_FILES)
+ FOREACH (it ${_HEADER})
+ SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
+ ENDFOREACH (it)
+
+ SET(_CHECK_CONSTANT_SOURCE_CODE "
+${_INCLUDE_FILES}
+void cmakeRequireConstant(int dummy,...){(void)dummy;}
+int main()
+{
+ cmakeRequireConstant(0,${_CONSTANT});
+ return 0;
+}
+")
+ CHECK_C_SOURCE_COMPILES("${_CHECK_CONSTANT_SOURCE_CODE}" ${_RESULT})
+
+ENDMACRO (CHECK_CONSTANT_EXISTS)
+
diff --git a/Modules/FindUSB.cmake b/Modules/FindUSB.cmake
index d562b98..8659ec2 100644
--- a/Modules/FindUSB.cmake
+++ b/Modules/FindUSB.cmake
@@ -10,7 +10,7 @@ include(LibFindMacros)
# Dependencies
# Use pkg-config to get hints about paths
-libfind_pkg_check_modules(USB_PKGCONF libusb-1.0)
+libfind_pkg_check_modules(USB_PKGCONF libusb-1.0>=1.0.2)
# Include dir
find_path(USB_INCLUDE_DIR
diff --git a/usbmuxd/CMakeLists.txt b/usbmuxd/CMakeLists.txt
index 7d0d3d8..f95727c 100644
--- a/usbmuxd/CMakeLists.txt
+++ b/usbmuxd/CMakeLists.txt
@@ -6,8 +6,27 @@ include_directories (${CMAKE_SOURCE_DIR}/common)
include_directories (${CMAKE_SOURCE_DIR}/usbmuxd)
include_directories (${CMAKE_SOURCE_DIR}/libusbmuxd)
+include(CheckConstantExists)
+set(CMAKE_REQUIRED_INCLUDES ${USB_INCLUDE_DIRS})
+check_constant_exists(LIBUSB_TRANSFER_ZERO_PACKET libusb.h HAVE_LIBUSB_ZLP)
+
+if(NOT HAVE_LIBUSB_ZLP)
+ message("
+================================================================================
+==================================== WARNING ===================================
+================================================================================
+Your libusb is missing proper Zero Length Packet support! If you are using a
+recent libusb Git, things may or may not work. If you are using libusb 1.0.2 or
+earlier, things will definitely not work properly.
+
+Please apply the patch in the contrib/ directory to your libusb 1.0 tree.
+================================================================================
+")
+ add_definitions(-DEXPLICIT_ZLP_TRANSACTION)
+endif(NOT HAVE_LIBUSB_ZLP)
+
add_definitions(-Wall -O2 -g -DUSBMUXD_DAEMON)
add_executable(usbmuxd main.c usb-linux.c log.c ../common/utils.c device.c client.c)
target_link_libraries(usbmuxd ${LIBS})
-install(TARGETS usbmuxd RUNTIME DESTINATION sbin) \ No newline at end of file
+install(TARGETS usbmuxd RUNTIME DESTINATION sbin)
diff --git a/usbmuxd/usb-linux.c b/usbmuxd/usb-linux.c
index 2d6053e..c09cdc9 100644
--- a/usbmuxd/usb-linux.c
+++ b/usbmuxd/usb-linux.c
@@ -33,17 +33,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "log.h"
#include "device.h"
-#ifndef LIBUSB_TRANSFER_ZERO_PACKET
-#warning Your libusb is missing proper Zero Length Packet support!
-#warning
-#warning If you are using a recent libusb Git, things may or may not work.
-#warning If you are using libusb 1.0.2 or earlier, things will definitely not work
-#warning properly.
-#warning
-#warning Please apply the patch in the contrib/ directory to your libusb 1.0 tree.
-#define EXPLICIT_ZLP_TRANSACTION
-#endif
-
// interval for device connection/disconnection polling, in milliseconds
// we need this because there is currently no asynchronous device discovery mechanism in libusb
#define DEVICE_POLL_TIME 1000