find_path(YKPERS_DIR ykpers.h ${CMAKE_SOURCE_DIR}/3rdparty/*)
mark_as_advanced(YKPERS_DIR)
include_directories(${YKPERS_DIR} ${YKPERS_DIR}/ykcore)

if(CMAKE_HOST_APPLE)
  find_library(CoreFoundation_LIBRARY CoreFoundation)
  find_library(IOKit_LIBRARY IOKit)
  set(YKPERS_CORE_SRC ${YKPERS_DIR}/ykcore/ykcore_osx.c)
elseif(CMAKE_HOST_UNIX)
  find_package(libusb1.0 REQUIRED)
  include_directories(${LIBUSB_1_INCLUDE_DIRS}/libusb-1.0)
  set(YKPERS_CORE_SRC ${YKPERS_DIR}/ykcore/ykcore_libusb-1.0.c)
else()
  find_package(WinDDK REQUIRED)
  set(YKPERS_CORE_SRC ${YKPERS_DIR}/ykcore/ykcore_windows.c)
endif()

set(YKPERS_SRC ${YKPERS_CORE_SRC} ${YKPERS_DIR}/ykcore/ykcore.c ${YKPERS_DIR}/ykcore/ykstatus.c)
set(YKPERS_LIBS ${LIBUSB_1_LIBRARY} ${CoreFoundation_LIBRARY} ${IOKit_LIBRARY} ${WINDDK_LIBS})
set(YKPERS_LICENSE ${YKPERS_DIR}/COPYING)
set(YKPERS_RULES ${YKPERS_DIR}/70-yubikey.rules)
