-
Notifications
You must be signed in to change notification settings - Fork 27
/
CMakeLists.txt
159 lines (133 loc) · 5.21 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
project(libxtrx C)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
cmake_minimum_required(VERSION 2.8)
# Set the version information here
set(MAJOR_VERSION 0)
set(API_COMPAT 0)
set(MINOR_VERSION 1)
set(MAINT_VERSION 2)
set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}")
# determine target architecture
execute_process(COMMAND ${CMAKE_C_COMPILER} -print-multiarch OUTPUT_VARIABLE CC_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CC_ARCH MATCHES "i386")
message(STATUS "Building for i386")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
set(ARCH "x86")
elseif(CC_ARCH MATCHES "x86_64")
message(STATUS "Building for x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(ARCH "x86")
elseif(CC_ARCH MATCHES "aarch64")
message(STATUS "Building for aarch64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
set(ARCH "arm")
elseif(CC_ARCH MATCHES "arm.*eabihf")
message(STATUS "Building for armhf")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
set(ARCH "arm")
else()
message(WARNING "Unknown target architecture ${CC_ARCH}, forcing to FORCE_ARCH=${FORCE_ARCH} variable if it was provided")
set(ARCH ${FORCE_ARCH})
endif()
set(CROSS_COMPILE_INCLUDE_PATH "/usr/${CC_ARCH}/include")
set(CROSS_COMPILE_LIB_PATH "/usr/${CC_ARCH}/lib")
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(SYSTEM_LIBS rt dl pthread)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(SYSTEM_LIBS "")
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_SHARED_LINKER_FLAGS " -Wl,--kill-at -static-libgcc ")
endif(CMAKE_COMPILER_IS_GNUCC)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(SYSTEM_LIBS rt dl pthread)
else()
message(WARNING "Unknown system type is ${CMAKE_SYSTEM_NAME}")
endif()
add_definitions(-Wall -g)
set(XTRX_LIBRARY_DIR lib${LIB_SUFFIX})
set(XTRX_INCLUDE_DIR include)
set(XTRX_UTILS_DIR ${XTRX_LIBRARY_DIR}/xtrx)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/libxtrx.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libxtrx.pc
@ONLY)
INSTALL(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxtrx.pc
DESTINATION ${XTRX_LIBRARY_DIR}/pkgconfig)
# Report all undfined symbols in shared libraries
if(CMAKE_COMPILER_IS_GNUCC)
add_definitions("-Wl,-z,defs")
endif(CMAKE_COMPILER_IS_GNUCC)
find_package(libxtrxdsp REQUIRED)
find_package(libxtrxll REQUIRED)
find_package(liblms7compact REQUIRED)
include_directories(${LIBXTRXDSP_INCLUDE_DIRS})
include_directories(${LIBXTRXLL_INCLUDE_DIRS})
include_directories(${LIBLMS7COMPACT_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_library(xtrx SHARED
xtrx.c
xtrx_debug.c
xtrx_fe.c
xtrx_fe_nlms7.c
xtrx_fe_octorx0.c
xtrx_fe_octocal0.c
octo/adf4355.c
)
target_link_libraries(xtrx ${LIBXTRXLL_LIBRARIES} ${LIBXTRXDSP_LIBRARIES} ${LIBLMS7COMPACT_LIBRARIES} m)
set_target_properties(xtrx PROPERTIES VERSION ${LIBVER} SOVERSION ${MAJOR_VERSION})
add_executable(test_xtrx test_xtrx.c)
target_link_libraries(test_xtrx xtrx ${SYSTEM_LIBS})
########################################################################
# XTRX QT examples
########################################################################
find_package(Qt5Widgets)
find_package(Qt5PrintSupport)
find_package(QCustomPlot)
if(Qt5Widgets_FOUND AND Qt5PrintSupport_FOUND AND QCustomPlot_FOUND)
set(LIBXTRX_FOUND TRUE "libxtrx found")
set(LIBXTRX_LIBRARIES xtrx)
set(LIBXTRX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(examples/xtrx_fft)
endif()
########################################################################
# install libraries
########################################################################
install(TARGETS xtrx DESTINATION ${XTRX_LIBRARY_DIR})
install(TARGETS test_xtrx DESTINATION ${XTRX_UTILS_DIR})
########################################################################
# install headers
########################################################################
install(FILES
xtrx_api.h
DESTINATION ${XTRX_INCLUDE_DIR})
option(ENABLE_SOAPY "Enable SOAPY plugin for XTRX" ON)
if(ENABLE_SOAPY)
find_package(SoapySDR)
if(SoapySDR_FOUND)
add_subdirectory(soapy)
else()
message(WARNING "SoapySDR hasn't been found -- ignoring SOAPY plugin")
endif()
endif(ENABLE_SOAPY)
########################################################################
# package generator
########################################################################
if(NOT CPACK_GENERATOR)
set(CPACK_GENERATOR DEB)
endif()
set(CPACK_PACKAGE_NAME "libxtrx")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "XTRX API library")
set(CPACK_PACKAGE_VENDOR "Fairwaves, Inc.")
set(CPACK_PACKAGE_CONTACT "http://fairwaves.co/wp/contact-us/")
set(CPACK_PACKAGE_VERSION ${LIBVER}-${MAINT_VERSION})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.17), libxtrxll (>= 0.0.1), libxtrxdsp (>= 0.0.1), liblms7002m (>= 0.0.1)")
if(ENABLE_SOAPY)
# TODO: need a dependency for correct soapy version
# set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, soapysdr (>= 0.5.2)")
endif(ENABLE_SOAPY)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
set(CPACK_SET_DESTDIR "")
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGE_CONTACT "Sergey Kostanbaev <[email protected]>")
include(CPack) #include last