mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-01-31 01:25:21 +01:00
Add meson.build as a wrapper over CMake (#410)
- not an independent build system, but a wrapper over CMake; - may be used as a standalone Meson build or as a subproject;
This commit is contained in:
28
.github/workflows/builds.yml
vendored
28
.github/workflows/builds.yml
vendored
@@ -37,6 +37,8 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: hidapisrc
|
||||
- name: Install dependencies
|
||||
run: brew install meson ninja
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
rm -rf build install
|
||||
@@ -58,6 +60,11 @@ jobs:
|
||||
install/framework/lib/hidapi.framework/Headers/hidapi.h, \
|
||||
install/framework/lib/hidapi.framework/Headers/hidapi_darwin.h"
|
||||
allow_failure: true
|
||||
- name: Check Meson build
|
||||
run: |
|
||||
meson setup build_meson hidapisrc
|
||||
cd build_meson
|
||||
ninja
|
||||
|
||||
ubuntu-cmake:
|
||||
|
||||
@@ -70,7 +77,8 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libudev-dev libusb-1.0-0-dev
|
||||
sudo apt install libudev-dev libusb-1.0-0-dev python3-pip ninja-build
|
||||
sudo -H pip3 install meson
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
rm -rf build install
|
||||
@@ -94,6 +102,11 @@ jobs:
|
||||
install/static/include/hidapi/hidapi.h, \
|
||||
install/static/include/hidapi/hidapi_libusb.h"
|
||||
allow_failure: true
|
||||
- name: Check Meson build
|
||||
run: |
|
||||
meson setup build_meson hidapisrc
|
||||
cd build_meson
|
||||
ninja
|
||||
|
||||
windows-cmake:
|
||||
|
||||
@@ -103,6 +116,11 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: hidapisrc
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
choco install ninja
|
||||
pip3 install meson
|
||||
refreshenv
|
||||
- name: Configure CMake MSVC
|
||||
shell: cmd
|
||||
run: |
|
||||
@@ -155,6 +173,14 @@ jobs:
|
||||
install/mingw/include/hidapi/hidapi_winapi.h"
|
||||
allow_failure: true
|
||||
|
||||
- name: Check Meson build
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
meson setup build_meson hidapisrc
|
||||
cd build_meson
|
||||
ninja
|
||||
|
||||
windows-msbuild:
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
8
BUILD.md
8
BUILD.md
@@ -19,7 +19,8 @@ For various reasons you may need to build HIDAPI on your own.
|
||||
It can be done in several different ways:
|
||||
- using [CMake](BUILD.cmake.md);
|
||||
- using [Autotools](BUILD.autotools.md) (deprecated);
|
||||
- using [manual makefiles](#building-the-manual-way-on-unix-platforms).
|
||||
- using [manual makefiles](#building-the-manual-way-on-unix-platforms);
|
||||
- using `Meson` (requires CMake);
|
||||
|
||||
**Autotools** build system is historically first mature build system for
|
||||
HIDAPI. Most common usage of it is in its separate README: [BUILD.autotools.md](BUILD.autotools.md).<br/>
|
||||
@@ -30,6 +31,11 @@ HIDAPI Team recommends using CMake build for HIDAPI.
|
||||
HIDAPI is one of the projects which uses the power of CMake for its advantage.
|
||||
More documentation is available in its separate README: [BUILD.cmake.md](BUILD.cmake.md).
|
||||
|
||||
**Meson** build system for HIDAPI is designed as a [wrapper](https://mesonbuild.com/CMake-module.html) over CMake build script.
|
||||
It is present for the convenience of Meson users who need to use HIDAPI and need to be sure HIDAPI is built in accordance with officially supported build scripts.<br>
|
||||
In the Meson script of your project you need a `hidapi = subproject('hidapi')` subproject, and `hidapi.get_variable('hidapi_dep')` as your dependency.
|
||||
There are also backend/platform-specific dependencies available: `hidapi_winapi`, `hidapi_darwin`, `hidapi_hidraw`, `hidapi_libusb`.
|
||||
|
||||
If you don't know where to start to build HIDAPI, we recommend starting with [CMake](BUILD.cmake.md) build.
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
22
meson.build
Normal file
22
meson.build
Normal file
@@ -0,0 +1,22 @@
|
||||
project('hidapi', meson_version: '>=0.57.0', version: files('VERSION'))
|
||||
|
||||
cmake = import('cmake')
|
||||
|
||||
hidapi_build_options = cmake.subproject_options()
|
||||
hidapi_build_options.set_install(true)
|
||||
|
||||
hidapi_build = cmake.subproject('hidapi_build_cmake', options: hidapi_build_options)
|
||||
|
||||
if (hidapi_build.target_list().contains('hidapi_winapi'))
|
||||
hidapi_winapi_dep = hidapi_build.dependency('hidapi_winapi')
|
||||
hidapi_dep = hidapi_winapi_dep
|
||||
elif (hidapi_build.target_list().contains('hidapi_darwin'))
|
||||
hidapi_darwin_dep = hidapi_build.dependency('hidapi_darwin')
|
||||
hidapi_dep = hidapi_darwin_dep
|
||||
elif (hidapi_build.target_list().contains('hidapi_hidraw'))
|
||||
hidapi_hidraw_dep = hidapi_build.dependency('hidapi_hidraw')
|
||||
hidapi_dep = hidapi_hidraw_dep
|
||||
elif (hidapi_build.target_list().contains('hidapi_libusb'))
|
||||
hidapi_libusb_dep = hidapi_build.dependency('hidapi_libusb')
|
||||
hidapi_dep = hidapi_libusb_dep
|
||||
endif
|
||||
2
subprojects/README.md
Normal file
2
subprojects/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
This folder is used only to support [meson.build](../meson.build) `subproject` command
|
||||
which would only look for a subproject in a "subprojects" directory.
|
||||
10
subprojects/hidapi_build_cmake/CMakeLists.txt
Normal file
10
subprojects/hidapi_build_cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR)
|
||||
project(hidapi LANGUAGES C)
|
||||
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root")
|
||||
|
||||
foreach(ROOT_ELEMENT CMakeLists.txt hidapi src windows linux mac libusb pc VERSION)
|
||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/../../${ROOT_ELEMENT}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/root/")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory("${CMAKE_CURRENT_BINARY_DIR}/root" hidapi_root)
|
||||
Reference in New Issue
Block a user