forked from analogdevicesinc/scopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·382 lines (316 loc) · 12.2 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# Copyright (c) 2019 Analog Devices Inc.
#
# This file is part of Scopy
# (see http://www.github.com/analogdevicesinc/scopy).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
project(scopy LANGUAGES CXX VERSION 1.1.2)
set(Python_ADDITIONAL_VERSIONS 3)
FIND_PACKAGE(PythonInterp REQUIRED)
set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
# Get the GIT hash of the latest commit
include(FindGit OPTIONAL)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE SCOPY_GIT_REPO
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (${SCOPY_GIT_REPO} MATCHES ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE SCOPY_VERSION_GIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
if (NOT SCOPY_VERSION_GIT)
set(SCOPY_VERSION_GIT v${PROJECT_VERSION})
endif()
# Set .exe properties
if (WIN32)
string(REPLACE "." "," SCOPY_FILEVERSION ${PROJECT_VERSION})
set(SCOPY_PRODUCTVERSION_STR ${PROJECT_VERSION})
string(TIMESTAMP BUILD_YEAR "%Y")
endif()
if (MSVC)
# http://www.suodenjoki.dk/us/archive/2010/min-max.htm
add_definitions(-DNOMINMAX)
# http://www.qtcentre.org/threads/32028-unresolved-external-symbol-quot-public-static-struct-QMetaObject-const-QwtPlot-staticMe
add_definitions(-DQWT_DLL)
endif (MSVC)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
#set(CMAKE_AUTOUIC ON) - Can't figure out how to configure it to look under ui/
# for the .ui file. Use qt5_wrap_ui instead.
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release RelWithDebInfo MinSizeRel)
endif()
if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_definitions(-DQT_NO_DEBUG_OUTPUT=1)
endif()
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_constexpr OUT_CONSTEXPR)
if (NOT "${OUT_CONSTEXPR}" STREQUAL "-1")
add_definitions(-DHAS_CONSTEXPR=1)
endif()
option(BREAKPAD_HANDLER "Build with breakpad exception handler " OFF)
if (${BREAKPAD_HANDLER})
set(BREAKPAD_HANDLER_BOOL 1)
find_library(BREAKPAD_LIBRARIES NAMES breakpad)
find_library(BREAKPADCLIENT_LIBRARIES NAMES breakpad_client)
find_path(BREAKPAD_INCLUDE_DIRS breakpad)
else()
set(BREAKPAD_HANDLER_BOOL 0)
SET(BREAKPAD_LIBRARIES "")
SET(BREAKPAD_INCLUDE_DIRS "")
SET(BREAKPADCLIENT_LIBRARIES "")
endif()
find_package(Qt5Widgets REQUIRED)
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Qwt REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5UiTools REQUIRED)
find_package(Qt5Xml REQUIRED)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
find_package(Gnuradio "3.8" REQUIRED COMPONENTS runtime analog blocks fft filter volk pmt )
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};/usr/local/lib/cmake)
find_package(gnuradio-iio REQUIRED PATH_SUFFIXES iio)
find_package(gnuradio-scopy REQUIRED PATH_SUFFIXES scopy)
find_package(gnuradio-m2k REQUIRED PATH_SUFFIXES m2k)
add_definitions(-DBOOST_ALL_DYN_LINK)
find_package(Boost COMPONENTS system filesystem thread REQUIRED)
set(VC_PATH "$ENV{VS120COMNTOOLS}/../../VC")
find_library(IIO_LIBRARIES NAMES iio libiio PATHS ${VC_PATH}/lib ${VC_PATH}/lib/amd64)
find_library(M2K_LIBRARIES NAMES m2k libm2k)
find_library(MATIO_LIBRARIES NAMES matio)
find_path(IIO_INCLUDE_DIRS iio.h PATHS ${VC_PATH}/include)
find_path(M2K_INCLUDE_DIRS libm2k/m2k.hpp)
find_library(QWTPOLAR_LIBRARIES qwtpolar)
find_path(QWTPOLAR_INCLUDE_DIRS qwt_polar_plot.h PATH_SUFFIXES qwt)
if (NOT QWTPOLAR_LIBRARIES OR NOT QWTPOLAR_INCLUDE_DIRS)
message(SEND_ERROR "QwtPolar not found")
endif()
find_package(PkgConfig)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GLIBMM REQUIRED glibmm-2.4)
pkg_check_modules(SIGCPP REQUIRED sigc++-2.0)
pkg_check_modules(LIBSIGROK REQUIRED libsigrok)
pkg_check_modules(LIBSIGROKCXX REQUIRED libsigrokcxx)
pkg_check_modules(LIBSIGROK_DECODE REQUIRED libsigrokdecode)
message(CMAKE_PATH ${CMAKE_PREFIX_PATH})
include_directories(
${Boost_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Concurrent_INCLUDE_DIRS}
${Qt5Qml_INCLUDE_DIRS}
${Qt5UiTools_INCLUDE_DIRS}
${QWT_INCLUDE_DIRS}
${QWTPOLAR_INCLUDE_DIRS}
${Qt5Svg_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS}
${IIO_INCLUDE_DIRS}
${SCOPY_INCLUDE_DIRS}
${LIBSIGROK_DECODE_INCLUDE_DIRS}
${LIBSIGROKCXX_INCLUDE_DIRS}
${LIBSIGROK_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${GLIBCONFIG_INCLUDE_DIRS}
${GLIBMM_INCLUDE_DIRS}
${GLIBMMCONFIG_INCLUDE_DIRS}
${SIGCPP_INCLUDE_DIRS}
${SIGCPPCONFIG_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src
${BREAKPAD_INCLUDE_DIRS}
${BREAKPAD_INCLUDE_DIRS}/breakpad
${M2K_INCLUDE_DIRS}
)
link_directories(
${Boost_LIBRARY_DIRS}
${GNURADIO_RUNTIME_LIBRARY_DIRS}
${BREAKPAD_LIBRARIES}
)
FILE(GLOB SRC_LIST src/*.cpp src/*.cc
src/pulseview/pv/*.cpp
src/pulseview/pv/binding/*.cpp
src/pulseview/pv/data/*.cpp
src/pulseview/pv/data/decode/*.cpp
src/pulseview/pv/devices/*.cpp
src/pulseview/pv/dialogs/*.cpp
src/pulseview/pv/popups/*.cpp
src/pulseview/pv/prop/*.cpp
src/pulseview/pv/toolbars/*.cpp
src/pulseview/pv/view/*.cpp
src/pulseview/pv/widgets/*.cpp
)
FILE(GLOB M2KSCOPE_UIS ui/patterns/*.ui ui/*.ui src/pulseview/pv/dialogs/*.ui)
qt5_wrap_ui (m2kscope_FORMS_HEADERS ${M2KSCOPE_UIS})
FILE(GLOB M2KSCOPE_RESOURCES resources/*.qrc)
qt5_add_resources(m2kscope_RESOURCES ${M2KSCOPE_RESOURCES})
if (WIN32)
set(RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/resources/properties.rc)
configure_file(properties.rc.cmakein ${RESOURCES} @ONLY)
endif()
add_definitions(-DQT_NO_KEYWORDS)
if (APPLE)
option(ENABLE_APPLICATION_BUNDLE "Enable application bundle for OSX" ON)
endif(APPLE)
if (ENABLE_APPLICATION_BUNDLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
set(PKGINFO ${CMAKE_BINARY_DIR}/PkgInfo)
file(WRITE ${PKGINFO} "APPLScopy")
set_source_files_properties(${PKGINFO} PROPERTIES MACOSX_PACKAGE_LOCATION .)
set(QT_CONF ${CMAKE_BINARY_DIR}/qt.conf)
file(WRITE ${QT_CONF} "")
set_source_files_properties(${QT_CONF} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(ICON_FILE ${CMAKE_SOURCE_DIR}/resources/Scopy.icns)
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-headerpad_max_install_names -Wl,-search_paths_first ${CMAKE_EXE_LINKER_FLAGS}")
foreach(plugin ${Qt5Gui_PLUGINS} ${Qt5Svg_PLUGINS})
get_target_property(_loc ${plugin} LOCATION)
get_filename_component(_name ${_loc} NAME)
get_filename_component(_dir ${_loc} DIRECTORY)
get_filename_component(_dir ${_dir} NAME)
set_source_files_properties(${_loc} PROPERTIES MACOSX_PACKAGE_LOCATION plugins/${_dir})
set(QT_PLUGINS ${QT_PLUGINS} ${_loc})
set(BUNDLED_QT_PLUGINS ${BUNDLED_QT_PLUGINS} ${CMAKE_BINARY_DIR}/Scopy.app/Contents/plugins/${_dir}/${_name})
endforeach()
file(GLOB_RECURSE DECODERS ${CMAKE_SOURCE_DIR}/resources/decoders/*.py)
foreach(_decoder ${DECODERS})
file(RELATIVE_PATH _file ${CMAKE_SOURCE_DIR}/resources ${_decoder})
get_filename_component(_path ${_file} DIRECTORY)
set_source_files_properties(${_decoder} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/${_path})
endforeach()
install(CODE "
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities)
fixup_bundle(\"${CMAKE_BINARY_DIR}/Scopy.app\" \"${BUNDLED_QT_PLUGINS}\" \"${CMAKE_SOURCE_DIR}\")"
)
set(OSX_BUNDLE MACOSX_BUNDLE)
set(EXTRA_BUNDLE_FILES ${QT_PLUGINS} ${ICON_FILE} ${PKGINFO} ${QT_CONF} ${DECODERS})
endif()
FILE(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/resources/*.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/resources/languages)
# Creates translation .ts files from ${CMAKE_SOURCE_DIR}
#qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
# Generate .qm files from the .ts files
qt5_add_translation(QM_FILES ${TS_FILES})
add_executable(${PROJECT_NAME} WIN32 ${OSX_BUNDLE}
${SRC_LIST}
${RESOURCES}
${m2kscope_RESOURCES}
${m2kscope_FORMS_HEADERS}
${EXTRA_BUNDLE_FILES}
${TS_FILES}
${QM_FILES}
)
if (WIN32 OR ENABLE_APPLICATION_BUNDLE)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME Scopy)
endif()
target_link_libraries(${PROJECT_NAME} LINK_PRIVATE
${BREAKPAD_LIBRARIES}
${BREAKPADCLIENT_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt5Concurrent_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5UiTools_LIBRARIES}
gnuradio::gnuradio-runtime
gnuradio::gnuradio-analog
gnuradio::gnuradio-blocks
gnuradio::gnuradio-fft
gnuradio::gnuradio-filter
gnuradio::gnuradio-pmt
gnuradio::gnuradio-iio
gnuradio::gnuradio-scopy
gnuradio::gnuradio-m2k
${Boost_LIBRARIES}
${QWT_LIBRARIES}
${QWTPOLAR_LIBRARIES}
${Qt5Svg_LIBRARIES}
${Qt5Xml_LIBRARIES}
${IIO_LIBRARIES}
${MATIO_LIBRARIES}
${LIBSIGROK_LIBRARIES}
${LIBSIGROKCXX_LIBRARIES}
${LIBSIGROK_DECODE_LIBRARIES}
${GLIBMM_LIBRARIES}
${SIGCPP_LIBRARIES}
${GLIB_LIBRARIES}
${M2K_LIBRARIES}
)
if (NOT WIN32)
find_library(PTHREAD_LIBRARIES pthread)
if (PTHREAD_LIBRARIES)
target_link_libraries(${PROJECT_NAME} LINK_PRIVATE ${PTHREAD_LIBRARIES})
endif()
endif()
configure_file(Info.plist.cmakein ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY)
option(WITH_NATIVEDIALOGS "Enable native file dialogs for Scopy" ON)
if (NOT ${WITH_NATIVEDIALOGS})
add_definitions(-DNONATIVE)
endif()
# Compiler options
target_compile_options(${PROJECT_NAME} PUBLIC -Wall)
#List of warnings to be treated as errors
target_compile_options(${PROJECT_NAME} PUBLIC
-Werror=return-type
-Werror=uninitialized
-Werror=init-self
-Werror=switch
)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
)
set(CMAKE_INSTALL_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
find_package(Doxygen)
if(DOXYGEN_FOUND)
option(WITH_DOC "Generate documentation with Doxygen" ON)
if (WITH_DOC)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile_API.in ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
set(HTML_DEST_DIR ${CMAKE_CURRENT_BINARY_DIR})
#file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc DESTINATION ${HTML_DEST_DIR})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
if(NOT SKIP_INSTALL_ALL)
install(DIRECTORY ${HTML_DEST_DIR} DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif()
endif()
else()
message(STATUS "Doxygen not found, API documentation won't be generated")
endif()
configure_file(scopy.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/scopy.iss @ONLY)
configure_file(scopy-32.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/scopy-32.iss @ONLY)
configure_file(scopy-64.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/scopy-64.iss @ONLY)
configure_file(config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
if (NOT ENABLE_APPLICATION_BUNDLE)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/scopy.desktop.cmakein ${CMAKE_CURRENT_BINARY_DIR}/scopy.desktop @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/scopy.desktop DESTINATION share/applications)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/icon_small.svg DESTINATION share/icons/hicolor/apps/scalable RENAME scopy.svg)
endif()
configure_file(qt.conf.cmakein ${CMAKE_CURRENT_BINARY_DIR}/qt.conf @ONLY)