2020-02-02 12:38:59 +00:00
|
|
|
cmake_minimum_required(VERSION 3.2)
|
2015-11-11 14:32:48 +00:00
|
|
|
|
|
|
|
# Project name
|
|
|
|
project(gqrx)
|
|
|
|
set(${PROJECT_NAME}_MAJOR "2")
|
2023-10-01 19:07:08 +00:00
|
|
|
set(${PROJECT_NAME}_MINOR "17")
|
2023-10-10 00:47:54 +00:00
|
|
|
set(${PROJECT_NAME}_PATCH "2")
|
2023-10-10 02:16:33 +00:00
|
|
|
set(IS_RELEASE FALSE)
|
2020-11-20 02:40:12 +00:00
|
|
|
|
|
|
|
if(IS_RELEASE)
|
|
|
|
if(${PROJECT_NAME}_PATCH EQUAL 0)
|
|
|
|
set(VERSION "${${PROJECT_NAME}_MAJOR}.${${PROJECT_NAME}_MINOR}")
|
|
|
|
else()
|
|
|
|
set(VERSION "${${PROJECT_NAME}_MAJOR}.${${PROJECT_NAME}_MINOR}.${${PROJECT_NAME}_PATCH}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
execute_process(
|
|
|
|
COMMAND git describe --long --dirty
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE VERSION
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_definitions(-DVERSION="${VERSION}")
|
2023-10-04 03:24:54 +00:00
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/version.txt ${VERSION})
|
2016-01-07 15:52:03 +00:00
|
|
|
|
|
|
|
set(PACKAGE ${PROJECT_NAME})
|
2015-11-11 14:32:48 +00:00
|
|
|
|
|
|
|
########### Main global variables ###########
|
2015-11-12 22:56:39 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug GProf Valgrind Release" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(BUILDTYPE ${CMAKE_BUILD_TYPE})
|
|
|
|
string(TOUPPER ${BUILDTYPE} BUILDTYPE)
|
|
|
|
add_definitions(-D${BUILDTYPE})
|
2015-11-11 14:32:48 +00:00
|
|
|
|
|
|
|
# We have some custom .cmake scripts not in the official distribution.
|
2015-11-22 23:25:53 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
2015-11-11 14:32:48 +00:00
|
|
|
|
|
|
|
# Add valgrind build options if necessary
|
2015-12-21 22:04:59 +00:00
|
|
|
if(${CMAKE_BUILD_TYPE} MATCHES "Valgrind")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
|
|
|
|
endif()
|
2015-11-11 14:32:48 +00:00
|
|
|
|
2020-01-26 10:13:34 +00:00
|
|
|
# Workaround for naming collision with log4cpp for Debug builds
|
|
|
|
add_definitions(-DLOG4CPP_FIX_ERROR_COLLISION=1)
|
|
|
|
|
2015-11-18 21:08:24 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
# using regular Clang or AppleClang
|
2015-12-21 22:04:59 +00:00
|
|
|
set(CMAKE_COMPILER_IS_CLANGXX 1)
|
2015-11-18 21:08:24 +00:00
|
|
|
endif()
|
|
|
|
|
2015-12-21 22:04:59 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
|
|
|
|
add_definitions(-Wall)
|
|
|
|
add_definitions(-Wextra)
|
2023-06-23 22:46:19 +00:00
|
|
|
add_definitions(-Wdouble-promotion)
|
2015-12-21 22:04:59 +00:00
|
|
|
add_definitions(-Wno-unused-parameter)
|
|
|
|
add_definitions(-Wsign-compare)
|
|
|
|
endif()
|
2015-11-18 21:08:24 +00:00
|
|
|
|
2016-01-25 20:02:03 +00:00
|
|
|
if(MSVC)
|
|
|
|
#get math definitions like M_PI
|
|
|
|
add_definitions(-D_USE_MATH_DEFINES)
|
|
|
|
|
|
|
|
#use std::min()/std::max()
|
|
|
|
add_definitions(-DNOMINMAX)
|
|
|
|
|
|
|
|
#needed to dynamically link boost
|
|
|
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
|
|
|
|
|
|
|
#export gr-rds symbols
|
|
|
|
add_definitions(-Dgnuradio_RDS_EXPORTS)
|
|
|
|
|
|
|
|
if ("${MSVC_VERSION}" VERSION_LESS "1900")
|
|
|
|
add_definitions(-D__func__=__FUNCTION__)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-11-11 14:32:48 +00:00
|
|
|
# Functions & macros. These must be defined before including subdirectories.
|
|
|
|
|
|
|
|
# function to collect all the sources from sub-directories
|
|
|
|
# into a single list
|
|
|
|
function(add_source_files list)
|
2015-11-11 16:16:42 +00:00
|
|
|
get_property(is_defined GLOBAL PROPERTY SRCS_LIST DEFINED)
|
|
|
|
if(NOT is_defined)
|
|
|
|
define_property(GLOBAL PROPERTY ${list}
|
|
|
|
BRIEF_DOCS "List of source files"
|
|
|
|
FULL_DOCS "List of source files to be compiled in one library")
|
|
|
|
endif()
|
|
|
|
# make absolute paths
|
|
|
|
set(SRCS)
|
|
|
|
foreach(s IN LISTS ARGN)
|
|
|
|
if(NOT IS_ABSOLUTE "${s}")
|
|
|
|
get_filename_component(s "${s}" ABSOLUTE)
|
|
|
|
endif()
|
|
|
|
list(APPEND SRCS "${s}")
|
|
|
|
endforeach()
|
|
|
|
# append to global list
|
|
|
|
set_property(GLOBAL APPEND PROPERTY ${list} "${SRCS}")
|
2015-11-11 14:32:48 +00:00
|
|
|
endfunction(add_source_files)
|
|
|
|
|
2018-10-20 13:11:50 +00:00
|
|
|
if(APPLE AND EXISTS /usr/local/opt/qt5)
|
|
|
|
# Homebrew installs Qt5 (up to at least 5.9.1) in
|
2022-01-26 01:48:01 +00:00
|
|
|
# /usr/local/opt/qt5, ensure it can be found by CMake since
|
2018-10-20 13:11:50 +00:00
|
|
|
# it is not in the default /usr/local prefix.
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
|
|
|
|
endif()
|
2015-11-11 14:32:48 +00:00
|
|
|
|
2022-01-26 01:48:01 +00:00
|
|
|
if(APPLE AND EXISTS /usr/local/opt/qt6)
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt6")
|
|
|
|
endif()
|
|
|
|
|
2020-12-27 12:18:29 +00:00
|
|
|
if(APPLE AND EXISTS /usr/local/opt/icu4c/lib)
|
|
|
|
# With Homebrew icu4c, `-licudata -licui18n -licuuc`
|
|
|
|
# are required, which reside in /usr/local/opt/icu4c/lib.
|
|
|
|
# See src/CMakeFiles/gqrx.dir/link.txt in the build directory.
|
|
|
|
set(ICU4C_LIBRARY_DIRS "/usr/local/opt/icu4c/lib")
|
|
|
|
else()
|
|
|
|
set(ICU4C_LIBRARY_DIRS "")
|
|
|
|
endif()
|
|
|
|
|
2015-11-11 14:32:48 +00:00
|
|
|
# 3rd Party Dependency Stuff
|
2023-10-09 22:17:12 +00:00
|
|
|
option(FORCE_QT6 "Force Qt6 to be used" OFF)
|
|
|
|
option(FORCE_QT5 "Force Qt5 to be used" OFF)
|
|
|
|
|
|
|
|
if(FORCE_QT6)
|
|
|
|
find_package(Qt6 QUIET COMPONENTS Core Network Widgets Svg SvgWidgets)
|
|
|
|
elseif(FORCE_QT5)
|
2022-01-26 01:48:01 +00:00
|
|
|
find_package(Qt5 REQUIRED COMPONENTS Core Network Widgets Svg)
|
2023-10-09 22:17:12 +00:00
|
|
|
else()
|
|
|
|
find_package(Qt6 QUIET COMPONENTS Core Network Widgets Svg SvgWidgets)
|
|
|
|
if(NOT Qt6_FOUND)
|
|
|
|
find_package(Qt5 REQUIRED COMPONENTS Core Network Widgets Svg)
|
|
|
|
endif()
|
2022-01-26 01:48:01 +00:00
|
|
|
endif()
|
2023-10-09 22:17:12 +00:00
|
|
|
|
2021-03-21 06:55:12 +00:00
|
|
|
include(FindPkgConfig)
|
2015-11-11 14:32:48 +00:00
|
|
|
find_package(Gnuradio-osmosdr REQUIRED)
|
2015-11-17 06:24:12 +00:00
|
|
|
|
2019-10-06 23:05:15 +00:00
|
|
|
set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG AUDIO BLOCKS DIGITAL FILTER FFT PMT)
|
2021-09-30 15:14:34 +00:00
|
|
|
find_package(Gnuradio REQUIRED COMPONENTS analog audio blocks digital filter fft network)
|
2019-10-06 23:05:15 +00:00
|
|
|
if(NOT Gnuradio_FOUND)
|
2017-03-02 22:55:37 +00:00
|
|
|
message(FATAL_ERROR "GnuRadio Runtime required to compile gqrx")
|
2015-11-17 06:24:12 +00:00
|
|
|
endif()
|
|
|
|
|
2022-01-19 02:24:45 +00:00
|
|
|
find_package(Volk)
|
2019-10-07 00:38:49 +00:00
|
|
|
|
|
|
|
# Pass the GNU Radio version as 0xMMNNPP BCD.
|
|
|
|
math(EXPR GNURADIO_BCD_VERSION
|
|
|
|
"(${Gnuradio_VERSION_MAJOR} / 10) << 20 |
|
|
|
|
(${Gnuradio_VERSION_MAJOR} % 10) << 16 |
|
|
|
|
(${Gnuradio_VERSION_MINOR} / 10) << 12 |
|
|
|
|
(${Gnuradio_VERSION_MINOR} % 10) << 8 |
|
|
|
|
(${Gnuradio_VERSION_PATCH} / 10) << 4 |
|
|
|
|
(${Gnuradio_VERSION_PATCH} % 10) << 0
|
|
|
|
"
|
|
|
|
)
|
|
|
|
add_definitions(-DGNURADIO_VERSION=${GNURADIO_BCD_VERSION})
|
|
|
|
|
2020-12-05 17:20:19 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
|
2015-12-21 22:04:59 +00:00
|
|
|
if(NOT LINUX_AUDIO_BACKEND)
|
2018-03-13 23:19:45 +00:00
|
|
|
set(LINUX_AUDIO_BACKEND Pulseaudio CACHE STRING "Choose the audio backend, options are: Pulseaudio, Portaudio, Gr-audio" FORCE)
|
2015-12-21 22:04:59 +00:00
|
|
|
endif()
|
2015-12-13 15:24:31 +00:00
|
|
|
|
2015-12-21 22:04:59 +00:00
|
|
|
if(${LINUX_AUDIO_BACKEND} MATCHES "Pulseaudio")
|
2020-12-05 17:20:45 +00:00
|
|
|
message(STATUS "Pulseaudio backend enabled")
|
2015-12-13 15:24:31 +00:00
|
|
|
find_package(PulseAudio REQUIRED)
|
|
|
|
# there is a defect in the pulse audio cmake file that does not include this library. So we add it here.
|
|
|
|
find_library(PULSE-SIMPLE NAMES pulse-simple REQUIRED)
|
2015-12-21 22:04:59 +00:00
|
|
|
add_definitions(-DWITH_PULSEAUDIO)
|
2016-09-04 21:30:06 +00:00
|
|
|
unset(PORTAUDIO_INCLUDE_DIRS CACHE)
|
|
|
|
unset(PORTAUDIO_LIBRARIES CACHE)
|
|
|
|
elseif(${LINUX_AUDIO_BACKEND} MATCHES "Portaudio")
|
2020-12-05 17:20:45 +00:00
|
|
|
message(STATUS "Portaudio backend enabled")
|
2023-04-14 03:11:26 +00:00
|
|
|
find_package(PORTAUDIO REQUIRED)
|
2016-09-04 21:30:06 +00:00
|
|
|
add_definitions(-DWITH_PORTAUDIO)
|
|
|
|
unset(PULSEAUDIO_FOUND CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_LIBRARY CACHE)
|
|
|
|
unset(PulseAudio_DIR CACHE)
|
|
|
|
unset(PULSE-SIMPLE CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_MAINLOOP_LIBRARY CACHE)
|
2015-12-21 22:04:59 +00:00
|
|
|
elseif(${LINUX_AUDIO_BACKEND} MATCHES "Gr-audio")
|
2020-12-05 17:20:45 +00:00
|
|
|
message(STATUS "Gr-audio backend enabled")
|
2015-12-21 22:04:59 +00:00
|
|
|
unset(PULSEAUDIO_FOUND CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_LIBRARY CACHE)
|
|
|
|
unset(PulseAudio_DIR CACHE)
|
|
|
|
unset(PULSE-SIMPLE CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_MAINLOOP_LIBRARY CACHE)
|
2016-09-04 21:30:06 +00:00
|
|
|
unset(PORTAUDIO_INCLUDE_DIRS CACHE)
|
|
|
|
unset(PORTAUDIO_LIBRARIES CACHE)
|
2015-12-21 22:04:59 +00:00
|
|
|
else()
|
2016-09-04 21:30:06 +00:00
|
|
|
message(FATAL_ERROR "Invalid audio backend: should be either Pulseaudio, Portaudio or Gr-audio")
|
2015-12-21 22:04:59 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2015-11-11 14:32:48 +00:00
|
|
|
|
2018-03-13 23:37:00 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
if(NOT OSX_AUDIO_BACKEND)
|
|
|
|
set(OSX_AUDIO_BACKEND Portaudio CACHE STRING "Choose the audio backend, options are: Portaudio and Gr-audio" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${OSX_AUDIO_BACKEND} MATCHES "Portaudio")
|
2020-12-15 13:23:21 +00:00
|
|
|
message(STATUS "Portaudio backend enabled")
|
2023-04-14 03:11:26 +00:00
|
|
|
find_package(PORTAUDIO REQUIRED)
|
2018-03-13 23:37:00 +00:00
|
|
|
add_definitions(-DWITH_PORTAUDIO)
|
|
|
|
unset(PULSEAUDIO_FOUND CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_LIBRARY CACHE)
|
|
|
|
unset(PulseAudio_DIR CACHE)
|
|
|
|
unset(PULSE-SIMPLE CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_MAINLOOP_LIBRARY CACHE)
|
|
|
|
elseif(${OSX_AUDIO_BACKEND} MATCHES "Gr-audio")
|
2020-12-15 13:23:21 +00:00
|
|
|
message(STATUS "Gr-audio backend enabled")
|
2018-03-13 23:37:00 +00:00
|
|
|
unset(PULSEAUDIO_FOUND CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_LIBRARY CACHE)
|
|
|
|
unset(PulseAudio_DIR CACHE)
|
|
|
|
unset(PULSE-SIMPLE CACHE)
|
|
|
|
unset(PULSEAUDIO_INCLUDE_DIR CACHE)
|
|
|
|
unset(PULSEAUDIO_MAINLOOP_LIBRARY CACHE)
|
|
|
|
unset(PORTAUDIO_INCLUDE_DIRS CACHE)
|
|
|
|
unset(PORTAUDIO_LIBRARIES CACHE)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Invalid audio backend: should be either Portaudio or Gr-audio")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-11 13:29:21 +00:00
|
|
|
|
|
|
|
# Airspy optimizations that require modified gr-osmosdr
|
2017-03-02 22:55:37 +00:00
|
|
|
option(CUSTOM_AIRSPY_KERNELS "Enable non-standard Airspy optimizations" ON)
|
2016-09-11 13:29:21 +00:00
|
|
|
if(CUSTOM_AIRSPY_KERNELS)
|
|
|
|
add_definitions(-DCUSTOM_AIRSPY_KERNELS)
|
|
|
|
endif(CUSTOM_AIRSPY_KERNELS)
|
|
|
|
|
|
|
|
|
2015-11-11 14:32:48 +00:00
|
|
|
# Tell CMake to run moc when necessary:
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
# As moc files are generated in the binary dir, tell CMake to always look for includes there:
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
# Finish configuring compiler / linker settings & flags
|
2015-11-17 06:24:12 +00:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_SOURCE_DIR}/include
|
2017-08-31 23:05:05 +00:00
|
|
|
${GNURADIO_OSMOSDR_INCLUDE_DIRS}
|
2015-11-17 06:24:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
link_directories(
|
|
|
|
${GNURADIO_RUNTIME_LIBRARY_DIRS}
|
2020-12-27 12:18:29 +00:00
|
|
|
${ICU4C_LIBRARY_DIRS}
|
2015-11-17 06:24:12 +00:00
|
|
|
)
|
|
|
|
|
2022-01-22 14:46:50 +00:00
|
|
|
# Install desktop
|
2022-01-23 14:42:12 +00:00
|
|
|
install(FILES dk.gqrx.gqrx.desktop DESTINATION share/applications)
|
2022-01-22 14:46:50 +00:00
|
|
|
|
|
|
|
# Install appstream / metainfo file
|
2022-01-23 14:42:12 +00:00
|
|
|
install(FILES dk.gqrx.gqrx.appdata.xml DESTINATION share/metainfo)
|
2022-01-22 14:46:50 +00:00
|
|
|
|
|
|
|
# Install icon
|
|
|
|
install(FILES resources/icons/gqrx.svg DESTINATION share/icons/hicolor/scalable/apps)
|
|
|
|
|
2015-11-11 14:32:48 +00:00
|
|
|
# Add subdirectories
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
2015-11-22 23:25:53 +00:00
|
|
|
# uninstall target
|
|
|
|
# https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
add_custom_target(uninstall
|
|
|
|
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
|
|
|
)
|