forked from Nuand/bladeRF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
159 lines (130 loc) · 4.75 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Copyright 2013 Nuand, LLC.
#
# This file is part of the bladeRF project
#
# TODO license text here (see top-level COPYING for time being)
cmake_minimum_required(VERSION 2.8)
project(bladeRF-cli C)
################################################################################
# Version information
################################################################################
set(VERSION_INFO_MAJOR 0)
set(VERSION_INFO_MINOR 5)
set(VERSION_INFO_PATCH 0)
set(VERSION_INFO_EXTRA "git")
include(Version)
set(VERSION "${VERSION_INFO}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/src/version.h
@ONLY
)
################################################################################
# Configuration options
################################################################################
find_package(LibTecla)
option(ENABLE_LIBTECLA
"Enable the use of libtecla, if available."
${LIBTECLA_FOUND}
)
if(ENABLE_LIBTECLA)
message(STATUS "libtecla support enabled")
endif()
################################################################################
# Build dependencies
################################################################################
if(MSVC)
find_package(LibPThreadsWin32 REQUIRED)
else(MSVC)
find_package(Threads REQUIRED)
endif(MSVC)
################################################################################
# Include paths
################################################################################
set(CLI_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/cmd
${CMAKE_CURRENT_SOURCE_DIR}/src/interactive
${CMAKE_CURRENT_BINARY_DIR}/src
${BLADERF_HOST_COMMON_INCLUDE_DIRS}
${libbladeRF_SOURCE_DIR}/include
)
if(ENABLE_LIBTECLA)
set(CLI_INCLUDE_DIRS ${CLI_INCLUDE_DIRS} ${LIBTECLA_INCLUDE_DIR})
endif()
if(MSVC)
set(CLI_INCLUDE_DIRS ${CLI_INCLUDE_DIRS}
${BLADERF_HOST_COMMON_INCLUDE_DIRS}/windows
${LIBPTHREADSWIN32_INCLUDE_DIRS}
)
endif()
include_directories(${CLI_INCLUDE_DIRS})
################################################################################
# Configure source files
################################################################################
set(BLADERF_CLI_SOURCE
src/main.c
src/common.c
src/cmd/calibrate.c
src/cmd/cmd.c
src/cmd/erase.c
src/cmd/info.c
src/cmd/load.c
src/cmd/open.c
src/cmd/peek.c
src/cmd/peekpoke.c
src/cmd/poke.c
src/cmd/printset.c
src/cmd/probe.c
src/cmd/rxtx.c
src/cmd/version.c
src/cmd/recover.c
src/cmd/jump_boot.c
src/interactive/interactive.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/log.c
)
# Select the interactive mode (and script handling) backend
if(ENABLE_LIBTECLA)
set(BLADERF_CLI_SOURCE ${BLADERF_CLI_SOURCE} src/interactive/tecla.c)
else()
set(BLADERF_CLI_SOURCE ${BLADERF_CLI_SOURCE} src/interactive/fgets.c)
endif()
if(MSVC)
set(BLADERF_CLI_SOURCE ${BLADERF_CLI_SOURCE}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c
)
endif()
add_executable(bladeRF-cli ${BLADERF_CLI_SOURCE})
################################################################################
# Build configuration
################################################################################
set(CLI_LINK_LIBRARIES
libbladerf_shared
${CMAKE_THREAD_LIBS_INIT}
)
if(ENABLE_LIBTECLA)
# CLI_LINK_LIBRARIES_EXTRA is here for a workaround for the following issue
set(CLI_LINK_LIBRARIES ${CLI_LINK_LIBRARIES} ${LIBTECLA_LIBRARIES} ${CLI_LINK_LIBRARIES_EXTRA})
# On a few tests Linux distros, libtecla is not build against
# ncurses. However, folks have reported that builds on OSX use it
if(CMAKE_HOST_APPLE)
set(CLI_LINK_LIBRARIES ${CLI_LINK_LIBRARIES} ncurses)
endif(CMAKE_HOST_APPLE)
endif(ENABLE_LIBTECLA)
if(LIBPTHREADSWIN32_FOUND)
set(CLI_LINK_LIBRARIES ${CLI_LINK_LIBRARIES} ${LIBPTHREADSWIN32_LIBRARIES})
endif()
target_link_libraries(bladeRF-cli ${CLI_LINK_LIBRARIES})
################################################################################
# Installation
################################################################################
if(NOT DEFINED BIN_INSTALL_DIR)
set(BIN_INSTALL_DIR bin)
endif()
install(TARGETS bladeRF-cli DESTINATION ${BIN_INSTALL_DIR})
################################################################################
# Informational output
################################################################################
message(STATUS "Configured to build bladeRF-cli version: ${VERSION_INFO}")