From 5e2a426cb3c99e5e637a94529ff6b2806bdcdaed Mon Sep 17 00:00:00 2001 From: Vitaliy Kirsanov Date: Sat, 6 Apr 2019 11:33:24 +0300 Subject: [PATCH] CMakeLists.txt for portmixer and portaudio The support of ALSA, OSS and CoreAudio was added to portaudio. portmixer was updated accordingly. --- cmake-proxies/CMakeLists.txt | 2 +- cmake-proxies/libflac/CMakeLists.txt | 3 +- cmake-proxies/portaudio-v19/CMakeLists.txt | 55 ++++++++++++++++++++ cmake-proxies/portmixer/CMakeLists.txt | 59 ++++++++++------------ src/CMakeLists.txt | 3 +- 5 files changed, 84 insertions(+), 38 deletions(-) create mode 100644 cmake-proxies/portaudio-v19/CMakeLists.txt diff --git a/cmake-proxies/CMakeLists.txt b/cmake-proxies/CMakeLists.txt index ca284363b..ccb71c808 100644 --- a/cmake-proxies/CMakeLists.txt +++ b/cmake-proxies/CMakeLists.txt @@ -33,7 +33,7 @@ add_subdirectory( "libvorbis" ) #add_subdirectory( "locale" ) add_subdirectory( "lv2" ) add_subdirectory( "mod-script-pipe" ) -add_subdirectory( "${LIB_SRC_DIRECTORY}portaudio-v19" "${CMAKE_CURRENT_BINARY_DIR}/portaudio-v19" EXCLUDE_FROM_ALL ) +add_subdirectory( "portaudio-v19" ) cmake_policy(PUSH) cmake_policy(VERSION 2.8.11) diff --git a/cmake-proxies/libflac/CMakeLists.txt b/cmake-proxies/libflac/CMakeLists.txt index c436ead0c..0650a9b7c 100644 --- a/cmake-proxies/libflac/CMakeLists.txt +++ b/cmake-proxies/libflac/CMakeLists.txt @@ -190,8 +190,7 @@ add_library(FLAC-static STATIC "${TARGET_SOURCE}/src/libFLAC/ogg_decoder_aspect.c" "${TARGET_SOURCE}/src/libFLAC/ogg_encoder_aspect.c" "${TARGET_SOURCE}/src/libFLAC/ogg_helper.c" - "${TARGET_SOURCE}/src/libFLAC/ogg_mapping.c" - "$<$:${TARGET_SOURCE}/src/libFLAC/windows_unicode_filenames.c>") + "${TARGET_SOURCE}/src/libFLAC/ogg_mapping.c") include_directories( "${TARGET_SOURCE}/include" diff --git a/cmake-proxies/portaudio-v19/CMakeLists.txt b/cmake-proxies/portaudio-v19/CMakeLists.txt new file mode 100644 index 000000000..02cbace8a --- /dev/null +++ b/cmake-proxies/portaudio-v19/CMakeLists.txt @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 3.13) + +set(TARGET portaudio-v19) +set(TARGET_SOURCE ${LIB_SRC_DIRECTORY}${TARGET}) + +add_subdirectory("${TARGET_SOURCE}" "${CMAKE_CURRENT_BINARY_DIR}/portaudio" EXCLUDE_FROM_ALL) +target_include_directories(portaudio_static INTERFACE "${TARGET_SOURCE}/include") +set_target_properties(portaudio_static PROPERTIES OSX_ARCHITECTURES "") + +if(NOT UNIX) + return() +endif() + +include(CheckIncludeFile) + +target_include_directories(portaudio_static PRIVATE + "${TARGET_SOURCE}/src/os/unix/") +target_sources(portaudio_static PRIVATE + "${TARGET_SOURCE}/src/os/unix/pa_unix_hostapis.c" + "${TARGET_SOURCE}/src/os/unix/pa_unix_util.c") + +if(APPLE) + target_compile_definitions(portaudio_static PUBLIC PA_USE_COREAUDIO=1) + target_sources(portaudio_static PRIVATE + "${TARGET_SOURCE}/src/hostapi/coreaudio/pa_mac_core.c" + "${TARGET_SOURCE}/src/hostapi/coreaudio/pa_mac_core_utilities.c" + "${TARGET_SOURCE}/src/hostapi/coreaudio/pa_mac_core_blocking.c" + "${TARGET_SOURCE}/src/common/pa_ringbuffer.c") +else() + option(PA_WITH_ALSA "Enable support for ALSA" OFF) + if(PA_WITH_ALSA) + find_package(ALSA REQUIRED) + target_compile_definitions(portaudio_static PUBLIC PA_USE_ALSA=1) + target_sources(portaudio_static PRIVATE + "${TARGET_SOURCE}/src/hostapi/alsa/pa_linux_alsa.c") + target_link_libraries(portaudio_static PUBLIC ALSA::ALSA) + endif() + + option(PA_WITH_OSS "Enable support for OSS" OFF) + if(PA_WITH_OSS) + check_include_file(sys/soundcard.h HAVE_SYS_SOUNDCARD_H) + check_include_file(linux/soundcard.h HAVE_LINUX_SOUNDCARD_H) + check_include_file(machine/soundcard.h HAVE_MACHINE_SOUNDCARD_H) + if(NOT (HAVE_SYS_SOUNDCARD_H OR HAVE_LINUX_SOUNDCARD_H OR HAVE_MACHINE_SOUNDCARD_H)) + message(FATAL_ERROR "Couldn't find OSS") + endif() + target_compile_definitions(portaudio_static PUBLIC + PA_USE_OSS=1 + $<$:HAVE_SYS_SOUNDCARD_H> + $<$:HAVE_LINUX_SOUNDCARD_H> + $<$:HAVE_MACHINE_SOUNDCARD_H>) + target_sources(portaudio_static PRIVATE + "${TARGET_SOURCE}/src/hostapi/oss/pa_unix_oss.c") + endif() +endif() diff --git a/cmake-proxies/portmixer/CMakeLists.txt b/cmake-proxies/portmixer/CMakeLists.txt index c0137c6fd..50c97584b 100644 --- a/cmake-proxies/portmixer/CMakeLists.txt +++ b/cmake-proxies/portmixer/CMakeLists.txt @@ -1,39 +1,32 @@ #directory cmake-proxies/portmixer -set( TARGET portmixer ) -set( TARGET_SOURCE ${LIB_SRC_DIRECTORY}${TARGET} ) -project( ${TARGET} ) +set(TARGET portmixer) +set(TARGET_SOURCE ${LIB_SRC_DIRECTORY}${TARGET}) +project(${TARGET}) -set( SOURCES -#${LIB_SRC_DIRECTORY}portmixer/px_tests/px_test.c -#${LIB_SRC_DIRECTORY}portmixer/src/px_example_api.c -#${LIB_SRC_DIRECTORY}portmixer/src/px_linux_alsa.c -#${LIB_SRC_DIRECTORY}portmixer/src/px_mac_coreaudio.c -${LIB_SRC_DIRECTORY}portmixer/src/px_mixer.c -#${LIB_SRC_DIRECTORY}portmixer/src/px_unix_oss.c -${LIB_SRC_DIRECTORY}portmixer/src/px_win_common.c -${LIB_SRC_DIRECTORY}portmixer/src/px_win_ds.c -${LIB_SRC_DIRECTORY}portmixer/src/px_win_endpoint.c -${LIB_SRC_DIRECTORY}portmixer/src/px_win_wasapi.c -${LIB_SRC_DIRECTORY}portmixer/src/px_win_wmme.c -) -# This defines the #define on both Windows and Linux. -add_definitions( --D_LIB - ) -add_library( ${TARGET} STATIC ${SOURCES}) +include(CheckIncludeFiles) -#if(MSVC) -#FIX-ME What a horrible hacky place for a config file! - add_definitions(/FI"${top_dir}/win/Projects/${TARGET}/Debug/config.h") -#else() - # GCC or Clang -# add_definitions(-include ${top_dir}/win/Projects/${TARGET}/config.h) -#endif() +get_target_property(PA_DEFINITIONS portaudio_static INTERFACE_COMPILE_DEFINITIONS) + +add_library(${TARGET} STATIC + "${TARGET_SOURCE}/src/px_mixer.c" + "$<$:${TARGET_SOURCE}/src/px_win_common.c>" + "$<$:${TARGET_SOURCE}/src/px_win_ds.c>" + "$<$:${TARGET_SOURCE}/src/px_win_endpoint.c>" + "$<$:${TARGET_SOURCE}/src/px_win_wasapi.c>" + "$<$:${TARGET_SOURCE}/src/px_win_wmme.c>" + "$<$:${TARGET_SOURCE}/src/px_linux_alsa.c>" + "$<$:${TARGET_SOURCE}/src/px_unix_oss.c>" + "$<$:${TARGET_SOURCE}/src/px_mac_coreaudio.c>") -target_include_directories( ${TARGET} PRIVATE -${TARGET_SOURCE}/include -${LIB_SRC_DIRECTORY}/portaudio-v19/include -) +target_compile_definitions(${TARGET} PRIVATE + $<$:PX_USE_WIN_DSOUND> + $<$:PX_USE_WIN_MME> + $<$:PX_USE_WIN_WASAPI> + $<$:PX_USE_LINUX_ALSA> + $<$:PX_USE_UNIX_OSS> + $<$:PX_USE_MAC_COREAUDIO>) -target_link_libraries( ${TARGET} ) \ No newline at end of file +target_include_directories(${TARGET} PUBLIC "${TARGET_SOURCE}/include") +target_link_libraries(${TARGET} PUBLIC portaudio_static) +set_target_properties(${TARGET} PROPERTIES OSX_ARCHITECTURES "") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 247f9a54e..bf0ad318f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,6 @@ include_directories(${top_dir}/lib-src/libsoxr/src) #really? Src? include_directories(${top_dir}/lib-src/libvamp) include_directories(${top_dir}/lib-src/libvorbis/include) include_directories(${top_dir}/lib-src/lib-widget-extra) -include_directories(${top_dir}/lib-src/portaudio-v19/include) include_directories(${top_dir}/lib-src/portmixer/include) include_directories(${top_dir}/lib-src/portsmf) include_directories(${top_dir}/lib-src/sbsms/include) @@ -497,7 +496,7 @@ FileDialog FLACXX-static libsndfile libsoxr -portaudio_static +portmixer portmidi-static ) if(MSVC)