From 0977dd1c0b7a55b9f3ef65afe4c0b3bbf9bbfd04 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Mon, 14 Sep 2009 08:47:31 +0000 Subject: [PATCH] Fix CMake pkg-config generation: "Requires:" is now dynamic. Fix devices.h, #endif should not be followed by the name of the block. Fix CMake libnfc_usb compilation. Rename tools to examples in CMake file. (This patch comes from Fkooman, thanks !) --- CMakeLists.txt | 18 ++++++++++++------ src/CMakeLists.txt | 8 +++++--- src/devices.h | 8 ++++---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4636304..09d3eff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,11 +11,6 @@ SET(LIBNFC_PCSC ON CACHE BOOL "Enable PC/SC support (PN532)") SET(LIBNFC_USB OFF CACHE BOOL "Enable direct USB communication support (PN531 and PN533)") SET(LIBNFC_DISABLE_SERIAL_AUTOPROBE OFF CACHE BOOL "Disable serial autoprobe") -# Set some pkg-config variables -SET(prefix ${CMAKE_INSTALL_PREFIX}) -SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) -SET(PACKAGE "libnfc") - IF(DEFINED CMAKE_INSTALL_LIBDIR) SET(libdir ${CMAKE_INSTALL_LIBDIR}) ELSE(DEFINED CMAKE_INSTALL_LIBDIR) @@ -35,7 +30,18 @@ IF(NOT DEFINED SHARE_INSTALL_PREFIX) ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX) IF(NOT MSVC) - #INCLUDE(FindPkgConfig) + # Set some pkg-config variables + SET(prefix ${CMAKE_INSTALL_PREFIX}) + SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) + SET(PACKAGE "libnfc") + IF(LIBNFC_USB) + SET(PKG_REQ ${PKG_REQ} "libusb") + ENDIF(LIBNFC_USB) + IF(LIBNFC_PCSC) + SET(PKG_REQ ${PKG_REQ} "libpcsclite") + ENDIF(LIBNFC_PCSC) + # CMake lists are separated by a semi colon, replace with colon + STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ENDIF(NOT MSVC) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1613f1d..a4ed7a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,11 @@ SET(LIBRARY-SOURCES libnfc rs232 bitutils dev_arygon) -SET(TOOLS-SOURCES list mftool mfultool initiator target anticol emulate relay) +SET(EXAMPLES-SOURCES list mftool mfultool initiator target anticol emulate relay) # 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) @@ -12,7 +13,8 @@ ENDIF(LIBNFC_PCSC) IF(LIBNFC_USB) FIND_PACKAGE(LIBUSB REQUIRED) ADD_DEFINITIONS("-DHAVE_LIBUSB=1") - SET(LIBRARY-SOURCES ${LIBRARY-SOURCES} "dev_pn531 dev_pn533") + 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) @@ -64,7 +66,7 @@ IF(MSVC) ENDIF(MSVC) # Examples -FOREACH(source ${TOOLS-SOURCES}) +FOREACH(source ${EXAMPLES-SOURCES}) ADD_EXECUTABLE(nfc-${source} ${source}.c) TARGET_LINK_LIBRARIES(nfc-${source} nfc) INSTALL(TARGETS nfc-${source} RUNTIME DESTINATION bin COMPONENT examples) diff --git a/src/devices.h b/src/devices.h index f4a7c73..0d1e155 100644 --- a/src/devices.h +++ b/src/devices.h @@ -25,22 +25,22 @@ along with this program. If not, see #include "types.h" #ifdef HAVE_PCSC_LITE #include "dev_acr122.h" -#endif +#endif /* HAVE_PCSC_LITE */ #ifdef HAVE_LIBUSB #include "dev_pn531.h" #include "dev_pn533.h" -#endif HAVE_LIBUSB +#endif /* HAVE_LIBUSB */ #include "dev_arygon.h" const static struct dev_callbacks dev_callbacks_list[] = { // Driver Name Connect Transceive Disconnect #ifdef HAVE_PCSC_LITE { "ACR122", dev_acr122_connect, dev_acr122_transceive, dev_acr122_disconnect }, -#endif +#endif /* HAVE_PCSC_LITE */ #ifdef HAVE_LIBUSB { "PN531USB", dev_pn531_connect, dev_pn531_transceive, dev_pn531_disconnect }, { "PN533USB", dev_pn533_connect, dev_pn533_transceive, dev_pn533_disconnect }, -#endif HAVE_LIBUSB +#endif /* HAVE_LIBUSB */ { "ARYGON", dev_arygon_connect, dev_arygon_transceive, dev_arygon_disconnect } };