Add alternative build system (CMake).
This commit is contained in:
parent
b16bc53025
commit
a552a596fb
2 changed files with 142 additions and 0 deletions
66
CMakeLists.txt
Normal file
66
CMakeLists.txt
Normal file
|
@ -0,0 +1,66 @@
|
|||
PROJECT(libnfc C)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
SET(VERSION "1.2.2")
|
||||
|
||||
SET(LIBNFC_VERBOSE_OUTPUT OFF CACHE BOOL "Verbose output of communication with the NFC chip")
|
||||
SET(LIBNFC_LANG_C99 OFF CACHE BOOL "Use C99 language standard (GCC only)")
|
||||
|
||||
IF(DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
SET(PKG_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||
ELSE(DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
SET(CMAKE_INSTALL_LIBDIR lib)
|
||||
SET(PKG_LIBDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||
ENDIF(DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
|
||||
IF(DEFINED INCLUDE_INSTALL_DIR)
|
||||
SET(PKG_INCLUDE_DIR ${INCLUDE_INSTALL_DIR})
|
||||
ELSE(DEFINED INCLUDE_INSTALL_DIR)
|
||||
SET(INCLUDE_INSTALL_DIR include)
|
||||
SET(PKG_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR})
|
||||
ENDIF(DEFINED INCLUDE_INSTALL_DIR)
|
||||
|
||||
IF(NOT DEFINED SHARE_INSTALL_PREFIX)
|
||||
SET(SHARE_INSTALL_PREFIX share)
|
||||
ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
|
||||
|
||||
IF(NOT MSVC)
|
||||
INCLUDE(FindPkgConfig)
|
||||
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)
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
|
||||
# Binary Package
|
||||
IF(MSVC)
|
||||
SET(CPACK_GENERATOR "NSIS")
|
||||
ELSE(MSVC)
|
||||
SET(CPACK_GENERATOR "TGZ")
|
||||
ENDIF(MSVC)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "libnfc-${VERSION}-bin")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Near Field Communication (NFC) library")
|
||||
SET(CPACK_PACKAGE_VENDOR "Roel Verdult")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "2")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "2")
|
||||
SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "NFC Library")
|
||||
SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example Applications")
|
||||
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Development Headers")
|
||||
SET(CPACK_COMPONENT_MANUALS_DISPLAY_NAME "Example Applications Manuals")
|
||||
SET(CPACK_COMPONENT_HEADERS_DISABLED TRUE)
|
||||
SET(CPACK_COMPONENT_MANUALS_DISABLED TRUE)
|
||||
SET(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
|
||||
SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries)
|
||||
SET(CPACK_COMPONENT_MANUALS_DEPENDS examples)
|
||||
|
||||
# Source Package
|
||||
IF(MSVC)
|
||||
SET(CPACK_SOURCE_GENERATOR "ZIP")
|
||||
ELSE(MSVC)
|
||||
SET(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
|
||||
ENDIF(MSVC)
|
||||
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "libnfc-${VERSION}")
|
||||
SET(CPACK_SOURCE_IGNORE_FILES "~$" "/\\\\.svn/" "bin/")
|
||||
INCLUDE(CPack)
|
76
src/CMakeLists.txt
Normal file
76
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,76 @@
|
|||
SET(LIBRARY-SOURCES libnfc dev_pn531 dev_pn533 dev_acr122 rs232 bitutils dev_arygon)
|
||||
SET(TOOLS-SOURCES list mftool mfultool)
|
||||
|
||||
ADD_DEFINITIONS("-DHAVE_PCSC_LITE=1")
|
||||
|
||||
IF(LIBNFC_VERBOSE_OUTPUT)
|
||||
ADD_DEFINITIONS("-DDEBUG")
|
||||
ENDIF(LIBNFC_VERBOSE_OUTPUT)
|
||||
|
||||
IF(LIBNFC_LANG_C99 AND NOT MSVC)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||
ENDIF(LIBNFC_LANG_C99 AND NOT MSVC)
|
||||
|
||||
IF(MSVC)
|
||||
# Hide some warnings, this should be fixed in the code instead!
|
||||
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS")
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF(MSVC)
|
||||
# Include the stdint headers, because MSVC does not have them
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/msvc)
|
||||
|
||||
# This is from libusb-win32.sourceforge.net
|
||||
SET(LIBUSB_INCLUDE_DIRS $ENV{ProgramFiles}/LibUSB-Win32/include)
|
||||
SET(LIBUSB_LIBRARIES $ENV{ProgramFiles}/LibUSB-Win32/lib/msvc/libusb.lib)
|
||||
|
||||
# This is included with Visual Studio Express 2008, we should really use
|
||||
# something that finds this library, whatever the MSVC version
|
||||
SET(LIBPCSCLITE_LIBRARIES "$ENV{ProgramFiles}/Microsoft SDKs/Windows/v6.0A/Lib/WinSCard.Lib")
|
||||
# On MSVC we don't need the winscard.h header in the include path because
|
||||
# it already is there...
|
||||
ELSE(MSVC)
|
||||
# On Unix we just use pkg-config
|
||||
PKG_CHECK_MODULES(LIBUSB REQUIRED libusb)
|
||||
PKG_CHECK_MODULES(LIBPCSCLITE REQUIRED libpcsclite)
|
||||
ENDIF(MSVC)
|
||||
|
||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS} ${LIBPCSCLITE_INCLUDE_DIRS})
|
||||
|
||||
# Library
|
||||
ADD_LIBRARY(nfc SHARED ${LIBRARY-SOURCES})
|
||||
TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES} ${LIBPCSCLITE_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)
|
||||
|
||||
# Examples
|
||||
FOREACH(source ${TOOLS-SOURCES})
|
||||
ADD_EXECUTABLE(nfc-${source} ${source}.c)
|
||||
TARGET_LINK_LIBRARIES(nfc-${source} nfc)
|
||||
INSTALL(TARGETS nfc-${source} RUNTIME DESTINATION bin COMPONENT examples)
|
||||
ENDFOREACH(source)
|
||||
|
||||
# Manuals for the examples
|
||||
FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1")
|
||||
INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals)
|
Loading…
Add table
Reference in a new issue