Skip to content

Commit

Permalink
README.md: Add instructions for building with Visual Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Rubli committed Oct 22, 2021
1 parent b9c8d79 commit 66bc2cd
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,38 @@ make

Library and tools can be installed with `make install`.

When building with Microsoft Visual C++ (MSVC), you must also provide a library for **getopt** (vcpkg has [one](https://vcpkg.info/port/getopt)). Shared library builds are not currently supported with MSVC, use `-DBUILD_SHARED_LIBS=OFF` when configuring cmake.
For building hidpp with Visual Studio (tested with Visual Studio 2019 16.11.5) a `CMakeSettings.json` file is included which contains Debug and Release configurations each for the x64 and x86 platforms.
By default `BUILD_SHARED_LIBS` and `BUILD_TOOLS` are disabled, the former because shared library builds are not currently supported for MSVC (see #19), the latter because it requires extra dependencies.

Building the tools requires installing the **getopt** dependency first.
The easiest way of doing so is by installing [this one](https://vcpkg.info/port/getopt) available through [vcpkg](https://vcpkg.io/):

```
vcpkg install getopt:x86-windows
vcpkg install getopt:x64-windows
```

With getopt installed, enable the `BUILD_TOOLS` variable in the CMake Settings for the desired configurations, regenerate the CMake cache, and then build.

Manually building from a Visual Studio Developer console is also supported:

```
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF ..
# or, with tools support:
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg>\scripts\buildsystems\vcpkg.cmake ..
start hidpp.sln
```

An alternative is to use CMake's Ninja generator:

```
cmake -G ninja -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF ..
# or, with tools support:
cmake -G ninja -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg>\scripts\buildsystems\vcpkg.cmake ..
ninja
```

### CMake options

Expand Down

0 comments on commit 66bc2cd

Please sign in to comment.