From 7815747d02bebb52f3385b5b3fbddae979f4b614 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Fri, 7 Feb 2014 00:14:46 +0100 Subject: [PATCH] smartcard: fix PCSC detection/build on OS X fixes #1683 --- channels/smartcard/client/smartcard_operations.c | 16 +++++++++++++++- cmake/FindPCSC.cmake | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index 81d0583d0..30b64dbd0 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -31,8 +31,22 @@ #define BOOL PCSC_BOOL #include -#include #include +#if !defined(__APPLE__) +#include +#else +/* On OS X reader.h isn't available so define it here */ +#endif +#define SCARD_CLASS_SYSTEM 0x7fff /**< System-specific definitions */ +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0003) +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0005) +#ifdef UNICODE +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_W /**< Reader's display name. */ +#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_W /**< Reader's system name. */ +#else +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_A /**< Reader's display name. */ +#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_A /**< Reader's system name. */ +#endif #undef BOOL #include diff --git a/cmake/FindPCSC.cmake b/cmake/FindPCSC.cmake index 0cee2aba6..683252e98 100644 --- a/cmake/FindPCSC.cmake +++ b/cmake/FindPCSC.cmake @@ -12,6 +12,14 @@ find_path(PCSC_INCLUDE_DIR pcsclite.h find_library(PCSC_LIBRARY pcsclite PATHS ${PCSC_LIBRARY_DIRS}) +# Windows and Mac detection from http://www.cmake.org/Bug/print_bug_page.php?bug_id=11325 +IF(NOT PCSC_FOUND) + # Will find PC/SC headers both on Mac and Windows + FIND_PATH(PCSC_INCLUDE_DIRS WinSCard.h) + # PCSC library is for Mac, WinSCard library is for Windows + FIND_LIBRARY(PCSC_LIBRARY NAMES PCSC WinSCard) +ENDIF(NOT PCSC_FOUND) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSC DEFAULT_MSG PCSC_INCLUDE_DIR PCSC_LIBRARY) mark_as_advanced(PCSC_INCLUDE_DIR PCSC_LIBRARY)