Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile on some non-Windows targets #26

Open
steven807 opened this issue May 8, 2018 · 4 comments
Open

Can't compile on some non-Windows targets #26

steven807 opened this issue May 8, 2018 · 4 comments

Comments

@steven807
Copy link

A change to compile on Windows broke non-Windows builds (at least on my mac). This change isn't portable to Windows, so I'm not submitting it as a pull request, but I had to make the following changes to build on MacOS (High Sierra):

git diff CMakeLists.txt  | cat
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 762f2b6..e3fafe7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,11 +24,12 @@ if(WIN32)
   find_library(LIBUSB_LIBRARIES usb-1.0
   PATHS /opt/local/lib)

-  find_path(LIBUSB_INCLUDE_DIR libusb-1.0/libusb.h
+  find_path(LIBUSB_INCLUDEDIR libusb-1.0/libusb.h
   PATHS /opt/local/include)
 else()
   find_package(PkgConfig)
   pkg_check_modules(LIBUSB libusb-1.0)
+  find_library(LIBUSB usb-1.0)
 endif()


@@ -54,7 +55,7 @@ SET(SOURCES src/ctrl.c src/ctrl-gen.c src/device.c src/diag.c
 include_directories(
   ${libuvc_SOURCE_DIR}/include
   ${libuvc_BINARY_DIR}/include
-  ${LIBUSB_INCLUDE_DIR}
+  ${LIBUSB_INCLUDEDIR}
   ${PTHREAD_INCLUDE_DIR}
 )

@@ -92,7 +93,7 @@ foreach(target_name ${UVC_TARGETS})
 endforeach()

 if(BUILD_UVC_SHARED)
-  target_link_libraries(uvc ${LIBUSB_LIBRARIES} ${PTHREAD_LIBRARIES})
+  target_link_libraries(uvc ${LIBUSB} ${PTHREAD_LIBRARIES})

   #add_executable(test src/test.c)
   #target_link_libraries(test uvc ${LIBUSB_LIBRARIES} opencv_highgui
@mcuee
Copy link

mcuee commented Jul 10, 2018

The CMake file here works for Windows (tested with MS Visual C++ x86 build) but it does not seem to be very good for other system. I am not a CMake expert but maybe the following can be a reference.
http://developer.intra2net.com/git/?p=libftdi;a=blob;f=cmake/FindUSB1.cmake

@burknator
Copy link

Thanks a ton @steven807, couldn't have fixed it without you! I'm on a mac too.

@onc
Copy link

onc commented Nov 23, 2018

Could reproduce the issue and fix it using the patch suggested by @steven807 on Mojave.

@algrant
Copy link

algrant commented Dec 17, 2020

this still works on Catalina! thanks @steven807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants