Skip to content

Commit

Permalink
CMake: Remove LIB_LIBHID from configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusgreuel committed Jan 20, 2023
1 parent 5ec72e2 commit c98a49b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 23 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ endif()
# -------------------------------------
# Find libhidapi

find_library(HAVE_LIBHID NAMES hid)
if(HAVE_LIBHID)
set(LIB_LIBHID ${HAVE_LIBHID})
endif()

find_library(HAVE_LIBHIDAPI NAMES ${PREFERRED_LIBHIDAPI})
if(HAVE_LIBHIDAPI)
set(LIB_LIBHIDAPI ${HAVE_LIBHIDAPI})
Expand Down Expand Up @@ -307,7 +302,6 @@ if (DEBUG_CMAKE)
message(STATUS "HAVE_LIBUSB: ${HAVE_LIBUSB}")
message(STATUS "HAVE_LIBUSB_1_0: ${HAVE_LIBUSB_1_0}")
message(STATUS "HAVE_LIBUSB_WIN32: ${HAVE_LIBUSB_WIN32}")
message(STATUS "HAVE_LIBHID: ${HAVE_LIBHID}")
message(STATUS "HAVE_LIBHIDAPI: ${HAVE_LIBHIDAPI}")
message(STATUS "HAVE_LIBFTDI: ${HAVE_LIBFTDI}")
message(STATUS "HAVE_LIBFTDI1: ${HAVE_LIBFTDI1}")
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\")

if(WIN32)
set(EXTRA_WINDOWS_RESOURCES "${PROJECT_BINARY_DIR}/src/windows.rc")
set(EXTRA_WINDOWS_LIBRARIES setupapi ws2_32)
set(EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32)
endif()

if(MSVC)
Expand Down
3 changes: 0 additions & 3 deletions src/cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@
/* Define to 1 if you have the <libusb-1.0/libusb.h> header file. */
#cmakedefine HAVE_LIBUSB_1_0_LIBUSB_H 1

/* Define if HID support is enabled via the Win32 DDK */
#cmakedefine HAVE_LIBHID 1

/* Define if HID support is enabled via libhidapi */
#cmakedefine HAVE_LIBHIDAPI 1

Expand Down
5 changes: 0 additions & 5 deletions src/msvc/msvc_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#include <io.h>
#include <malloc.h>

#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "hid.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "setupapi.lib")

#define strerror_r(errno,buf,len) strerror_s(buf,len,errno)

#define R_OK 4
Expand Down
16 changes: 8 additions & 8 deletions src/pickit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
#include "avrdude.h"
#include "libavrdude.h"

#if defined(HAVE_LIBUSB) || (defined(WIN32) && defined(HAVE_LIBHID))
#if defined(HAVE_LIBUSB) || defined(WIN32)

#if (defined(WIN32) && defined(HAVE_LIBHID))
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <hidsdi.h>
Expand Down Expand Up @@ -88,7 +88,7 @@

#define SPI_MAX_CHUNK (64 - 10) // max packet size less the command overhead

#if (defined(WIN32) && defined(HAVE_LIBHID))
#ifdef WIN32
static HANDLE open_hid(unsigned short vid, unsigned short pid);
static const char *usb_strerror()
{
Expand Down Expand Up @@ -116,7 +116,7 @@ static int pickit2_read_report(const PROGRAMMER *pgm, unsigned char report[65]);
*/
struct pdata
{
#if (defined(WIN32) && defined(HAVE_LIBHID))
#ifdef WIN32
HANDLE usb_handle, write_event, read_event;
#else
struct usb_dev_handle *usb_handle; // LIBUSB STUFF
Expand Down Expand Up @@ -179,7 +179,7 @@ static void pickit2_teardown(PROGRAMMER * pgm)
}

static int pickit2_open(PROGRAMMER *pgm, const char *port) {
#if (defined(WIN32) && defined(HAVE_LIBHID))
#ifdef WIN32
PDATA(pgm)->usb_handle = open_hid(PICKIT2_VID, PICKIT2_PID);

if (PDATA(pgm)->usb_handle == INVALID_HANDLE_VALUE)
Expand Down Expand Up @@ -227,7 +227,7 @@ static int pickit2_open(PROGRAMMER *pgm, const char *port) {

static void pickit2_close(PROGRAMMER * pgm)
{
#if (defined(WIN32) && defined(HAVE_LIBHID))
#ifdef WIN32
CloseHandle(PDATA(pgm)->usb_handle);
CloseHandle(PDATA(pgm)->read_event);
CloseHandle(PDATA(pgm)->write_event);
Expand Down Expand Up @@ -788,7 +788,7 @@ static int pickit2_spi(const PROGRAMMER *pgm, const unsigned char *cmd,
return n_bytes;
}

#if (defined(WIN32) && defined(HAVE_LIBHID))
#ifdef WIN32
/*
Func: open_hid()
Desc: finds & opens device having specified VID & PID.
Expand Down Expand Up @@ -1298,7 +1298,7 @@ void pickit2_initpgm(PROGRAMMER *pgm) {
strncpy(pgm->type, "pickit2", sizeof(pgm->type));
}

#endif /* defined(HAVE_LIBUSB) || (defined(WIN32) && defined(HAVE_LIBHID)) */
#endif /* defined(HAVE_LIBUSB) || defined(WIN32) */

const char pickit2_desc[] = "Microchip's PICkit2 Programmer";

0 comments on commit c98a49b

Please sign in to comment.