diff options
author | cslashm <cslashm@gmail.com> | 2018-05-23 10:22:55 +0200 |
---|---|---|
committer | cslashm <cslashm@gmail.com> | 2018-05-23 10:22:55 +0200 |
commit | bdf5a3ad3fb9e626a0c1cc2264934f26d07d06fc (patch) | |
tree | 2b5825df6768c530b59dce4b4eda722fe6c106ec | |
parent | Merge pull request #3800 (diff) | |
download | monero-bdf5a3ad3fb9e626a0c1cc2264934f26d07d06fc.tar.xz |
Fix PCSC compilation under windows
PR3843 based on release-v0.12 => rebased on master
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | cmake/FindPCSC.cmake | 6 | ||||
-rw-r--r-- | src/device/device_ledger.cpp | 9 | ||||
-rw-r--r-- | src/device/device_ledger.hpp | 5 |
4 files changed, 23 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b1297e716..287f93bd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -452,9 +452,12 @@ link_directories(${LIBUNWIND_LIBRARY_DIRS}) # Final setup for libpcsc if (PCSC_FOUND) + message(STATUS "Using PCSC include dir at ${PCSC_INCLUDE_DIR}") add_definitions(-DHAVE_PCSC) include_directories(${PCSC_INCLUDE_DIR}) link_directories(${LIBPCSC_LIBRARY_DIRS}) +else (PCSC_FOUND) + message(STATUS "Could not find PCSC") endif() if(MSVC) diff --git a/cmake/FindPCSC.cmake b/cmake/FindPCSC.cmake index 8dd9d0e76..8332abc49 100644 --- a/cmake/FindPCSC.cmake +++ b/cmake/FindPCSC.cmake @@ -18,6 +18,9 @@ ENDIF (NOT WIN32) FIND_PATH(PCSC_INCLUDE_DIR winscard.h HINTS + IF (WIN32) + ${MSYS2_FOLDER}/mingw64/x86_64-w64-mingw32/include + ENDIF (WIN32) /usr/include/PCSC ${PC_PCSC_INCLUDEDIR} ${PC_PCSC_INCLUDE_DIRS} @@ -26,6 +29,9 @@ FIND_PATH(PCSC_INCLUDE_DIR winscard.h FIND_LIBRARY(PCSC_LIBRARY NAMES pcsclite libpcsclite WinSCard PCSC HINTS + IF (WIN32) + ${MSYS2_FOLDER}/mingw64/x86_64-w64-mingw32/lib + ENDIF (WIN32) ${PC_PCSC_LIBDIR} ${PC_PCSC_LIBRARY_DIRS} ) diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index 3b9ab6744..aedaf8382 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -48,6 +48,15 @@ namespace hw { /* ===================================================================== */ /* === Debug ==== */ /* ===================================================================== */ + #ifdef WIN32 + static char *pcsc_stringify_error(LONG rv) { + static __thread char out[20]; + sprintf_s(out, sizeof(out), "0x%08lX", rv); + + return out; + } + #endif + void set_apdu_verbose(bool verbose) { apdu_verbose = verbose; } diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp index f1fcaab87..b62bdf959 100644 --- a/src/device/device_ledger.hpp +++ b/src/device/device_ledger.hpp @@ -33,8 +33,13 @@ #include <cstddef> #include <string> #include "device.hpp" +#ifdef WIN32 +#include <winscard.h> +#define MAX_ATR_SIZE 33 +#else #include <PCSC/winscard.h> #include <PCSC/wintypes.h> +#endif #include <boost/thread/mutex.hpp> #include <boost/thread/recursive_mutex.hpp> |