### Installing mpg123 Target and Headers Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Installs the mpg123 target (libraries/executables) and header files to their designated locations based on installation directories. ```cmake install(TARGETS ${TARGET} EXPORT targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/include/mpg123.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/include/fmt123.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ``` -------------------------------- ### Build and Install win32 Output Module Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures the build and installation of the 'output_win32' module. This snippet is used when the 'win32' output module is found to be available. ```cmake add_library(output_win32 MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/win32.c") target_link_libraries(output_win32 PRIVATE ${WIN32_LIBRARIES}) install(TARGETS output_win32 ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") ``` -------------------------------- ### Install Man Pages Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Installs the man pages for 'mpg123' and 'out123' to the designated man directory. This provides users with documentation accessible via the 'man' command. ```cmake install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../man1/mpg123.1" "${CMAKE_CURRENT_SOURCE_DIR}/../../../man1/out123.1" DESTINATION "${CMAKE_INSTALL_MANDIR}") ``` -------------------------------- ### Install id3dump and strip Targets Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Installs the 'mpg123-id3dump' and 'mpg123-strip' executables to the runtime destination directory. This makes these utility tools available after installation. ```cmake install(TARGETS ${PROJECT_NAME}-id3dump ${PROJECT_NAME}-strip EXPORT targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") ``` -------------------------------- ### Build Dynamic Output Module (CoreAudio) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures a dynamic library for the CoreAudio output module if it's found in the OUTPUT_MODULES list. Links the necessary AudioToolbox framework and installs the module. ```cmake set(CMAKE_SHARED_MODULE_PREFIX "") list(FIND OUTPUT_MODULES coreaudio INDEX) if(NOT INDEX EQUAL -1) add_library(output_coreaudio MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/coreaudio.c") target_link_libraries(output_coreaudio PRIVATE ${AUDIO_TOOLBOX}) install(TARGETS output_coreaudio ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") endif() ``` -------------------------------- ### Install mpg123 and out123 Targets Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Installs the 'mpg123' and 'out123' targets to the appropriate library and binary directories. This ensures executables and libraries are placed correctly after building. ```cmake install(TARGETS ${PROJECT_NAME} out123 EXPORT targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") ``` -------------------------------- ### Build and Install win32 WASAPI Output Module Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures the build and installation of the 'output_win32_wasapi' module. This snippet is used when the 'win32_wasapi' output module is found to be available. It links against specific WASAPI libraries and includes compatibility objects. ```cmake add_library(output_win32_wasapi MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/win32_wasapi.c" $) target_link_libraries(output_win32_wasapi PRIVATE ${WIN32_WASAPI_LIBRARIES}) install(TARGETS output_win32_wasapi ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") ``` -------------------------------- ### Install libsyn123 Target and Header Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libsyn123/CMakeLists.txt Installs the libsyn123 library artifacts (archives, libraries, runtimes) and its header file to specified destinations. ```cmake install(TARGETS ${TARGET} EXPORT targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/include/syn123.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ``` -------------------------------- ### Build Dynamic Output Module (JACK) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures a dynamic library for the JACK output module if it's found in the OUTPUT_MODULES list. Sets compile options, links JACK libraries, and installs the module. Includes compatibility objects. ```cmake list(FIND OUTPUT_MODULES jack INDEX) if(NOT INDEX EQUAL -1) add_library(output_jack MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/jack.c" $) target_compile_options(output_jack PRIVATE ${JACK_CFLAGS}) target_link_libraries(output_jack PRIVATE ${JACK_LIBRARIES}) install(TARGETS output_jack ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") endif() ``` -------------------------------- ### Build Dynamic Output Module (PulseAudio) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures a dynamic library for the PulseAudio output module if it's found in the OUTPUT_MODULES list. Sets compile options, links PulseAudio libraries, and installs the module. ```cmake list(FIND OUTPUT_MODULES pulse INDEX) if(NOT INDEX EQUAL -1) add_library(output_pulse MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/pulse.c") target_compile_options(output_pulse PRIVATE ${PULSE_CFLAGS}) target_link_libraries(output_pulse PRIVATE ${PULSE_LIBRARIES}) install(TARGETS output_pulse ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") endif() ``` -------------------------------- ### Specifying Audio Device Path Source: https://github.com/libsdl-org/mpg123/blob/main/doc/windows-notes.html Example of a Windows device instance path for an audio device. This can be used with the -a option in mpg123 or saved as a system environment variable. ```text USB\VID_0D8C&PID_0014&MI_00\6&175BA917&0&0000 ``` -------------------------------- ### Build Dynamic Output Module (ALSA) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures a dynamic library for the ALSA output module if it's found in the OUTPUT_MODULES list. Links the ALSA library and installs the module. ```cmake list(FIND OUTPUT_MODULES alsa INDEX) if(NOT INDEX EQUAL -1) add_library(output_alsa MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/alsa.c") target_link_libraries(output_alsa PRIVATE ALSA::ALSA) install(TARGETS output_alsa ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") endif() ``` -------------------------------- ### Build Dynamic Output Module (TinyALSA) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures a dynamic library for the TinyALSA output module if it's found in the OUTPUT_MODULES list. Sets compile options, links TinyALSA libraries, and installs the module. ```cmake list(FIND OUTPUT_MODULES tinyalsa INDEX) if(NOT INDEX EQUAL -1) add_library(output_tinyalsa MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/tinyalsa.c") target_compile_options(output_tinyalsa PRIVATE ${TINYALSA_CFLAGS}) target_link_libraries(output_tinyalsa PRIVATE ${TINYALSA_LIBRARIES}) install(TARGETS output_tinyalsa ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}") endif() ``` -------------------------------- ### Set libsyn123 Target Include Directories Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libsyn123/CMakeLists.txt Configures interface include directories for the libsyn123 target, specifying build and install paths. ```cmake target_include_directories(${TARGET} INTERFACE "$" "$") ``` -------------------------------- ### arm64 Platform Definitions and Sources Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Configures build for arm64 architecture, enabling NEON64 optimizations. Includes assembly sources for DCT and synthesis functions, and C sources for dithering and CPU flag detection. ```cmake elseif(MACHINE STREQUAL "arm64") set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON64) set(PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_neon64.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_neon64_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/check_neon.S") if(ACCURATE_ROUNDING) list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64_accurate.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64_accurate.S") else() list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon64.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon64.S") endif() target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_arm.c") ``` -------------------------------- ### Set Include Directories Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Configures the include paths for the build process, including the current binary and source directories. ```cmake include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/") ``` -------------------------------- ### arm32 Platform Definitions and Sources with FPU Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Configures build for arm32 architecture with FPU support, enabling NEON optimizations. Includes assembly sources for DCT and synthesis functions. ```cmake elseif(MACHINE STREQUAL "arm32") if(HAVE_FPU) set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON) set(PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_neon.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_neon_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/check_neon.S") target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_arm.c") if(ACCURATE_ROUNDING) list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon_accurate.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_neon_accurate.S") else() list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_neon.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_neon.S") endif() ``` -------------------------------- ### Linking Libraries and Setting Include Directories Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Appends necessary libraries like 'm' and 'shlwapi' based on defined options and sets interface include directories for the target. ```cmake if(HAVE_M) string(APPEND LIBMPG123_LIBS " -lm") endif() if(WANT_WIN32_UNICODE) string(APPEND LIBMPG123_LIBS " -lshlwapi") endif() set(LIBMPG123_LIBS "${LIBMPG123_LIBS}" PARENT_SCOPE) target_link_libraries(${TARGET} PRIVATE $<$:m> $<$:shlwapi>) target_include_directories(${TARGET} INTERFACE "$" "$") ``` -------------------------------- ### Determine network support Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Enables HAVE_NETWORK if necessary network-related header files are found. ```cmake if(HAVE_NETDB_H AND HAVE_SYS_PARAM_H AND HAVE_SYS_SOCKET_H AND HAVE_NETINET_IN_H AND HAVE_ARPA_INET_H) set(HAVE_NETWORK ON) endif() ``` -------------------------------- ### Enable MKFIFO on Windows Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Explicitly enables the HAVE_MKFIFO option if the system is Windows. ```cmake if(WIN32) set(HAVE_MKFIFO ON) endif() ``` -------------------------------- ### x86 Platform Definitions and Sources Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Configures build for x86 architecture, enabling SSE optimizations if available. Includes assembly sources for various DCT and synthesis functions. ```cmake elseif(MACHINE STREQUAL "x86") if(TRUE) set(PLATFORM_DEFINITIONS OPT_I386) target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_i386.c") endif() cmake_host_system_information(RESULT HAVE_SSE QUERY HAS_SSE) if(CMAKE_SYSTEM_NAME STREQUAL "Android") set(HAVE_SSE ${WITH_SSE}) endif() if(HAVE_SSE) set(PLATFORM_DEFINITIONS OPT_SSE) set(PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/tabinit_mmx.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_sse.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_sse_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_sse_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_sse_s32.S") if(ACCURATE_ROUNDING) list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse_accurate.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_sse_accurate.S") else() list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_sse.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse.S") endif() endif() ``` -------------------------------- ### Configure Header File Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Generates the 'config.h' file by configuring a template file 'config.cmake.h.in'. This is a common practice in C/C++ projects to manage build-time configuration options. ```cmake configure_file(config.cmake.h.in config.h) ``` -------------------------------- ### Configure libsyn123 Library Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libsyn123/CMakeLists.txt Defines the libsyn123 library, lists its source files, and sets output name. Includes compatibility objects. ```cmake cmake_minimum_required(VERSION 3.12) include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/libsyn123/") set(TARGET libsyn123) add_library(${TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/pinknoise.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/geiger.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/libsyn123.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/volume.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/resample.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/filter.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/sampleconv.c" $) set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME syn123) ``` -------------------------------- ### Set WIN32 FIFO and UNICODE options Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Sets flags related to Windows-specific features: HAVE_MKFIFO and WANT_WIN32_UNICODE, based on whether the system is WIN32. ```cmake set(HAVE_WIN32_FIFO ${WIN32}) set(WANT_WIN32_UNICODE ${WIN32}) ``` -------------------------------- ### Build Default Static Output Module Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libout123/modules/CMakeLists.txt Configures a static library for the default output module, conditionally including source files based on the DEFAULT_OUTPUT_MODULE variable. Links necessary libraries and sets compile options. ```cmake if(NOT USE_MODULES) add_library(defaultmodule STATIC "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:dummy.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:coreaudio.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:alsa.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:tinyalsa.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:pulse.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:jack.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:win32.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/libout123/modules/$<$:win32_wasapi.c>") target_link_libraries(defaultmodule PUBLIC $<$:ALSA::ALSA> $<$:${TINYALSA_LIBRARIES}> $<$:${AUDIO_TOOLBOX}> $<$:${PULSE_LIBRARIES}> $<$:${JACK_LIBRARIES}> $<$:${WIN32_LIBRARIES}> $<$:${WIN32_WASAPI_LIBRARIES}>) if(DEFAULT_OUTPUT_MODULE STREQUAL "pulse") target_compile_options(defaultmodule PRIVATE ${PULSE_CFLAGS}) elseif(DEFAULT_OUTPUT_MODULE STREQUAL "jack") target_compile_options(defaultmodule PRIVATE ${JACK_CFLAGS}) elseif(DEFAULT_OUTPUT_MODULE STREQUAL "tinyalsa") target_compile_options(defaultmodule PRIVATE ${TINYALSA_CFLAGS}) endif() if(BUILD_SHARED_LIBS) set_target_properties(defaultmodule PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() ``` -------------------------------- ### Build and Test plain_id3 Executable Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/tests/CMakeLists.txt Defines the plain_id3 test executable, links it to the mpg123 library, and registers it as a CMake test. ```cmake add_executable(plain_id3 "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/plain_id3.c") target_link_libraries(plain_id3 PRIVATE lib${PROJECT_NAME}) add_test(NAME plain_id3 COMMAND plain_id3) ``` -------------------------------- ### Performance Test Loop for mpg123 Versions Source: https://github.com/libsdl-org/mpg123/blob/main/doc/libmpg123_speed.txt This shell script iterates through different mpg123 builds (mpg123-lib and mpg123-trunk) and CPU instruction sets (mmx, 3dnowext, sse) to measure decoding performance for a set of MP3 files. It uses the 'time' command to record real, user, and system execution times. ```shell thomas@kiste:~$ for i in mpg123-lib mpg123-trunk; do for cpu in mmx 3dnowext sse; do echo $i $cpu; time $i/src/mpg123 --cpu $cpu -q -t /thorma/var/music/metallica/ride_the_lightning/*.mp3; done; done ``` ```shell mpg123-lib mmx real 0m25.949s user 0m25.395s sys 0m0.534s mpg123-lib 3dnowext real 0m25.442s user 0m24.863s sys 0m0.558s mpg123-lib sse real 0m25.794s user 0m25.214s sys 0m0.562s mpg123-trunk mmx real 0m26.650s user 0m26.004s sys 0m0.626s mpg123-trunk 3dnowext real 0m25.886s user 0m25.262s sys 0m0.600s mpg123-trunk sse real 0m25.695s user 0m25.136s sys 0m0.539s ``` -------------------------------- ### Search for network libraries Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Searches for necessary libraries for network operations, specifically 'nsl' and 'socket' libraries, for functions like 'gethostbyname'. ```cmake search_libs(gethostbyname GETHOSTBYNAME_LIB nsl socket network) search_libs(socket SOCKET_LIB socket) ``` -------------------------------- ### Check CPU Architecture Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Includes a custom CMake module to check the CPU architecture and sets variables like ARCH_IS_X86, ARCH_IS_X64, etc. ```cmake include(../cmake/CheckCPUArch.cmake) check_cpu_arch_x86(ARCH_IS_X86) check_cpu_arch_x64(ARCH_IS_X64) check_cpu_arch_arm32(ARCH_IS_ARM32) check_cpu_arch_arm64(ARCH_IS_ARM64) ``` -------------------------------- ### Build and Test text Executable Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/tests/CMakeLists.txt Defines the text test executable, links it to the mpg123 library, and registers it as a CMake test. ```cmake add_executable(text "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/text.c") target_link_libraries(text PRIVATE lib${PROJECT_NAME}) add_test(NAME text COMMAND text) ``` -------------------------------- ### Performance Test Loop for 3DNow CPU Source: https://github.com/libsdl-org/mpg123/blob/main/doc/libmpg123_speed.txt This shell script specifically tests the '3dnow' CPU instruction set for both mpg123-lib and mpg123-trunk, measuring decoding performance. It highlights a potential performance concern with the 3DNow instruction set compared to MMX. ```shell thomas@kiste:~$ for i in mpg123-lib mpg123-trunk; do for cpu in 3dnow; do echo $i $cpu; time $i/src/mpg123 --cpu $cpu -q -t /thorma/var/music/metallica/ride_the_lightning/*.mp3; done; done ``` ```shell mpg123-lib 3dnow real 0m33.011s user 0m32.365s sys 0m0.621s mpg123-trunk 3dnow real 0m32.830s user 0m32.192s sys 0m0.619s ``` -------------------------------- ### Build noise Test Executable Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/tests/CMakeLists.txt Defines the noise test executable and links it to the mpg123 library. ```cmake add_executable(noise "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/noise.c") target_link_libraries(noise PRIVATE lib${PROJECT_NAME}) ``` -------------------------------- ### Build Option Definitions Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Defines various build options for mpg123, such as ACCURATE_ROUNDING, FIFO, GAPLESS, IEEE_FLOAT, and IPV6. Some options are dependent on system features. ```cmake option(ACCURATE_ROUNDING "use rounding instead of fast truncation for integer output, where possible" ON) cmake_dependent_option(FIFO "FIFO support for control interface" ON "HAVE_MKFIFO" OFF) option(GAPLESS "enable gapless" ON) option(IEEE_FLOAT "use special hackery relying on IEEE 754 floating point storage format (to accurately round to 16 bit integer at bit more efficiently in generic decoder, enabled by default, disable in case you have a very special computer)" ON) cmake_dependent_option(IPV6 "IPv6 support (actually any protocol your libc does with getaddrinfo)" ON "HAVE_IPV6" OFF) ``` -------------------------------- ### Build seek_whence Test Executable Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/tests/CMakeLists.txt Defines the seek_whence test executable and links it to the mpg123 library. ```cmake add_executable(seek_whence "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/tests/seek_whence.c") target_link_libraries(seek_whence PRIVATE lib${PROJECT_NAME}) ``` -------------------------------- ### x86_64 Platform Optimizations Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Configures platform-specific sources and definitions for the 'amd64' machine type, including various assembly files for optimized decoders and dithering. Adds 'dither.c' to target sources. ```cmake if(MACHINE STREQUAL "amd64") if(HAVE_FPU) set(PLATFORM_DEFINITIONS OPT_MULTI OPT_X86_64 OPT_AVX OPT_GENERIC OPT_GENERIC_DITHER) set(PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_x86_64.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_x86_64_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_avx.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_avx_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_float.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_s32.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_x86_64.S") target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c") if(ACCURATE_ROUNDING) list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_accurate.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_accurate.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_accurate.S") else() list(APPEND PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_x86_64.S" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64.S") ``` -------------------------------- ### Conditional Module Building Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt This block controls the building of optional output modules based on the BUILD_LIBOUT123 flag. It checks for the presence of various audio backend modules like ALSA, CoreAudio, PulseAudio, JACK, TinyALSA, and Windows-specific APIs. ```cmake if(BUILD_LIBOUT123) if(CHECK_MODULES) list(FIND CHECK_MODULES alsa ALSA_REQUIRED) list(FIND CHECK_MODULES coreaudio COREAUDIO_REQUIRED) list(FIND CHECK_MODULES pulse PULSE_REQUIRED) list(FIND CHECK_MODULES jack JACK_REQUIRED) list(FIND CHECK_MODULES tinyalsa TINYALSA_REQUIRED) list(FIND CHECK_MODULES win32 WIN32_REQUIRED) list(FIND CHECK_MODULES win32_wasapi WIN32_WASAPI_REQUIRED) set(MODULE_NOT_FOUND_MESSAGE "module required but couldn't be found") endif() if(NOT CHECK_MODULES OR NOT ALSA_REQUIRED EQUAL -1) find_package(ALSA) if(TARGET ALSA::ALSA) list(APPEND OUTPUT_MODULES alsa) elseif(CHECK_MODULES AND NOT ALSA_REQUIRED EQUAL -1) message(FATAL_ERROR "alsa ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() if(NOT CHECK_MODULES OR NOT COREAUDIO_REQUIRED EQUAL -1) if(APPLE) find_library(AUDIO_TOOLBOX AudioToolbox) list(APPEND OUTPUT_MODULES coreaudio) elseif(CHECK_MODULES AND NOT COREAUDIO_REQUIRED EQUAL -1) message(FATAL_ERROR "coreaudio ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() find_package(PkgConfig) if(PKG_CONFIG_FOUND) if(NOT CHECK_MODULES OR NOT PULSE_REQUIRED EQUAL -1) pkg_search_module(PULSE libpulse-simple) if(PULSE_FOUND) list(APPEND OUTPUT_MODULES pulse) elseif(CHECK_MODULES AND NOT PULSE_REQUIRED EQUAL -1) message(FATAL_ERROR "pulse ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() if(NOT CHECK_MODULES OR NOT JACK_REQUIRED EQUAL -1) pkg_search_module(JACK jack) if(JACK_FOUND) list(APPEND OUTPUT_MODULES jack) elseif(CHECK_MODULES AND NOT JACK_REQUIRED EQUAL -1) message(FATAL_ERROR "jack ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() if(NOT CHECK_MODULES OR NOT TINYALSA_REQUIRED EQUAL -1) pkg_search_module(TINYALSA tinyalsa) if(TINYALSA_FOUND) list(APPEND OUTPUT_MODULES tinyalsa) elseif(CHECK_MODULES AND NOT TINYALSA_REQUIRED EQUAL -1) message(FATAL_ERROR "tinyalsa ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() endif() if(NOT CHECK_MODULES OR NOT WIN32_REQUIRED EQUAL -1) if(HAVE_WINDOWS_H) set(WIN32_LIBRARIES winmm) list(APPEND OUTPUT_MODULES win32) elseif(CHECK_MODULES AND NOT WIN32_REQUIRED EQUAL -1) message(FATAL_ERROR "win32 ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() if(NOT CHECK_MODULES OR NOT WIN32_WASAPI_REQUIRED EQUAL -1) set(WASAPI_INCLUDES "initguid.h" "audioclient.h" "mmdeviceapi.h" "avrt.h") check_include_files("${WASAPI_INCLUDES}" HAVE_WASAPI) if(HAVE_WASAPI) set(WIN32_WASAPI_LIBRARIES ole32 avrt) list(APPEND OUTPUT_MODULES win32_wasapi) elseif(CHECK_MODULES AND NOT WIN32_WASAPI_REQUIRED EQUAL -1) message(FATAL_ERROR "win32_wasapi ${MODULE_NOT_FOUND_MESSAGE}") endif() endif() if(CHECK_MODULES) list(REMOVE_AT CHECK_MODULES ${ALSA_REQUIRED} ${COREAUDIO_REQUIRED} ${PULSE_REQUIRED} ${JACK_REQUIRED} ${TINYALSA_REQUIRED} ${WIN32_REQUIRED} ${WIN32_WASAPI_REQUIRED}) list(LENGTH CHECK_MODULES CHECK_MODULES_LENGTH) if(NOT CHECK_MODULES_LENGTH EQUAL 0) message(FATAL_ERROR "Dunno how to find modules: ${CHECK_MODULES}") endif() endif() if(NOT OUTPUT_MODULES) set(DEFAULT_OUTPUT_MODULE dummy) set(DEFAULT_OUTPUT_MODULES ${DEFAULT_OUTPUT_MODULE}) else() list(GET OUTPUT_MODULES 0 _DEFAULT_OUTPUT_MODULE) set(DEFAULT_OUTPUT_MODULE ${_DEFAULT_OUTPUT_MODULE} CACHE STRING "Default output module") if(BUILD_SHARED_LIBS) string(REPLACE ";" "," DEFAULT_OUTPUT_MODULES "${OUTPUT_MODULES}") else() set(DEFAULT_OUTPUT_MODULES ${DEFAULT_OUTPUT_MODULE}) endif() set_property(CACHE DEFAULT_OUTPUT_MODULE PROPERTY STRINGS ${OUTPUT_MODULES}) endif() endif() ``` -------------------------------- ### Check for FPU support Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Determines FPU support. On Windows or ARM64 on Apple, it's assumed to be present. Otherwise, it queries the host system information. ```cmake if(WIN32 OR (ARCH_IS_ARM64 AND APPLE)) set(HAVE_FPU 1) else() cmake_host_system_information(RESULT HAVE_FPU QUERY HAS_FPU) endif() ``` -------------------------------- ### Compile Definitions and Options Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Sets preprocessor definitions and compiler flags. These are used to conditionally compile code or enable specific compiler warnings and behaviors. ```cmake add_compile_definitions( $<$:_CRT_SECURE_NO_WARNINGS> $<$:NOXFERMEM> $<$:NEWOLD_WRITE_SAMPLE>) add_compile_options( $<$:/wd4996>) ``` -------------------------------- ### mpg123 Command Line Usage Source: https://github.com/libsdl-org/mpg123/blob/main/doc/windows-notes.html Basic syntax for running mpg123. Use double quotes for file paths containing spaces. The wildcard '*' is supported. ```bash mpg123 [ options ] file ...| URL ... | - ``` -------------------------------- ### Define compat OBJECT Library Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/compat/CMakeLists.txt Defines the 'compat' OBJECT library using C source files from the compatibility layer. This is typically used as a building block for other targets. ```cmake set(TARGET compat) add_library(${TARGET} OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_str.c") if(BUILD_SHARED_LIBS) set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() ``` -------------------------------- ### Conditional Include for stdlib.h Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Sets a preprocessor macro based on the availability of stdlib.h. ```cmake if(HAVE_STDLIB_H) set(INCLUDE_STDLIB_H "#include ") else() set(INCLUDE_STDLIB_H "/* #include is not available on this system */") endif() ``` -------------------------------- ### Check for large file support with _FILE_OFFSET_BITS=64 (LFS_SENSITIVE) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Tests if 'off_t' can correctly represent large values when the '_FILE_OFFSET_BITS' macro is defined as 64. Sets LFS_SENSITIVE. ```cmake if(NOT LFS_SENSITIVE) check_c_source_compiles(" #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main() { return 0; }" LFS_SENSITIVE) endif() ``` -------------------------------- ### Include Directories Configuration Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Specifies the directories where CMake should look for header files during compilation. This is crucial for resolving dependencies between different parts of the project. ```cmake include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/include") ``` -------------------------------- ### Adding mpg123 Library Sources Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Defines the libmpg123 library and adds core source files. Includes conditional compilation for optional features like ICY support and different layer decoders. ```cmake set(TARGET lib${PROJECT_NAME}) add_library(${TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/parse.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/frame.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/format.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/equalizer.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/id3.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/optimize.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/readers.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/tabinit.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/libmpg123.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/index.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:icy.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:icy2utf8.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:layer1.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$,$>>:layer2.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:layer3.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:ntom.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:synth_8bit.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:synth.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$,$>>:synth_s32.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$,$>>:synth_real.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:stringbuf.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:feature.c>" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$>:lfs_wrap.c>" $) ``` -------------------------------- ### out123 Executable and Library Linking Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Defines the 'out123' executable, linking it with libmpg123, libout123, and libsyn123 libraries. This snippet is part of the main build configuration. ```cmake add_executable(out123 "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/out123.c") target_link_libraries(out123 PRIVATE lib${PROJECT_NAME} libout123 libsyn123) ``` -------------------------------- ### Check for assembler alignment directives (.balign) Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Tests the availability of assembler directives for alignment, specifically '.balign 4'. Sets ASMALIGN_BALIGN if supported. ```cmake check_c_source_compiles( "int main() { __asm__(\".balign 4\"); return 0; }" ASMALIGN_BALIGN) ``` -------------------------------- ### Set seek table option Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Configures the seek table size. If WITH_SEEKTABLE is not equal to 0, FRAME_INDEX is set to 1. ```cmake set(WITH_SEEKTABLE 1000) if(NOT WITH_SEEKTABLE EQUAL 0) set(FRAME_INDEX 1) endif() ``` -------------------------------- ### Subdirectory and Conditional Builds Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt Includes other CMake subdirectories and conditionally builds certain targets like programs based on project options. ```cmake add_subdirectory("compat") add_subdirectory("libmpg123") if(BUILD_LIBOUT123) add_subdirectory("libout123") endif() add_subdirectory("libsyn123") if(UNIX AND NOT PORTABLE_API) option(BUILD_PROGRAMS "Build programs (mpg123 executable and others)" ON) if(BUILD_PROGRAMS) if(HAVE_FORK AND HAVE_EXECVP AND NETWORK) set(NET123 ON) set(NET123_EXEC ON) endif() if(HAVE_TERMIOS) set(TERM_POSIX ON) else() set(TERM_NONE ON) endif() add_subdirectory("tests") if(BUILD_LIBOUT123) add_executable(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/audio.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/common.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/sysutil.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/control_generic.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/equalizer.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/getlopt.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/httpget.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/resolver.c" $<$:${CMAKE_CURRENT_SOURCE_DIR}/../../../src/net123_exec.c> "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/genre.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/mpg123.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/metaprint.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/local.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/playlist.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/streamdump.c" $<$:${CMAKE_CURRENT_SOURCE_DIR}/../../../src/term_posix.c> $<$:${CMAKE_CURRENT_SOURCE_DIR}/../../../src/term_none.c> "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/term.c") target_link_libraries(${PROJECT_NAME} PRIVATE compat lib${PROJECT_NAME} libout123 libsyn123 ${GETHOSTBYNAME_LIB} ${SOCKET_LIB} $<$:m>) add_executable(out123 "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/sysutil.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/getlopt.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src/filters.c") endif() endif() endif() ``` -------------------------------- ### Processor Architecture Detection Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/libmpg123/CMakeLists.txt Detects the target processor architecture (x64, x86, arm64, arm32) and sets a MACHINE variable. Defaults to 'generic' with a warning for unknown architectures. ```cmake if(ARCH_IS_X64) set(MACHINE amd64) elseif(ARCH_IS_X86) set(MACHINE x86) elseif(ARCH_IS_ARM64) set(MACHINE arm64) elseif(ARCH_IS_ARM32) set(MACHINE arm32) else() message(WARNING "Unknown processor. Using generic optimizations.") set(MACHINE generic) endif() message(STATUS "Detected machine: ${MACHINE}") ``` -------------------------------- ### Check for various C standard library functions Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt This section checks for the availability of numerous standard C library functions. These checks set corresponding HAVE_* variables, indicating system support for features like memory mapping, network functions, and string manipulation. ```cmake check_function_exists(atoll HAVE_ATOLL) check_function_exists(getaddrinfo HAVE_IPV6) check_function_exists(mkfifo HAVE_MKFIFO) check_function_exists(mmap HAVE_MMAP) check_function_exists(nl_langinfo HAVE_NL_LANGINFO) check_function_exists(random HAVE_RANDOM) check_function_exists(setenv HAVE_SETENV) check_function_exists(unsetenv HAVE_UNSETENV) check_function_exists(setlocale HAVE_SETLOCALE) check_function_exists(uselocale HAVE_USELOCALE) check_function_exists(setpriority HAVE_SETPRIORITY) check_function_exists(shmget HAVE_SHMGET) check_function_exists(shmat HAVE_SHMAT) check_function_exists(shmdt HAVE_SHMDT) check_function_exists(shmctl HAVE_SHMCTL) check_function_exists(strerror HAVE_STRERROR) check_function_exists(strerror_l HAVE_STRERROR_L) check_function_exists(strtok_r HAVE_STRTOK_R) check_function_exists(strtok_s HAVE_STRTOK_S) check_function_exists(fork HAVE_FORK) check_function_exists(execvp HAVE_EXECVP) check_function_exists(ctermid HAVE_CTERMID) check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) ``` -------------------------------- ### Disable 32-bit synthesis if FPU is not available Source: https://github.com/libsdl-org/mpg123/blob/main/ports/cmake/src/CMakeLists.txt If FPU support is not detected, the NO_SYNTH32 option is enabled, likely disabling certain 32-bit floating-point synthesis features. ```cmake if(NOT HAVE_FPU) set(NO_SYNTH32 ON) endif() ```