Skip to content

Commit f57479b

Browse files
committed
fix build on Windows
1 parent 337cf55 commit f57479b

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ First let's install a few dependencies.
6363
- `apt install git cmake libusb-1.0-0-dev libssl-dev`
6464
- Install [grpc](https://github.com/grpc/grpc/blob/master/BUILDING.md) from source.
6565
- Windows
66-
- Install [Visual Studio C++](https://visualstudio.microsoft.com/vs/features/cplusplus/) for its C++ compiler. It's also an IDE.
66+
- Install [Visual Studio C++](https://visualstudio.microsoft.com/vs/features/cplusplus/) for its C++ compiler.
6767
- Use [winget](https://docs.microsoft.com/en-us/windows/package-manager/winget/) to install [git](https://winget.run/pkg/Git/Git) and [CMake](https://winget.run/pkg/Kitware/CMake).
68-
- Use [vcpkg](https://github.com/microsoft/vcpkg) to install `libusb`, `gRPC`, `OpenSSL`, and `getopt` under the right triplet (e.g. `x64-windows`).
68+
- Use [vcpkg](https://github.com/microsoft/vcpkg) to install `libusb`, `gRPC`, `OpenSSL`, and `getopt`.
6969
- Use [Zadig](https://zadig.akeo.ie) to install the [WinUSB](https://github.com/libusb/libusb/wiki/Windows#driver-installation) driver on any `JABI USB` devices.
7070

71-
We use CMake for our build system which has the following standard build process. For macOS gRPC projects, you may need to do `cmake .. -DOPENSSL_ROOT_DIR=$(brew --prefix openssl)` instead.
71+
We use CMake for our build system which has the following standard build process.
7272

7373
```
7474
cd <project path>

clients/libjabi/CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ add_library(libjabi
1515
peripherals/lin.cpp
1616
)
1717

18-
find_package(libusb CONFIG QUIET)
19-
if(NOT ${libusb_FOUND})
20-
find_library(LIBUSB_LIBRARIES NAMES usb-1.0)
21-
find_path(LIBUSB_INCLUDE_DIRS NAMES libusb.h PATH_SUFFIXES libusb-1.0)
22-
endif()
23-
2418
if(MSVC)
25-
target_link_libraries(libjabi ${LIBUSB_LIBRARIES})
19+
find_package(PkgConfig REQUIRED)
20+
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
21+
target_link_libraries(libjabi PkgConfig::libusb)
2622
else()
23+
find_package(libusb CONFIG QUIET)
24+
if(NOT ${libusb_FOUND})
25+
find_library(LIBUSB_LIBRARIES NAMES usb-1.0)
26+
find_path(LIBUSB_INCLUDE_DIRS NAMES libusb.h PATH_SUFFIXES libusb-1.0)
27+
endif()
2728
target_link_libraries(libjabi pthread ${LIBUSB_LIBRARIES})
2829
endif()
2930

include/protos/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ target_include_directories(jabiproto SYSTEM PUBLIC
1717
)
1818

1919
target_link_libraries(jabiproto PUBLIC
20-
${Protobuf_LIBRARIES}
2120
gRPC::grpc++
2221
)
2322

0 commit comments

Comments
 (0)