File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -332,9 +332,20 @@ fn bridge_dependency_include_flags(_target: &TargetInfo) -> Vec<String> {
332332 let mut flags = Vec :: new ( ) ;
333333 for package in [ "glib-2.0" , "libusb-1.0" , "fftw3" ] {
334334 for flag in pkg_config_output ( package, "--cflags" ) {
335+ let parent_flag = if package == "libusb-1.0" {
336+ normalized_libusb_include_flag ( & flag)
337+ } else {
338+ None
339+ } ;
340+
335341 if !flags. contains ( & flag) {
336342 flags. push ( flag) ;
337343 }
344+ if let Some ( parent_flag) = parent_flag {
345+ if !flags. contains ( & parent_flag) {
346+ flags. push ( parent_flag) ;
347+ }
348+ }
338349 }
339350 }
340351 flags
@@ -529,3 +540,13 @@ fn append_msvc_flag(command: &mut Command, flag: &str) {
529540 command. arg ( flag) ;
530541 }
531542}
543+
544+ fn normalized_libusb_include_flag ( flag : & str ) -> Option < String > {
545+ let include_path = flag. strip_prefix ( "-I" ) ?;
546+ let include_path = Path :: new ( include_path) ;
547+ if include_path. file_name ( ) ? != "libusb-1.0" {
548+ return None ;
549+ }
550+
551+ Some ( format ! ( "-I{}" , include_path. parent( ) ?. display( ) ) )
552+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ pkg_check_modules(GLIB REQUIRED glib-2.0)
1818pkg_check_modules (LIBUSB REQUIRED libusb-1.0 )
1919pkg_check_modules (FFTW REQUIRED fftw3 )
2020
21+ set (LIBUSB_NORMALIZED_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIRS} )
22+ foreach (LIBUSB_INCLUDE_DIR IN LISTS LIBUSB_INCLUDE_DIRS)
23+ get_filename_component (LIBUSB_INCLUDE_BASENAME "${LIBUSB_INCLUDE_DIR} " NAME )
24+ if (LIBUSB_INCLUDE_BASENAME STREQUAL "libusb-1.0" )
25+ get_filename_component (LIBUSB_INCLUDE_PARENT "${LIBUSB_INCLUDE_DIR} " DIRECTORY )
26+ list (APPEND LIBUSB_NORMALIZED_INCLUDE_DIRS "${LIBUSB_INCLUDE_PARENT} " )
27+ endif ()
28+ endforeach ()
29+ list (REMOVE_DUPLICATES LIBUSB_NORMALIZED_INCLUDE_DIRS)
30+
2131find_package (ZLIB REQUIRED )
2232find_package (Threads REQUIRED )
2333
@@ -61,7 +71,7 @@ target_include_directories(dsview_runtime PRIVATE
6171 ${LIBSIGROK_ROOT}
6272 ${COMMON_ROOT}
6373 ${GLIB_INCLUDE_DIRS}
64- ${LIBUSB_INCLUDE_DIRS }
74+ ${LIBUSB_NORMALIZED_INCLUDE_DIRS }
6575 ${FFTW_INCLUDE_DIRS}
6676)
6777
You can’t perform that action at this time.
0 commit comments