2009-09-02 22:15:21 +02:00
|
|
|
PROJECT(libnfc C)
|
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
2009-11-02 15:05:03 +01:00
|
|
|
SET(VERSION_MAJOR "1")
|
2011-03-01 12:34:07 +01:00
|
|
|
SET(VERSION_MINOR "5")
|
|
|
|
SET(VERSION_PATCH "0")
|
2009-11-02 15:05:03 +01:00
|
|
|
|
|
|
|
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
|
|
|
|
|
|
|
SET(PACKAGE_NAME "libnfc")
|
|
|
|
SET(PACKAGE_VERSION ${VERSION})
|
|
|
|
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
2010-01-29 16:04:32 +01:00
|
|
|
|
2010-04-26 14:59:23 +02:00
|
|
|
# config.h
|
2011-03-31 15:38:49 +02:00
|
|
|
IF(WIN32)
|
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_windows.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32)
|
|
|
|
ELSE(WIN32)
|
2010-01-29 16:04:32 +01:00
|
|
|
SET(_XOPEN_SOURCE 600)
|
2011-03-31 15:38:49 +02:00
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
|
|
|
ENDIF(WIN32)
|
2010-01-29 16:04:32 +01:00
|
|
|
|
2010-04-26 14:59:23 +02:00
|
|
|
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
|
|
|
|
|
2010-04-07 16:37:19 +02:00
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
2009-09-02 22:15:21 +02:00
|
|
|
|
2009-09-09 09:51:11 +02:00
|
|
|
# make it easy to locate CMake modules for finding libraries
|
2011-03-31 15:38:49 +02:00
|
|
|
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
2009-09-09 09:51:11 +02:00
|
|
|
|
2010-04-26 14:59:23 +02:00
|
|
|
# Options
|
|
|
|
SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip")
|
|
|
|
IF(LIBNFC_DEBUG_OUTPUT)
|
|
|
|
ADD_DEFINITIONS(-DDEBUG -g3)
|
|
|
|
ENDIF(LIBNFC_DEBUG_OUTPUT)
|
|
|
|
|
2010-01-12 20:27:37 +01:00
|
|
|
# Doxygen
|
|
|
|
SET(builddir "${CMAKE_BINARY_DIR}")
|
|
|
|
SET(top_srcdir "${CMAKE_SOURCE_DIR}")
|
|
|
|
INCLUDE(UseDoxygen)
|
|
|
|
|
2009-09-02 22:15:21 +02:00
|
|
|
IF(DEFINED CMAKE_INSTALL_LIBDIR)
|
2009-09-03 11:21:52 +02:00
|
|
|
SET(libdir ${CMAKE_INSTALL_LIBDIR})
|
2009-09-02 22:15:21 +02:00
|
|
|
ELSE(DEFINED CMAKE_INSTALL_LIBDIR)
|
|
|
|
SET(CMAKE_INSTALL_LIBDIR lib)
|
2009-09-03 11:21:52 +02:00
|
|
|
SET(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
2009-09-02 22:15:21 +02:00
|
|
|
ENDIF(DEFINED CMAKE_INSTALL_LIBDIR)
|
|
|
|
|
|
|
|
IF(DEFINED INCLUDE_INSTALL_DIR)
|
2009-09-03 11:21:52 +02:00
|
|
|
SET(includedir ${INCLUDE_INSTALL_DIR})
|
2009-09-02 22:15:21 +02:00
|
|
|
ELSE(DEFINED INCLUDE_INSTALL_DIR)
|
|
|
|
SET(INCLUDE_INSTALL_DIR include)
|
2009-09-03 11:21:52 +02:00
|
|
|
SET(includedir ${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR})
|
2009-09-02 22:15:21 +02:00
|
|
|
ENDIF(DEFINED INCLUDE_INSTALL_DIR)
|
|
|
|
|
|
|
|
IF(NOT DEFINED SHARE_INSTALL_PREFIX)
|
|
|
|
SET(SHARE_INSTALL_PREFIX share)
|
|
|
|
ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
|
|
|
|
|
2010-04-26 14:59:23 +02:00
|
|
|
# Additonnal GCC flags
|
2010-12-21 12:06:43 +01:00
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
2010-03-22 21:28:30 +01:00
|
|
|
# Make sure we will not miss some warnings ;)
|
|
|
|
ADD_DEFINITIONS(-Wall -pedantic -std=c99)
|
2010-12-21 12:06:43 +01:00
|
|
|
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
2009-12-01 12:39:35 +01:00
|
|
|
|
2010-02-09 17:10:45 +01:00
|
|
|
# Workarounds for libusb in C99
|
|
|
|
ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
|
|
|
|
|
2011-01-17 14:42:24 +01:00
|
|
|
IF(MINGW)
|
|
|
|
# force MinGW-w64 in 32bit mode
|
|
|
|
ADD_DEFINITIONS(-m32)
|
|
|
|
SET(CMAKE_SHARED_LINKER_FLAGS -m32)
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS -m32)
|
|
|
|
ENDIF(MINGW)
|
|
|
|
|
2010-11-17 09:29:41 +01:00
|
|
|
IF(NOT WIN32)
|
2009-09-14 10:47:31 +02:00
|
|
|
# Set some pkg-config variables
|
|
|
|
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
SET(PACKAGE "libnfc")
|
2011-03-31 15:38:49 +02:00
|
|
|
IF(LIBNFC_DRIVER_PN53X_USB)
|
2009-09-14 10:47:31 +02:00
|
|
|
SET(PKG_REQ ${PKG_REQ} "libusb")
|
2011-03-31 15:38:49 +02:00
|
|
|
ENDIF(LIBNFC_DRIVER_PN53X_USB)
|
2010-04-20 10:45:31 +02:00
|
|
|
IF(LIBNFC_DRIVER_ACR122)
|
2009-09-14 10:47:31 +02:00
|
|
|
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
|
2010-04-20 10:45:31 +02:00
|
|
|
ENDIF(LIBNFC_DRIVER_ACR122)
|
2009-09-14 10:47:31 +02:00
|
|
|
# CMake lists are separated by a semi colon, replace with colon
|
|
|
|
STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}")
|
2009-09-02 22:15:21 +02:00
|
|
|
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)
|
2010-11-17 09:29:41 +01:00
|
|
|
ENDIF(NOT WIN32)
|
2009-09-02 22:15:21 +02:00
|
|
|
|
2010-04-07 16:37:19 +02:00
|
|
|
ADD_SUBDIRECTORY(libnfc)
|
|
|
|
ADD_SUBDIRECTORY(include)
|
|
|
|
ADD_SUBDIRECTORY(examples)
|
2009-09-02 22:15:21 +02:00
|
|
|
|
|
|
|
# Binary Package
|
2010-11-17 09:29:41 +01:00
|
|
|
IF(WIN32)
|
2009-09-02 22:15:21 +02:00
|
|
|
SET(CPACK_GENERATOR "NSIS")
|
2010-11-17 09:29:41 +01:00
|
|
|
ELSE(WIN32)
|
2009-09-09 14:32:41 +02:00
|
|
|
SET(CPACK_GENERATOR "TBZ2")
|
2010-11-17 09:29:41 +01:00
|
|
|
ENDIF(WIN32)
|
|
|
|
|
2009-09-02 22:15:21 +02:00
|
|
|
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")
|
2009-11-02 15:05:03 +01:00
|
|
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "libnfc")
|
|
|
|
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
|
|
|
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
|
|
|
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
2009-09-02 22:15:21 +02:00
|
|
|
SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "NFC Library")
|
|
|
|
SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example Applications")
|
|
|
|
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Development Headers")
|
2010-11-17 09:29:41 +01:00
|
|
|
IF(NOT WIN32)
|
2010-03-23 11:00:48 +01:00
|
|
|
SET(CPACK_COMPONENT_MANUALS_DISPLAY_NAME "Example Applications Manuals")
|
|
|
|
SET(CPACK_COMPONENT_MANUALS_DISABLED TRUE)
|
|
|
|
SET(CPACK_COMPONENT_MANUALS_DEPENDS examples)
|
2010-11-17 09:29:41 +01:00
|
|
|
ENDIF(NOT WIN32)
|
2009-09-02 22:15:21 +02:00
|
|
|
SET(CPACK_COMPONENT_HEADERS_DISABLED TRUE)
|
|
|
|
SET(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
|
|
|
|
SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries)
|
|
|
|
|
|
|
|
# Source Package
|
2010-11-17 09:29:41 +01:00
|
|
|
IF(WIN32)
|
2009-09-02 22:15:21 +02:00
|
|
|
SET(CPACK_SOURCE_GENERATOR "ZIP")
|
2010-11-17 09:29:41 +01:00
|
|
|
ELSE(WIN32)
|
2009-09-02 22:15:21 +02:00
|
|
|
SET(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
|
2010-11-17 09:29:41 +01:00
|
|
|
ENDIF(WIN32)
|
|
|
|
|
2009-09-02 22:15:21 +02:00
|
|
|
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "libnfc-${VERSION}")
|
|
|
|
SET(CPACK_SOURCE_IGNORE_FILES "~$" "/\\\\.svn/" "bin/")
|
|
|
|
INCLUDE(CPack)
|