forked from nfc-tools/libnfc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
131 lines (111 loc) · 4.25 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
PROJECT(libnfc C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(VERSION_MAJOR "1")
SET(VERSION_MINOR "5")
SET(VERSION_PATCH "0")
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
SET(PACKAGE_NAME "libnfc")
SET(PACKAGE_VERSION ${VERSION})
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
# config.h
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)
SET(_XOPEN_SOURCE 600)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
ENDIF(WIN32)
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
# make it easy to locate CMake modules for finding libraries
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
# 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)
# Doxygen
SET(builddir "${CMAKE_BINARY_DIR}")
SET(top_srcdir "${CMAKE_SOURCE_DIR}")
INCLUDE(UseDoxygen)
IF(DEFINED CMAKE_INSTALL_LIBDIR)
SET(libdir ${CMAKE_INSTALL_LIBDIR})
ELSE(DEFINED CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR lib)
SET(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
ENDIF(DEFINED CMAKE_INSTALL_LIBDIR)
IF(DEFINED INCLUDE_INSTALL_DIR)
SET(includedir ${INCLUDE_INSTALL_DIR})
ELSE(DEFINED INCLUDE_INSTALL_DIR)
SET(INCLUDE_INSTALL_DIR include)
SET(includedir ${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)
# Additonnal GCC flags
IF(CMAKE_COMPILER_IS_GNUCC)
# Make sure we will not miss some warnings ;)
ADD_DEFINITIONS(-Wall -pedantic -std=c99)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
# Workarounds for libusb in C99
ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
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)
IF(NOT WIN32)
# Set some pkg-config variables
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
SET(PACKAGE "libnfc")
IF(LIBNFC_DRIVER_PN53X_USB)
SET(PKG_REQ ${PKG_REQ} "libusb")
ENDIF(LIBNFC_DRIVER_PN53X_USB)
IF(LIBNFC_DRIVER_ACR122)
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
ENDIF(LIBNFC_DRIVER_ACR122)
# 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 WIN32)
ADD_SUBDIRECTORY(libnfc)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(examples)
# Binary Package
IF(WIN32)
SET(CPACK_GENERATOR "NSIS")
ELSE(WIN32)
SET(CPACK_GENERATOR "TBZ2")
ENDIF(WIN32)
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_INSTALL_DIRECTORY "libnfc")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "NFC Library")
SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example Applications")
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Development Headers")
IF(NOT WIN32)
SET(CPACK_COMPONENT_MANUALS_DISPLAY_NAME "Example Applications Manuals")
SET(CPACK_COMPONENT_MANUALS_DISABLED TRUE)
SET(CPACK_COMPONENT_MANUALS_DEPENDS examples)
ENDIF(NOT WIN32)
SET(CPACK_COMPONENT_HEADERS_DISABLED TRUE)
SET(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries)
# Source Package
IF(WIN32)
SET(CPACK_SOURCE_GENERATOR "ZIP")
ELSE(WIN32)
SET(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
ENDIF(WIN32)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "libnfc-${VERSION}")
SET(CPACK_SOURCE_IGNORE_FILES "~$" "/\\\\.svn/" "bin/")
INCLUDE(CPack)