diff --git a/ports/cmake/CMakeLists.txt b/ports/cmake/CMakeLists.txt index b5008da..8e6309a 100644 --- a/ports/cmake/CMakeLists.txt +++ b/ports/cmake/CMakeLists.txt @@ -5,6 +5,13 @@ read_api_version(MPG123_VERSION API_VERSION OUTAPI_VERSION SYNAPI_VERSION) project(mpg123 VERSION ${MPG123_VERSION} LANGUAGES C ASM) +option(BUILD_LIBOUT123 "build libout123" ON) +if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + message(WARNING "Output module is not implemented for '${CMAKE_SYSTEM_NAME}' platform.") + message(WARNING "To prevent build errors 'BUILD_LIBOUT123' option is set to OFF.") + set(BUILD_LIBOUT123 OFF) +endif() + include(cmake/search_libs.cmake) include(CMakePackageConfigHelpers) include(GNUInstallDirs) @@ -34,17 +41,28 @@ set(exec_prefix "${CMAKE_INSTALL_PREFIX}") set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libmpg123.pc.in" libmpg123.pc @ONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libout123.pc.in" libout123.pc @ONLY) +if(BUILD_LIBOUT123) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libout123.pc.in" libout123.pc @ONLY) +endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../../libsyn123.pc.in" libsyn123.pc @ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/libmpg123.pc" - "${CMAKE_CURRENT_BINARY_DIR}/libout123.pc" "${CMAKE_CURRENT_BINARY_DIR}/libsyn123.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../man1/mpg123.1" - "${CMAKE_CURRENT_SOURCE_DIR}/../../man1/out123.1" DESTINATION "${CMAKE_INSTALL_MANDIR}") + +if(BUILD_LIBOUT123) + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/libout123.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/../../man1/out123.1" + DESTINATION "${CMAKE_INSTALL_MANDIR}") +endif() diff --git a/ports/cmake/src/CMakeLists.txt b/ports/cmake/src/CMakeLists.txt index b843152..3945c7e 100644 --- a/ports/cmake/src/CMakeLists.txt +++ b/ports/cmake/src/CMakeLists.txt @@ -194,112 +194,114 @@ endif() # Modules -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}") +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() -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}") + 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() -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}") + 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() - 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}") + 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() - 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}") + 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() -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}") + 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() -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}") + 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() -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}") + 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() -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() + 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() - set_property(CACHE DEFAULT_OUTPUT_MODULE PROPERTY STRINGS ${OUTPUT_MODULES}) endif() option(ACCURATE_ROUNDING "use rounding instead of fast truncation for integer output, where possible" ON) @@ -362,7 +364,9 @@ add_compile_options( add_subdirectory("compat") add_subdirectory("libmpg123") -add_subdirectory("libout123") +if(BUILD_LIBOUT123) + add_subdirectory("libout123") +endif() add_subdirectory("libsyn123") if(0)