-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
84 lines (76 loc) · 1.92 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
project (ejtagproxy C)
cmake_minimum_required (VERSION 2.4)
#
# Extract Git revision number
#
FIND_PACKAGE(Git)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
OUTPUT_VARIABLE GITCOUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
cmake_policy (SET CMP0005 OLD)
message ("Build ejtagproxy revision r${GITCOUNT} on ${CMAKE_SYSTEM_NAME}")
message ("Compiler is ${CMAKE_C_COMPILER}")
# Compilation flags
set (CMAKE_C_FLAGS_DEBUG "-Wall")
#set (CMAKE_BUILD_TYPE DEBUG)
set (CMAKE_BUILD_TYPE release)
#
# Mac OS X: need IOKit
#
if (APPLE)
set (HID_SRC hidapi/hid-mac.c)
find_library (IOKIT_LIB IOKit)
find_library (COREFOUNDATION_LIB CoreFoundation)
message (STATUS "Found IOKit framework: ${IOKIT_LIB}")
#
# Linux: need libusb-1.0
#
elseif (UNIX)
set (HID_SRC hidapi/hid-libusb.c)
find_library (USB_LIB usb-1.0)
find_library (PTHREAD_LIB pthread)
message (STATUS "Found USB library: ${USB_LIB}")
endif()
#
# FT2232-based adapters: Olimex ARM-USB-Tiny and others.
# Need legacy libusb-0.1 library.
#
find_path (USBLEGACY_H usb.h
/usr/include
/opt/local/include/libusb-legacy
)
find_library (USBLEGACY_LIB
NAMES usb usb-legacy
PATHS /usr/lib
/opt/local/lib/libusb-legacy
)
if (USBLEGACY_LIB AND USBLEGACY_H)
add_definitions (-DUSE_MPSSE)
set (MPSSE_SRC adapter-mpsse.c)
message (STATUS "Found legacy USB library: ${USBLEGACY_LIB}")
else()
message (STATUS "Legacy USB library not found: support for FTDI adapters disabled")
endif()
#
# Configure the target executable
#
add_definitions (-DGITCOUNT='"${GITCOUNT}"')
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/hidapi ${USBLEGACY_H})
add_executable (ejtagproxy
gdbproxy.c
rpmisc.c
target-ejtag.c
${HID_SRC}
proxy-mips.c
adapter-pickit2.c
${MPSSE_SRC}
)
target_link_libraries (ejtagproxy
${USB_LIB}
${USBLEGACY_LIB}
${PTHREAD_LIB}
${IOKIT_LIB}
${COREFOUNDATION_LIB}
)