Windows support contribution:

- Move CMake modules from cmake_modules/ to cmake/modules/
 - CMake now use cmake/config_windows.h.cmake to create config.h on Windows platform
 - contrib/windows.h header is automagically included by config.h
 - Put missing NFC_EXPORT macro on front of emulation API
 - nfc-mfclassic and nfc-mfcultralight examples are now compiled under Windows
Many thanks to Glenn Ergeerts which provide the initial patch.
This commit is contained in:
Romuald Conty 2011-03-31 13:38:49 +00:00
parent b471f56c52
commit 5db8be908b
20 changed files with 37 additions and 31 deletions

View file

@ -0,0 +1,22 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,66 @@
# This CMake script wants to use libusb functionality, therefore it looks
# for libusb include files and libraries.
#
# Operating Systems Supported:
# - Unix (requires pkg-config)
# Tested with Ubuntu 9.04 and Fedora 11
# - Windows (requires MSVC)
# Tested with Windows XP
#
# This should work for both 32 bit and 64 bit systems.
#
# Author: F. Kooman <fkooman@tuxed.net>
#
# FreeBSD has built-in libusb since 800069
IF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
EXEC_PROGRAM(sysctl ARGS -n kern.osreldate OUTPUT_VARIABLE FREEBSD_VERSION)
SET(MIN_FREEBSD_VERSION 800068)
IF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
SET(LIBUSB_FOUND TRUE)
SET(LIBUSB_INCLUDE_DIRS "/usr/include")
SET(LIBUSB_LIBRARIES "usb")
SET(LIBUSB_LIBRARY_DIRS "/usr/lib/")
ENDIF(FREEBSD_VERSION GREATER ${MIN_FREEBSD_VERSION})
ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
IF(NOT LIBUSB_FOUND)
IF(WIN32)
# Windows with Microsoft Visual C++
FIND_PATH(LIBUSB_INCLUDE_DIRS usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
IF(MSVC)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x64")
# on x64 (win64)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/msvc_x64")
ELSE(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x64")
# on x86 (win32)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/msvc")
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x64")
ENDIF(MSVC)
IF(MINGW)
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/gcc")
ENDIF(MINGW)
ELSE(WIN32)
# If not under Windows we use PkgConfig
FIND_PACKAGE (PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(LIBUSB REQUIRED libusb)
ELSE(PKG_CONFIG_FOUND)
MESSAGE(FATAL_ERROR "Could not find PkgConfig")
ENDIF(PKG_CONFIG_FOUND)
ENDIF(WIN32)
IF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
SET(LIBUSB_FOUND TRUE)
ENDIF(LIBUSB_INCLUDE_DIRS AND LIBUSB_LIBRARIES)
ENDIF(NOT LIBUSB_FOUND)
IF(LIBUSB_FOUND)
IF(NOT LIBUSB_FIND_QUIETLY)
MESSAGE(STATUS "Found LIBUSB: ${LIBUSB_LIBRARIES} ${LIBUSB_INCLUDE_DIRS}")
ENDIF (NOT LIBUSB_FIND_QUIETLY)
ELSE(LIBUSB_FOUND)
IF(LIBUSB_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LIBUSB")
ENDIF(LIBUSB_FIND_REQUIRED)
ENDIF(LIBUSB_FOUND)

View file

@ -0,0 +1,31 @@
# - Try to find the PC/SC smart card library
# Once done this will define
#
# PCSC_FOUND - system has the PC/SC library
# PCSC_INCLUDE_DIRS - the PC/SC include directory
# PCSC_LIBRARIES - The libraries needed to use PC/SC
#
# Author: F. Kooman <fkooman@tuxed.net>
# Version: 20101019
#
FIND_PACKAGE (PkgConfig)
IF(PKG_CONFIG_FOUND)
# Will find PC/SC library on Linux/BSDs using PkgConfig
PKG_CHECK_MODULES(PCSC libpcsclite)
# PKG_CHECK_MODULES(PCSC QUIET libpcsclite) # IF CMake >= 2.8.2?
ENDIF(PKG_CONFIG_FOUND)
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_LIBRARIES NAMES PCSC libwinscard)
ENDIF(NOT PCSC_FOUND)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSC DEFAULT_MSG
PCSC_LIBRARIES
PCSC_INCLUDE_DIRS
)
MARK_AS_ADVANCED(PCSC_INCLUDE_DIRS PCSC_LIBRARIES)

View file

@ -0,0 +1,29 @@
SET(LIBNFC_DRIVER_ACR122 ON CACHE BOOL "Enable ACR122 support (Depends on PC/SC)")
SET(LIBNFC_DRIVER_PN53X_USB ON CACHE BOOL "Enable PN531 and PN531 USB support (Depends on libusb)")
SET(LIBNFC_DRIVER_ARYGON ON CACHE BOOL "Enable ARYGON support (Use serial port)")
SET(LIBNFC_DRIVER_PN532_UART OFF CACHE BOOL "Enable PN532 UART support (Use serial port)")
IF(LIBNFC_DRIVER_ACR122)
FIND_PACKAGE(PCSC REQUIRED)
ADD_DEFINITIONS("-DDRIVER_ACR122_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122")
ENDIF(LIBNFC_DRIVER_ACR122)
IF(LIBNFC_DRIVER_PN53X_USB)
FIND_PACKAGE(LIBUSB REQUIRED)
ADD_DEFINITIONS("-DDRIVER_PN53X_USB_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn53x_usb")
ENDIF(LIBNFC_DRIVER_PN53X_USB)
IF(LIBNFC_DRIVER_ARYGON)
ADD_DEFINITIONS("-DDRIVER_ARYGON_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/arygon")
ENDIF(LIBNFC_DRIVER_ARYGON)
IF(LIBNFC_DRIVER_PN532_UART)
ADD_DEFINITIONS("-DDRIVER_PN532_UART_ENABLED")
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_uart")
ENDIF(LIBNFC_DRIVER_PN532_UART)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/drivers)

View file

@ -0,0 +1,6 @@
EXTRA_DIST = \
COPYING-CMAKE-SCRIPTS \
FindLIBUSB.cmake \
FindPCSC.cmake \
UseDoxygen.cmake \
LibnfcDrivers.cmake

View file

@ -0,0 +1,100 @@
# - Run Doxygen
#
# Adds a doxygen target that runs doxygen to generate the html
# and optionally the LaTeX API documentation.
# The doxygen target is added to the doc target as dependency.
# i.e.: the API documentation is built with:
# make doc
#
# USAGE: GLOBAL INSTALL
#
# Install it with:
# cmake ./ && sudo make install
# Add the following to the CMakeLists.txt of your project:
# include(UseDoxygen OPTIONAL)
# Optionally copy Doxyfile.in in the directory of CMakeLists.txt and edit it.
#
# USAGE: INCLUDE IN PROJECT
#
# set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# include(UseDoxygen)
# Add the Doxyfile.in and UseDoxygen.cmake files to the projects source directory.
#
#
# Variables you may define are:
# DOXYFILE_OUTPUT_DIR - Path where the Doxygen output is stored. Defaults to "doc".
#
# DOXYFILE_LATEX_DIR - Directory where the Doxygen LaTeX output is stored. Defaults to "latex".
#
# DOXYFILE_HTML_DIR - Directory where the Doxygen html output is stored. Defaults to "html".
#
#
# Copyright (c) 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
macro(usedoxygen_set_default name value)
if(NOT DEFINED "${name}")
set("${name}" "${value}")
endif()
endmacro()
find_package(Doxygen)
if(DOXYGEN_FOUND)
find_file(DOXYFILE_IN "Doxyfile.in"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_ROOT}/Modules/")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Doxyfile.in DEFAULT_MSG DOXYFILE_IN)
endif()
if(DOXYGEN_FOUND AND DOXYFILE_IN)
add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
usedoxygen_set_default(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
usedoxygen_set_default(DOXYFILE_HTML_DIR "html")
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR}")
set(DOXYFILE_LATEX "NO")
set(DOXYFILE_PDFLATEX "NO")
set(DOXYFILE_DOT "NO")
find_package(LATEX)
if(LATEX_COMPILER AND MAKEINDEX_COMPILER)
set(DOXYFILE_LATEX "YES")
usedoxygen_set_default(DOXYFILE_LATEX_DIR "latex")
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
if(PDFLATEX_COMPILER)
set(DOXYFILE_PDFLATEX "YES")
endif()
if(DOXYGEN_DOT_EXECUTABLE)
set(DOXYFILE_DOT "YES")
endif()
add_custom_command(TARGET doxygen
POST_BUILD
COMMAND ${CMAKE_MAKE_PROGRAM}
WORKING_DIRECTORY "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
endif()
configure_file(${DOXYFILE_IN} Doxyfile ESCAPE_QUOTES IMMEDIATE @ONLY)
get_target_property(DOC_TARGET doc TYPE)
if(NOT DOC_TARGET)
add_custom_target(doc)
endif()
add_dependencies(doc doxygen)
endif()