Skip to content

Commit

Permalink
Fix build under MSYS2 MinGW-w64 (Windows)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
c72578 committed Dec 9, 2019
1 parent e4c5a3a commit 23c6aec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ find_path(HIDAPI_HEADER_DIR hidapi.h
)

if (BUILD_HIDAPI_SHARED)
find_library(HIDAPI_LIB NAMES hidapi-hidraw hidapi-libusb
# Under MSYS2 MinGW-w64 the filename of the import library is libhidapi.dll.a
find_library(HIDAPI_LIB NAMES hidapi-hidraw hidapi-libusb hidapi.dll
PATHS ../hidapi ../hidapi.git
PATH_SUFFIXES linux/.libs libusb/.libs linux libusb mac
DOC "The location of the HIDAPI shared library file"
Expand Down
4 changes: 4 additions & 0 deletions libtempered-util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ if (BUILD_SHARED_LIB)
OUTPUT_NAME tempered-util
SOVERSION 0
)
if(MINGW)
set_target_properties(tempered-util-shared PROPERTIES
SUFFIX ".dll")
endif()
target_link_libraries(tempered-util-shared m)
if (DEFINED CMAKE_INSTALL_LIBDIR)
install(
Expand Down
4 changes: 4 additions & 0 deletions libtempered/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ if (BUILD_SHARED_LIB)
OUTPUT_NAME tempered
SOVERSION 0
)
if(MINGW)
set_target_properties(tempered-shared PROPERTIES
SUFFIX ".dll")
endif()
if (DEFINED CMAKE_INSTALL_LIBDIR)
install(
TARGETS tempered-shared
Expand Down

0 comments on commit 23c6aec

Please sign in to comment.