From 06a76f6470bd3d8a7a0461ca60a041a2e05bf6f1 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 4 Nov 2009 10:42:53 +0000 Subject: [PATCH] Attempt to make it works on MacOS. Small fixes. CMake work started. --- Makefile.am | 2 +- configure.ac | 2 +- src/CMakeLists.txt | 47 +--------------------------------- src/lib/CMakeLists.txt | 31 ++++++++++++++++++++++ src/lib/buses/CMakeLists.txt | 2 ++ src/lib/drivers.h | 10 ++++---- src/lib/drivers/CMakeLists.txt | 19 ++++++++++++++ 7 files changed, 60 insertions(+), 53 deletions(-) create mode 100644 src/lib/CMakeLists.txt create mode 100644 src/lib/buses/CMakeLists.txt create mode 100644 src/lib/drivers/CMakeLists.txt diff --git a/Makefile.am b/Makefile.am index 0d6fa9c..4ba301d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,7 @@ html-am : Doxyfile .PHONY: html endif -DISTCLEANFILES = \ +DISTCLEANFILES = \ Makefile.in \ configure \ depcomp \ diff --git a/configure.ac b/configure.ac index 7e364dc..931310c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -define([rev], esyscmd([sh -c "echo -n 'r' && svnversion -n"]))dnl +define([rev], esyscmd([sh -c "echo -e 'r\c' && svnversion -n"]))dnl AC_INIT(libnfc, 1.2.1+rev, info@libnfc.org) AC_CONFIG_HEADER(config.h) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e16108a..bd08bea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,21 +1,3 @@ -SET(LIBRARY-SOURCES libnfc rs232 bitutils dev_arygon dev_pn532_uart) - -# find PCSC library and headers -IF(LIBNFC_PCSC) - FIND_PACKAGE(PCSC REQUIRED) - ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCSC_CFLAGS_OTHER}") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "dev_acr122") -ENDIF(LIBNFC_PCSC) - -# find libusb library and headers -IF(LIBNFC_USB) - FIND_PACKAGE(LIBUSB REQUIRED) - ADD_DEFINITIONS("-DHAVE_LIBUSB=1") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS_OTHER}") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "dev_pn531" "dev_pn533") -ENDIF(LIBNFC_USB) - IF(LIBNFC_VERBOSE_OUTPUT) ADD_DEFINITIONS("-DDEBUG") ENDIF(LIBNFC_VERBOSE_OUTPUT) @@ -37,31 +19,4 @@ ENDIF(MSVC) INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${PCSC_INCLUDE_DIRS}) -# Library -ADD_LIBRARY(nfc SHARED ${LIBRARY-SOURCES}) -TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES}) -SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0 VERSION 0.0.0) - -IF(MSVC) - # On Windows the shared (runtime) library should be either in the same - # directory as the excutables or in the path, we add it to same directory - INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries) - - # At compile time we need the .LIB file, we place it in the lib directory - INSTALL(TARGETS nfc ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT headers) -ELSE(MSVC) - INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) -ENDIF(MSVC) - -# Headers -FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) -IF(MSVC) - # On Windows we also install the stdint headers, without it programs using it - # can't compile (like if we want to compile the included examples "out of - # tree") - #FILE(GLOB stdint "${CMAKE_CURRENT_SOURCE_DIR}/msvc/*.h") - #INSTALL(FILES ${stdint} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) -ENDIF(MSVC) - -ADD_SUBDIRECTORY(examples) +ADD_SUBDIRECTORY(lib examples) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 0000000..39cdca1 --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,31 @@ +SET(LIBRARY-SOURCES nfc bitutils) + +# Library +ADD_LIBRARY(nfc SHARED ${LIBRARY-SOURCES}) +TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${PCSC_LIBRARIES}) +SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0 VERSION 0.0.0) + +IF(MSVC) + # On Windows the shared (runtime) library should be either in the same + # directory as the excutables or in the path, we add it to same directory + INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries) + + # At compile time we need the .LIB file, we place it in the lib directory + INSTALL(TARGETS nfc ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT headers) +ELSE(MSVC) + INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +ENDIF(MSVC) + +# Headers +FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) +IF(MSVC) + # On Windows we also install the stdint headers, without it programs using it + # can't compile (like if we want to compile the included examples "out of + # tree") + #FILE(GLOB stdint "${CMAKE_CURRENT_SOURCE_DIR}/msvc/*.h") + #INSTALL(FILES ${stdint} DESTINATION ${INCLUDE_INSTALL_DIR}/libnfc COMPONENT headers) +ENDIF(MSVC) + + +ADD_SUBDIRECTORY(buses drivers) diff --git a/src/lib/buses/CMakeLists.txt b/src/lib/buses/CMakeLists.txt new file mode 100644 index 0000000..ac25831 --- /dev/null +++ b/src/lib/buses/CMakeLists.txt @@ -0,0 +1,2 @@ +SET(LIBRARY-SOURCES uart) + diff --git a/src/lib/drivers.h b/src/lib/drivers.h index c79b137..8061f59 100644 --- a/src/lib/drivers.h +++ b/src/lib/drivers.h @@ -27,14 +27,14 @@ #include "defines.h" #include "types.h" #ifdef HAVE_PCSC_LITE - #include + #include "drivers/acr122.h" #endif /* HAVE_PCSC_LITE */ #ifdef HAVE_LIBUSB - #include - #include + #include "drivers/pn531.h" + #include "drivers/pn533.h" #endif /* HAVE_LIBUSB */ -#include -#include +#include "drivers/arygon.h" +#include "drivers/pn532_uart.h" const static struct driver_callbacks drivers_callbacks_list[] = { // Driver Name Connect Transceive Disconnect diff --git a/src/lib/drivers/CMakeLists.txt b/src/lib/drivers/CMakeLists.txt new file mode 100644 index 0000000..a1ee863 --- /dev/null +++ b/src/lib/drivers/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(LIBRARY-SOURCES arygon pn532_uart) + +# find PCSC library and headers +IF(LIBNFC_PCSC) + FIND_PACKAGE(PCSC REQUIRED) + ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PCSC_CFLAGS_OTHER}") + SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "acr122") +ENDIF(LIBNFC_PCSC) + +# find libusb library and headers +IF(LIBNFC_USB) + FIND_PACKAGE(LIBUSB REQUIRED) + ADD_DEFINITIONS("-DHAVE_LIBUSB=1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS_OTHER}") + SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "pn531" "pn533") +ENDIF(LIBNFC_USB) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib)