@ -1,10 +1,10 @@
if ( MINGW )
if ( MINGW OR NOT WIN32 )
# T h e M i n G W t o o l c h a i n f o r s o m e r e a s o n d o e s n ' t w o r k w i t h t h i s C M a k e L i s t s f i l e a f t e r u p d a t i n g t o
# G N U t o o l c h a i n s f o r s o m e r e a s o n d o e s n ' t w o r k w i t h t h e l a t e r h a l f o f t h i s C M a k e L i s t s a f t e r
# 1 . 0 . 2 4 , s o w e d o i t t h e o l d - f a s h i o n e d w a y f o r n o w . W e m a y w a n t t o m o v e n a t i v e L i n u x t o o l c h a i n s
# u p d a t i n g t o 1 . 0 . 2 4 , s o w e d o i t t h e o l d - f a s h i o n e d w a y f o r n o w .
# t o h e r e , too ( TODO lat9nq? ) .
set ( LIBUSB_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libusb" )
set ( LIBUSB_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libusb" )
set ( LIBUSB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libusb" )
set ( LIBUSB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libusb" )
# W o r k a r o u n d s f o r M S Y S / M i n G W
# W o r k a r o u n d s f o r M S Y S / M i n G W
if ( MSYS )
if ( MSYS )
# C M a k e o n W i n d o w s p a s s e s ` C : / ` , b u t w e n e e d ` / C / ` o r ` / c / ` t o u s e ` c o n f i g u r e `
# C M a k e o n W i n d o w s p a s s e s ` C : / ` , b u t w e n e e d ` / C / ` o r ` / c / ` t o u s e ` c o n f i g u r e `
@ -19,9 +19,18 @@ if (MINGW)
set ( LIBUSB_CONFIGURE "${LIBUSB_SRC_DIR}/configure" )
set ( LIBUSB_CONFIGURE "${LIBUSB_SRC_DIR}/configure" )
set ( LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile" )
set ( LIBUSB_MAKEFILE "${LIBUSB_PREFIX}/Makefile" )
set ( LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a" )
set ( LIBUSB_SHARED_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll" )
if ( MINGW )
set ( LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.dll" )
set ( LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll.a" )
set ( LIBUSB_SHARED_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.dll" )
set ( LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.dll" )
set ( LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows )
else ( )
set ( LIBUSB_LIBRARY "${LIBUSB_PREFIX}/libusb/.libs/libusb-1.0.so" )
set ( LIBUSB_SHARED_LIBRARY "${LIBUSB_LIBRARY}" )
set ( LIBUSB_SHARED_LIBRARY_DEST "${CMAKE_BINARY_DIR}/bin/libusb-1.0.so" )
endif ( )
# C a u s e s " e x t e r n a l s / l i b u s b / l i b u s b / l i b u s b / o s / w i n d o w s _ w i n u s b . c : 1 4 2 7 : 2 : e r r o r : c o n v e r s i o n t o n o n - s c a l a r t y p e r e q u e s t e d " , s o c a n n o t s t a t i c a l l y l i n k i t f o r n o w .
# C a u s e s " e x t e r n a l s / l i b u s b / l i b u s b / l i b u s b / o s / w i n d o w s _ w i n u s b . c : 1 4 2 7 : 2 : e r r o r : c o n v e r s i o n t o n o n - s c a l a r t y p e r e q u e s t e d " , s o c a n n o t s t a t i c a l l y l i n k i t f o r n o w .
# set ( LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}" )
# set ( LIBUSB_CFLAGS "-DGUID_DEVINTERFACE_USB_DEVICE=\\(GUID\\){0xA5DCBF10,0x6530,0x11D2,{0x90,0x1F,0x00,0xC0,0x4F,0xB9,0x51,0xED}}" )
@ -37,11 +46,6 @@ if (MINGW)
" $ { L I B U S B _ P R E F I X } "
" $ { L I B U S B _ P R E F I X } "
)
)
# W e m a y u s e t h i s p a t h f o r o t h e r G N U t o o l c h a i n s , s o p u t a l l o f t h e M i n G W - s p e c i f i c s t u f f h e r e
if ( MINGW )
set ( LIBUSB_CONFIGURE_ARGS --host=x86_64-w64-mingw32 --build=x86_64-windows )
endif ( )
add_custom_command (
add_custom_command (
O U T P U T
O U T P U T
" $ { L I B U S B _ M A K E F I L E } "
" $ { L I B U S B _ M A K E F I L E } "
@ -71,16 +75,24 @@ if (MINGW)
/ b i n / c p " $ { L I B U S B _ S H A R E D _ L I B R A R Y } " " $ { L I B U S B _ S H A R E D _ L I B R A R Y _ D E S T } "
/ b i n / c p " $ { L I B U S B _ S H A R E D _ L I B R A R Y } " " $ { L I B U S B _ S H A R E D _ L I B R A R Y _ D E S T } "
)
)
add_custom_target ( usb-bootstrap ALL DEPENDS "${LIBUSB_CONFIGURE}" )
add_custom_target ( usb-bootstrap DEPENDS "${LIBUSB_CONFIGURE}" )
add_custom_target ( usb-configure ALL DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap )
add_custom_target ( usb-configure DEPENDS "${LIBUSB_MAKEFILE}" usb-bootstrap )
add_custom_target ( usb-build ALL DEPENDS "${LIBUSB_LIBRARY}" usb-configure )
add_custom_target ( usb-build ALL DEPENDS "${LIBUSB_LIBRARY}" usb-configure )
# W o r k a r o u n d s i n c e s t a t i c l i n k i n g d i d n ' t w o r k o u t - - W e n e e d t o c o p y t h e D L L t o t h e b i n d i r e c t o r y
# W o r k a r o u n d s i n c e s t a t i c l i n k i n g d i d n ' t w o r k o u t - - W e n e e d t o c o p y t h e D L L t o t h e b i n d i r e c t o r y
add_custom_target ( usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build )
add_custom_target ( usb-copy ALL DEPENDS "${LIBUSB_SHARED_LIBRARY_DEST}" usb-build )
# M a k e ` u s b ` a l i a s t o L I B U S B _ L I B R A R Y
add_library ( usb INTERFACE )
add_library ( usb INTERFACE )
add_dependencies ( usb usb-copy )
target_link_libraries ( usb INTERFACE "${LIBUSB_LIBRARY}" )
target_link_libraries ( usb INTERFACE "${LIBUSB_LIBRARY}" )
else ( ) # MINGW
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
find_package ( Libudev QUIET )
if ( LIBUDEV_FOUND )
target_link_libraries ( usb INTERFACE "${LIBUDEV_LIBRARIES}" )
target_include_directories ( usb INTERFACE "${LIBUDEV_INCLUDE_DIR}" )
endif ( )
endif ( )
else ( ) # MINGW O R N O T WIN32
# E n s u r e l i b u s b c o m p i l e s w i t h U T F - 8 e n c o d i n g o n MSVC
# E n s u r e l i b u s b c o m p i l e s w i t h U T F - 8 e n c o d i n g o n MSVC
if ( MSVC )
if ( MSVC )
add_compile_options ( /utf-8 )
add_compile_options ( /utf-8 )