### Install Targets Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Installs the built libraries and executable to their designated locations. This makes the project's outputs available for use. ```cmake install ( TARGETS nrsc5 nrsc5_static RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include ) ``` -------------------------------- ### Test nrsc5 installation on Windows Source: https://github.com/theori-io/nrsc5/blob/master/README.md Tests the nrsc5 installation on Windows using a sample file after building with MSYS2. ```bash cd ~/nrsc5/support הראש -d sample.xz nrsc5.exe -r sample 0 ``` -------------------------------- ### Build nrsc5 on Ubuntu/Debian/Raspbian Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs dependencies, clones the repository, configures the build with CMake, and installs the program. ```bash sudo apt install git build-essential cmake autoconf libtool libao-dev libfftw3-dev librtlsdr-dev git clone https://github.com/theori-io/nrsc5.git cd nrsc5 mkdir build cd build cmake [options] .. make sudo make install sudo ldconfig ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Initializes the CMake build system and sets the project name and language. ```cmake cmake_minimum_required (VERSION 3.10) cmake_policy (VERSION 3.10...3.28) include (CheckLibraryExists) include (CheckSymbolExists) include (ExternalProject) include (FindPkgConfig) project (nrsc5 C) ``` -------------------------------- ### Build nrsc5 on openSUSE Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs openSUSE development patterns and packages for building nrsc5. ```bash zypper install -t pattern devel_C_C++ zypper install git cmake libao-devel fftw3-devel rtl-sdr-devel libusb-1_0-devel ``` -------------------------------- ### Basic Tuning and Playback Source: https://github.com/theori-io/nrsc5/blob/master/README.md Tune to a specific frequency and play audio program 0. This is the simplest way to start receiving a station. ```bash nrsc5 107.1 0 ``` -------------------------------- ### Build nrsc5 on Fedora Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs Fedora-specific development packages for building nrsc5. ```bash sudo dnf install git make patch cmake autoconf libtool libao-devel fftw-devel rtl-sdr-devel libusb1-devel ``` -------------------------------- ### Build nrsc5 on macOS using Homebrew Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs nrsc5 on macOS by cloning a Homebrew formula and installing from source. ```bash curl https://raw.githubusercontent.com/theori-io/nrsc5/master/nrsc5.rb > /tmp/nrsc5.rb brew install --HEAD -s /tmp/nrsc5.rb ``` -------------------------------- ### Build nrsc5 on Windows with MSYS2 Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs MSYS2, updates packages, clones the repository, and builds nrsc5 using a provided script. ```bash pacman -Syu pacman -Su pacman -S git git clone https://github.com/theori-io/nrsc5.git nrsc5/support/msys2-build -j4 ``` -------------------------------- ### Cross-compile nrsc5 for Windows from Ubuntu/Debian Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs cross-compilation tools and builds a Windows version of nrsc5 from a Linux environment. ```bash sudo apt install cmake autoconf libtool pkgconf git mingw-w64 git clone https://github.com/theori-io/nrsc5.git cd nrsc5 support/win-cross-compile 64 --cmake-args="-DUSE_SSE=ON" -j4 ``` -------------------------------- ### Cross-compile nrsc5 for Windows from macOS Source: https://github.com/theori-io/nrsc5/blob/master/README.md Installs cross-compilation tools and builds a Windows version of nrsc5 from a macOS environment. ```bash brew install cmake autoconf automake libtool pkgconf git mingw-w64 git clone https://github.com/theori-io/nrsc5.git cd nrsc5 support/win-cross-compile 64 --cmake-args="-DUSE_SSE=ON" -j4 ``` -------------------------------- ### Advanced Tuning with Gain and IQ Output Source: https://github.com/theori-io/nrsc5/blob/master/README.md Tune to a specific frequency, manually set the gain, and save raw IQ samples to a file. Use this when you need to analyze the raw signal data. ```bash nrsc5 -g 49.0 -w samples1071 107.1 0 ``` -------------------------------- ### Playback from IQ Samples Source: https://github.com/theori-io/nrsc5/blob/master/README.md Read raw IQ samples from a file and play back audio program 0. This is useful for replaying previously recorded signals. ```bash nrsc5 -r samples1071 0 ``` -------------------------------- ### Display Build Information Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Outputs the determined host triple to the build log for informational purposes. ```cmake message (STATUS "Building for ${HOST_TRIPLE}") ``` -------------------------------- ### Build FFTW from Source Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Uses `ExternalProject_Add` to download and build FFTW 3.3.10 if `USE_SYSTEM_FFTW` is disabled. Configures it for float, static linking, and specific instruction sets. ```cmake if (NOT USE_SYSTEM_FFTW) set (FFTW_PREFIX "${CMAKE_BINARY_DIR}/fftw-prefix") ExternalProject_Add ( fftw_external URL "https://www.fftw.org/fftw-3.3.10.tar.gz" URL_HASH SHA256=56c932549852cddcfafdab3820b0200c7742675be92179e59e6215b340e26467 PREFIX ${FFTW_PREFIX} CONFIGURE_COMMAND ${FFTW_PREFIX}/src/fftw_external/configure ${HOST_TRIPLE_ARG} --prefix=${FFTW_PREFIX} --enable-float --enable-static --disable-shared --enable-sse2 --enable-avx --enable-avx2 --with-our-malloc ) add_library (fftw3f STATIC IMPORTED) set_property (TARGET fftw3f PROPERTY IMPORTED_LOCATION "${FFTW_PREFIX}/lib/libfftw3f.a") add_dependencies (fftw3f fftw_external) set (FFTW3F_INCLUDE_DIRS "${FFTW_PREFIX}/include") set (FFTW3F_LIBRARIES fftw3f) set (FFTW3F_BUILTIN fftw3f) endif () ``` -------------------------------- ### Test nrsc5 with Sample Capture Source: https://github.com/theori-io/nrsc5/blob/master/README.md Tests the compiled nrsc5 program using a provided sample capture file. ```bash xz -d < ../support/sample.xz | src/nrsc5 -r - 0 ``` -------------------------------- ### Audio Output to WAV for External Player Source: https://github.com/theori-io/nrsc5/blob/master/README.md Tune to a frequency, convert audio program 0 to WAV format, and pipe it to an external player like mplayer. This allows for playback using preferred media software. ```bash nrsc5 -o - 90.5 0 | mplayer - ``` -------------------------------- ### Configuration File Generation Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Generates a configuration header file from a template. This allows build-time configuration of the project. ```cmake configure_file (config.h.in config.h) ``` -------------------------------- ### Find System LibAO Library Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Checks for the libao library, required for audio output when `BUILD_CLI` is enabled. If not found, it warns and disables using the system library. ```cmake if (BUILD_CLI AND USE_SYSTEM_LIBAO) find_library (AO_LIBRARIES ao) pkg_search_module(AO ao) if (NOT AO_LIBRARIES) message (WARNING "libao not found. Building from source.") set (USE_SYSTEM_LIBAO OFF) endif () endif () ``` -------------------------------- ### Find System FFTW3 Library Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Attempts to locate the FFTW3F library using `find_library` and `pkg_search_module`. If not found, it warns the user and prepares to build FFTW from source. ```cmake if (USE_SYSTEM_FFTW) find_library (FFTW3F_LIBRARIES fftw3f) pkg_search_module (FFTW3F fftw3f) if (NOT FFTW3F_LIBRARIES) message (WARNING "libfftw3f not found. Building from source.") set (USE_SYSTEM_FFTW OFF) endif () endif () ``` -------------------------------- ### Build Command-Line Application Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Conditionally builds an executable named 'app' if BUILD_CLI is enabled. It links against the static library and other necessary dependencies. ```cmake if (BUILD_CLI) add_executable ( app main.c log.c ) set_property (TARGET app PROPERTY OUTPUT_NAME nrsc5) set_target_properties(app PROPERTIES LINK_FLAGS "${STATIC_LINKER_FLAGS}") target_link_libraries ( app nrsc5_static ${AO_LIBRARIES} ${THREAD_LIBRARY} ${SOCKET_LIBRARY} ) install ( TARGETS app RUNTIME DESTINATION bin ) endif () ``` -------------------------------- ### Build Static Library Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Creates a static library target named 'nrsc5_static' using the same source files and dependencies as the shared library. This provides an alternative linking option. ```cmake add_library ( nrsc5_static ${LIBRARY_FILES} ) target_link_libraries ( nrsc5_static ${LibraryDependencies} ) if (BUILTIN_LIBRARIES) add_dependencies(nrsc5_static ${BUILTIN_LIBRARIES}) endif () ``` -------------------------------- ### Find Build Tool Dependencies Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Locates essential build tools like autoconf, automake, and libtoolize. Aborts the build if any are missing. ```cmake find_program (AUTOCONF autoconf) if (NOT AUTOCONF) message (FATAL_ERROR "Missing autoconf. Install autoconf package and try again.") endif () find_program (AUTOMAKE automake) if (NOT AUTOMAKE) message (FATAL_ERROR "Missing automake. Install autoconf package and try again.") endif () find_program (LIBTOOLIZE NAMES libtoolize glibtoolize) if (NOT LIBTOOLIZE) message (FATAL_ERROR "Missing libtoolize. Install libtool package and try again.") endif () ``` -------------------------------- ### Include and Library Directories Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Specifies directories where CMake should search for header files and libraries. This is essential for resolving dependencies. ```cmake include_directories ( ${FAAD2_INCLUDE_DIRS} ${AO_INCLUDE_DIRS} ${RTL_SDR_INCLUDE_DIRS} ${FFTW3F_INCLUDE_DIRS} "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/include" ) link_directories ( ${FAAD2_LIBRARY_DIRS} ${AO_LIBRARY_DIRS} ${RTL_SDR_LIBRARY_DIRS} ${FFTW3F_LIBRARY_DIRS} ${LIBUSB_LIBRARY_DIRS} ) ``` -------------------------------- ### Build LibUSB from Source Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Manages the download and build of libusb from its Git repository using `ExternalProject_Add` when `USE_SYSTEM_LIBUSB` is disabled. Sets a timeout and specifies the Git tag. ```cmake if (NOT USE_SYSTEM_LIBUSB) set (LIBUSB_PREFIX "${CMAKE_BINARY_DIR}/libusb-prefix") ExternalProject_Add ( libusb_external TIMEOUT 120 GIT_REPOSITORY "https://github.com/libusb/libusb.git" GIT_TAG v1.0.27 PREFIX ${LIBUSB_PREFIX} UPDATE_COMMAND "" CONFIGURE_COMMAND ${LIBUSB_PREFIX}/src/libusb_external/configure ${HOST_TRIPLE_ARG} --prefix=${LIBUSB_PREFIX} ) ExternalProject_Add_Step ( libusb_external bootstrap ``` -------------------------------- ### Compiler and Preprocessor Options Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Sets standard C++ compiler flags and defines preprocessor macros for the build. These options control optimization, warnings, and feature availability. ```cmake add_compile_options (--std=gnu11 -O3 -Wall -Wextra) add_definitions (-D_GNU_SOURCE) ``` -------------------------------- ### Define Build Options Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Sets boolean options that control various aspects of the build, such as enabling specific instruction sets or external libraries. ```cmake option (USE_NEON "Use NEON instructions") option (USE_SSE "Use SSE3 instructions") option (USE_FAAD2 "AAC decoding with FAAD2" ON) option (USE_STATIC "Link with static libraries") option (USE_SYSTEM_FFTW "Use system provided fftw" ON) option (USE_SYSTEM_RTLSDR "Use system provided rtl-sdr" ON) option (USE_SYSTEM_LIBUSB "Use system provided libusb" ON) option (USE_SYSTEM_LIBAO "Use system provided libao" ON) option (INSTALLED_FAAD_IS_PATCHED "Use patched system-provided FAAD2" OFF) option (BUILD_DOC "Build API documentation" OFF) option (BUILD_CLI "Build nrsc5 executable" ON) ``` -------------------------------- ### Find System RTL-SDR Library Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Searches for the rtl-sdr library. If the library is not found and `USE_SYSTEM_RTLSDR` is enabled, it issues a warning and disables building from the system. ```cmake if (USE_SYSTEM_RTLSDR) find_library (RTL_SDR_LIBRARIES rtlsdr) pkg_search_module (RTL_SDR librtlsdr) if (NOT RTL_SDR_LIBRARIES) message (WARNING "librtlsdr not found. Building from source.") set (USE_SYSTEM_RTLSDR OFF) endif () endif () ``` -------------------------------- ### Find System LibUSB Library Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Locates the libusb-1.0 library. If it's not found and `USE_SYSTEM_LIBUSB` is enabled, a warning is issued, and the option is turned off. ```cmake if (USE_SYSTEM_LIBUSB) find_library (LIBUSB_LIBRARIES usb-1.0) pkg_search_module (LIBUSB libusb-1.0) if (NOT LIBUSB_LIBRARIES) message (WARNING "libusb-1.0 not found. Building from source.") set (USE_SYSTEM_LIBUSB OFF) endif () endif () ``` -------------------------------- ### Configure x86 SSE Flags Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Applies SSE2 and SSE3 compiler flags for x86 processors when `USE_SSE` is enabled. ```cmake if (CMAKE_SYSTEM_PROCESSOR MATCHES "(i[456]|x)86.*") if (USE_SSE) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -msse3 -mssse3") add_definitions (-DHAVE_SSE2 -DHAVE_SSE3) endif() endif() ``` -------------------------------- ### Build Shared Library Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Creates a shared library target named 'nrsc5' using the defined source files and dependencies. It also sets public header properties and linker flags. ```cmake add_library ( nrsc5 SHARED ${LIBRARY_FILES} ) target_link_libraries ( nrsc5 ${LibraryDependencies} ) if (BUILTIN_LIBRARIES) add_dependencies(nrsc5 ${BUILTIN_LIBRARIES}) endif () set_target_properties(nrsc5 PROPERTIES PUBLIC_HEADER "../include/nrsc5.h") set_target_properties(nrsc5 PROPERTIES LINK_FLAGS "${STATIC_LINKER_FLAGS} ${EXPORTS_LINKER_FLAGS}") target_compile_definitions(nrsc5 PUBLIC "-DNRSC5_EXPORTS=1") ``` -------------------------------- ### Library Dependencies Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Lists the external libraries and system libraries required for linking the NRSC5 project. This ensures all necessary components are available. ```cmake set ( LibraryDependencies ${FAAD2_LIBRARIES} ${FFTW3F_LIBRARIES} ${RTL_SDR_LIBRARIES} ${THREAD_LIBRARY} ${SOCKET_LIBRARY} m ) ``` -------------------------------- ### Configure ARM NEON Flags Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Sets specific C compiler flags for ARM processors when NEON instructions are enabled via the `USE_NEON` option. ```cmake if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*") if (USE_NEON) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4") add_definitions (-DHAVE_NEON) endif() endif() ``` -------------------------------- ### Library Source Files Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Defines the list of source files that will be compiled into the NRSC5 library. This includes core logic and utility files. ```cmake set (LIBRARY_FILES acquire.c decode.c frame.c here_images.c input.c nrsc5.c output.c pids.c rtltcp.c sync.c firdecim_q15.c conv_dec.c rs_init.c rs_decode.c unicode.c strndup.c ) ``` -------------------------------- ### Find Patch Utility Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Checks for the presence of the 'patch' command-line utility, which is required for applying patches during the build process. ```cmake find_program (PATCH patch) if (NOT PATCH) message (FATAL_ERROR "Missing patch. Install patch package and try again.") endif() ``` -------------------------------- ### Determine Host Compiler Triple Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Executes the C compiler to determine the default host triple, used for cross-compilation configurations. ```cmake execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE HOST_TRIPLE_DEFAULT OUTPUT_STRIP_TRAILING_WHITESPACE) ``` -------------------------------- ### Conditional Doxygen Build Target Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt This snippet shows how to conditionally enable Doxygen documentation generation based on the BUILD_DOC CMake variable. It includes finding the Doxygen package and providing user feedback. ```cmake if (BUILD_DOC) find_package(Doxygen) if (NOT DOXYGEN_FOUND) message("** Install the Doxygen application to generate API documentation") else () message("-- Build of Doxygen API documentation enabled") set(DOXYGEN_IN ${CMAKE_CURRENT_BINARY_DIR}/../doc/Doxyfile.in) set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) # 'ALL' below enables building docs together with the application add_custom_target( doc_doxygen ALL COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM ) endif () else () message("-- Build of Doxygen API documentation disabled; use -DBUILD_DOC=ON to enable") endif () ``` -------------------------------- ### Check C Standard Library Symbols Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Verifies the availability of specific C standard library functions like `strndup` and complex number support symbols. ```cmake set (CMAKE_REQUIRED_FLAGS --std=gnu11) check_symbol_exists (strndup string.h HAVE_STRNDUP) check_symbol_exists (CMPLXF complex.h HAVE_CMPLXF) check_symbol_exists (_Imaginary_I complex.h HAVE_IMAGINARY_I) check_symbol_exists (_Complex_I complex.h HAVE_COMPLEX_I) ``` -------------------------------- ### Static Library Flag Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Sets a flag to enable static linking if the USE_STATIC variable is defined. This affects how the library is built and linked. ```cmake if (USE_STATIC) set (STATIC_LINKER_FLAGS -static) endif() ``` -------------------------------- ### Set Cache Variables Source: https://github.com/theori-io/nrsc5/blob/master/CMakeLists.txt Configures cache variables for build customization, such as extra arguments for external projects or debug logging levels. ```cmake set (FAAD2_CMAKE_ARGS "" CACHE STRING "Extra arguments for FAAD2 cmake command") set (LIBRARY_DEBUG_LEVEL "5" CACHE STRING "Debug logging level for libnrsc5: 1=debug, 2=info, 3=warn, 4=error, 5=none") set (HOST_TRIPLE "${HOST_TRIPLE_DEFAULT}" CACHE STRING "Override default host triple") if (HOST_TRIPLE) set (HOST_TRIPLE_ARG "--host=${HOST_TRIPLE}") endif() ``` -------------------------------- ### Platform-Specific Linker Flags Source: https://github.com/theori-io/nrsc5/blob/master/src/CMakeLists.txt Configures linker flags based on the operating system to manage symbol exports. This is crucial for creating compatible shared libraries. ```cmake set (THREAD_LIBRARY pthread) if (CMAKE_SYSTEM_NAME MATCHES Linux) set (EXPORTS_LINKER_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libnrsc5.map") elseif (CMAKE_SYSTEM_NAME MATCHES Darwin) set (CMAKE_MACOSX_RPATH ON) set (EXPORTS_LINKER_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/libnrsc5.sym") elseif (CMAKE_SYSTEM_NAME MATCHES Windows) set (EXPORTS_LINKER_FLAGS "-Wl,--exclude-all-symbols") set (SOCKET_LIBRARY ws2_32) endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.