Skip to content

Commit 23c6aec

Browse files
committed
Fix build under MSYS2 MinGW-w64 (Windows)
- Under MSYS2 MinGW-w64 the filename of the hidapi import library is "libhidapi.dll.a". Add hidapi.dll to NAMES of findlibrary(). - Use SUFFIX ".dll" for libtempered and libtempered-util, which is typical under Windows in case of shared libraries. Result: libtempered.so -> libtempered.dll libtempered-util.so -> libtempered-util.dll
1 parent e4c5a3a commit 23c6aec

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ find_path(HIDAPI_HEADER_DIR hidapi.h
3838
)
3939

4040
if (BUILD_HIDAPI_SHARED)
41-
find_library(HIDAPI_LIB NAMES hidapi-hidraw hidapi-libusb
41+
# Under MSYS2 MinGW-w64 the filename of the import library is libhidapi.dll.a
42+
find_library(HIDAPI_LIB NAMES hidapi-hidraw hidapi-libusb hidapi.dll
4243
PATHS ../hidapi ../hidapi.git
4344
PATH_SUFFIXES linux/.libs libusb/.libs linux libusb mac
4445
DOC "The location of the HIDAPI shared library file"

libtempered-util/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ if (BUILD_SHARED_LIB)
1212
OUTPUT_NAME tempered-util
1313
SOVERSION 0
1414
)
15+
if(MINGW)
16+
set_target_properties(tempered-util-shared PROPERTIES
17+
SUFFIX ".dll")
18+
endif()
1519
target_link_libraries(tempered-util-shared m)
1620
if (DEFINED CMAKE_INSTALL_LIBDIR)
1721
install(

libtempered/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ if (BUILD_SHARED_LIB)
1313
OUTPUT_NAME tempered
1414
SOVERSION 0
1515
)
16+
if(MINGW)
17+
set_target_properties(tempered-shared PROPERTIES
18+
SUFFIX ".dll")
19+
endif()
1620
if (DEFINED CMAKE_INSTALL_LIBDIR)
1721
install(
1822
TARGETS tempered-shared

0 commit comments

Comments
 (0)