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

Windows build: Add CMakeSettings.json and improve documentation #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "BUILD_TOOLS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "False",
"type": "BOOL"
}
]
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "BUILD_SHARED_LIBS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TOOLS",
"value": "False",
"type": "BOOL"
}
]
},
{
"name": "x86-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": [
{
"name": "BUILD_SHARED_LIBS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TOOLS",
"value": "False",
"type": "BOOL"
}
]
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": [
{
"name": "BUILD_SHARED_LIBS",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TOOLS",
"value": "False",
"type": "BOOL"
}
]
}
]
}
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,40 @@ 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.
### Building with Visual Studio

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