diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 89b3a6564..4fbb09df8 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -43,10 +43,14 @@ jobs: run: | rm -rf build install cmake -B build/shared -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/shared -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" + cmake -B build/static -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/static -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" cmake -B build/framework -S hidapisrc -DCMAKE_INSTALL_PREFIX=install/framework -DCMAKE_FRAMEWORK=ON -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" - name: Build CMake Shared working-directory: build/shared run: make install + - name: Build CMake Static + working-directory: build/static + run: make install - name: Build CMake Framework working-directory: build/framework run: make install @@ -56,10 +60,34 @@ jobs: files: "install/shared/lib/libhidapi.dylib, \ install/shared/include/hidapi/hidapi.h, \ install/shared/include/hidapi/hidapi_darwin.h, \ + install/static/lib/libhidapi.a, \ + install/static/include/hidapi/hidapi.h, \ + install/static/include/hidapi/hidapi_darwin.h, \ install/framework/lib/hidapi.framework/hidapi, \ install/framework/lib/hidapi.framework/Headers/hidapi.h, \ install/framework/lib/hidapi.framework/Headers/hidapi_darwin.h" allow_failure: true + - name: Check CMake Export Package Shared + run: | + cmake \ + -B build/shared_test \ + -S hidapisrc/hidtest \ + -Dhidapi_ROOT=install/shared \ + -DCMAKE_INSTALL_PREFIX=install/shared_test \ + "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" + cd build/shared_test + make install + - name: Check CMake Export Package Static + run: | + cmake \ + -B build/static_test \ + -S hidapisrc/hidtest \ + -Dhidapi_ROOT=install/static \ + -DCMAKE_INSTALL_PREFIX=install/static_test \ + "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" + cd build/static_test + make install + - name: Check Meson build run: | meson setup build_meson hidapisrc @@ -102,6 +130,27 @@ jobs: install/static/include/hidapi/hidapi.h, \ install/static/include/hidapi/hidapi_libusb.h" allow_failure: true + - name: Check CMake Export Package Shared + run: | + cmake \ + -B build/shared_test \ + -S hidapisrc/hidtest \ + -Dhidapi_ROOT=install/shared \ + -DCMAKE_INSTALL_PREFIX=install/shared_test \ + "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" + cd build/shared_test + make install + - name: Check CMake Export Package Static + run: | + cmake \ + -B build/static_test \ + -S hidapisrc/hidtest \ + -Dhidapi_ROOT=install/static \ + -DCMAKE_INSTALL_PREFIX=install/static_test \ + "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}" + cd build/static_test + make install + - name: Check Meson build run: | meson setup build_meson hidapisrc @@ -136,6 +185,17 @@ jobs: install/msvc/include/hidapi/hidapi.h, \ install/msvc/include/hidapi/hidapi_winapi.h" allow_failure: true + - name: Check CMake Export Package + shell: cmd + run: | + cmake ^ + -B build\msvc_test ^ + -S hidapisrc\hidtest ^ + -Dhidapi_ROOT=install\msvc ^ + -DCMAKE_INSTALL_PREFIX=install\msvc_test ^ + "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" + cd build\msvc_test + cmake --build . --target install - name: Configure CMake NMake shell: cmd @@ -156,6 +216,19 @@ jobs: install/nmake/include/hidapi/hidapi.h, \ install/nmake/include/hidapi/hidapi_winapi.h" allow_failure: true + - name: Check CMake Export Package NMake + shell: cmd + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + cmake ^ + -G"NMake Makefiles" ^ + -B build\nmake_test ^ + -S hidapisrc\hidtest ^ + -Dhidapi_ROOT=install\nmake ^ + -DCMAKE_INSTALL_PREFIX=install\nmake_test ^ + "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" + cd build\nmake_test + nmake install - name: Configure CMake MinGW shell: cmd @@ -172,6 +245,18 @@ jobs: install/mingw/include/hidapi/hidapi.h, \ install/mingw/include/hidapi/hidapi_winapi.h" allow_failure: true + - name: Check CMake Export Package MinGW + shell: cmd + run: | + cmake ^ + -G"MinGW Makefiles" ^ + -B build\ming_test ^ + -S hidapisrc\hidtest ^ + -Dhidapi_ROOT=install\mingw ^ + -DCMAKE_INSTALL_PREFIX=install\mingw_test ^ + "-DCMAKE_C_FLAGS=%NIX_COMPILE_FLAGS%" + cd build\ming_test + cmake --build . --target install - name: Check Meson build shell: cmd diff --git a/hidtest/CMakeLists.txt b/hidtest/CMakeLists.txt index 717ffec03..701a4fb91 100644 --- a/hidtest/CMakeLists.txt +++ b/hidtest/CMakeLists.txt @@ -1,5 +1,21 @@ +cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR) project(hidtest C) +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + # hidtest is build as a standalone project + + if(POLICY CMP0074) + # allow using hidapi_ROOT if CMake supports it + cmake_policy(SET CMP0074 NEW) + endif() + + find_package(hidapi 0.12 REQUIRED) + message(STATUS "Using HIDAPI: ${hidapi_VERSION}") +else() + # hidtest is built as part of the main HIDAPI build + message(STATUS "Building hidtest") +endif() + set(HIDAPI_HIDTEST_TARGETS) if(NOT WIN32 AND NOT APPLE AND CMAKE_SYSTEM_NAME MATCHES "Linux") if(TARGET hidapi::hidraw) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fe6716e2..29238592b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,8 +78,14 @@ endif() add_library(hidapi_include INTERFACE) target_include_directories(hidapi_include INTERFACE "$" - "$" ) +if(APPLE AND CMAKE_FRAMEWORK) + # FIXME: https://github.com/libusb/hidapi/issues/492: it is untrivial to set the include path for Framework correctly +else() + target_include_directories(hidapi_include INTERFACE + "$" + ) +endif() set_target_properties(hidapi_include PROPERTIES EXPORT_NAME "include") set(HIDAPI_PUBLIC_HEADERS "${PROJECT_ROOT}/hidapi/hidapi.h")