diff options
-rw-r--r-- | CMakeLists.txt | 902 |
1 files changed, 451 insertions, 451 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 44a261f9..83eee139 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -561,7 +561,7 @@ set(COMMON_OBJS common/vecmat.h common/vector.h ) -SET(OPENAL_OBJS +set(OPENAL_OBJS al/auxeffectslot.cpp al/auxeffectslot.h al/buffer.cpp @@ -580,7 +580,7 @@ SET(OPENAL_OBJS al/source.h al/state.cpp ) -SET(ALC_OBJS +set(ALC_OBJS alc/alc.cpp alc/alcmain.h alc/alu.cpp @@ -649,88 +649,88 @@ SET(ALC_OBJS ) -SET(CPU_EXTS "Default") -SET(HAVE_SSE 0) -SET(HAVE_SSE2 0) -SET(HAVE_SSE3 0) -SET(HAVE_SSE4_1 0) -SET(HAVE_NEON 0) +set(CPU_EXTS "Default") +set(HAVE_SSE 0) +set(HAVE_SSE2 0) +set(HAVE_SSE3 0) +set(HAVE_SSE4_1 0) +set(HAVE_NEON 0) # Check for SSE+SSE2 support -OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF) -OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF) -IF(HAVE_XMMINTRIN_H AND HAVE_EMMINTRIN_H) - OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON) - OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON) - IF(ALSOFT_CPUEXT_SSE AND ALSOFT_CPUEXT_SSE2) - SET(HAVE_SSE 1) - SET(HAVE_SSE2 1) - SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp) - IF(SSE2_SWITCH) - SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp +option(ALSOFT_REQUIRE_SSE "Require SSE support" OFF) +option(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF) +if(HAVE_XMMINTRIN_H AND HAVE_EMMINTRIN_H) + option(ALSOFT_CPUEXT_SSE "Enable SSE support" ON) + option(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON) + if(ALSOFT_CPUEXT_SSE AND ALSOFT_CPUEXT_SSE2) + set(HAVE_SSE 1) + set(HAVE_SSE2 1) + set(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp) + if(SSE2_SWITCH) + set_source_files_properties(alc/mixer/mixer_sse.cpp alc/mixer/mixer_sse2.cpp PROPERTIES COMPILE_FLAGS "${SSE2_SWITCH}") - ENDIF() - SET(CPU_EXTS "${CPU_EXTS}, SSE, SSE2") - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE) - MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions") -ENDIF() -IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2) - MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions") -ENDIF() - -OPTION(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF) -IF(HAVE_EMMINTRIN_H) - OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON) - IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3) - SET(HAVE_SSE3 1) - SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse3.cpp) - IF(SSE2_SWITCH) - SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse3.cpp PROPERTIES - COMPILE_FLAGS "${SSE3_SWITCH}") - ENDIF() - SET(CPU_EXTS "${CPU_EXTS}, SSE3") - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3) - MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions") -ENDIF() - -OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF) -IF(HAVE_SMMINTRIN_H) - OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON) - IF(HAVE_SSE3 AND ALSOFT_CPUEXT_SSE4_1) - SET(HAVE_SSE4_1 1) - SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse41.cpp) - IF(SSE4_1_SWITCH) - SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_sse41.cpp PROPERTIES - COMPILE_FLAGS "${SSE4_1_SWITCH}") - ENDIF() - SET(CPU_EXTS "${CPU_EXTS}, SSE4.1") - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1) - MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions") -ENDIF() + endif() + set(CPU_EXTS "${CPU_EXTS}, SSE, SSE2") + endif() +endif() +if(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE) + message(FATAL_ERROR "Failed to enabled required SSE CPU extensions") +endif() +if(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2) + message(FATAL_ERROR "Failed to enable required SSE2 CPU extensions") +endif() + +option(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF) +if(HAVE_EMMINTRIN_H) + option(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON) + if(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3) + set(HAVE_SSE3 1) + set(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse3.cpp) + if(SSE2_SWITCH) + set_source_files_properties(alc/mixer/mixer_sse3.cpp PROPERTIES + COMPILE_FLAGS "${SSE3_SWITCH}") + endif() + set(CPU_EXTS "${CPU_EXTS}, SSE3") + endif() +endif() +if(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3) + message(FATAL_ERROR "Failed to enable required SSE3 CPU extensions") +endif() + +option(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF) +if(HAVE_SMMINTRIN_H) + option(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON) + if(HAVE_SSE3 AND ALSOFT_CPUEXT_SSE4_1) + set(HAVE_SSE4_1 1) + set(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_sse41.cpp) + if(SSE4_1_SWITCH) + set_source_files_properties(alc/mixer/mixer_sse41.cpp PROPERTIES + COMPILE_FLAGS "${SSE4_1_SWITCH}") + endif() + set(CPU_EXTS "${CPU_EXTS}, SSE4.1") + endif() +endif() +if(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1) + message(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions") +endif() # Check for ARM Neon support -OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF) -IF(HAVE_ARM_NEON_H) - OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON) - IF(ALSOFT_CPUEXT_NEON) - SET(HAVE_NEON 1) - SET(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_neon.cpp) - IF(FPU_NEON_SWITCH) - SET_SOURCE_FILES_PROPERTIES(alc/mixer/mixer_neon.cpp PROPERTIES - COMPILE_FLAGS "${FPU_NEON_SWITCH}") - ENDIF() - SET(CPU_EXTS "${CPU_EXTS}, Neon") - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON) - MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions") -ENDIF() +option(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF) +if(HAVE_ARM_NEON_H) + option(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON) + if(ALSOFT_CPUEXT_NEON) + set(HAVE_NEON 1) + set(ALC_OBJS ${ALC_OBJS} alc/mixer/mixer_neon.cpp) + if(FPU_NEON_SWITCH) + set_source_files_properties(alc/mixer/mixer_neon.cpp PROPERTIES + COMPILE_FLAGS "${FPU_NEON_SWITCH}") + endif() + set(CPU_EXTS "${CPU_EXTS}, Neon") + endif() +endif() +if(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON) + message(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions") +endif() set(HAVE_ALSA 0) @@ -771,86 +771,86 @@ set(ALC_OBJS ${ALC_OBJS} ) # Check ALSA backend -OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF) -FIND_PACKAGE(ALSA) -IF(ALSA_FOUND) - OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON) - IF(ALSOFT_BACKEND_ALSA) - SET(HAVE_ALSA 1) - SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h) - ADD_BACKEND_LIBS(${ALSA_LIBRARIES}) - SET(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA) - MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend") -ENDIF() +option(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF) +find_package(ALSA) +if(ALSA_FOUND) + option(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON) + if(ALSOFT_BACKEND_ALSA) + set(HAVE_ALSA 1) + set(BACKENDS "${BACKENDS} ALSA${IS_LINKED},") + set(ALC_OBJS ${ALC_OBJS} alc/backends/alsa.cpp alc/backends/alsa.h) + add_backend_libs(${ALSA_LIBRARIES}) + set(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA) + message(FATAL_ERROR "Failed to enabled required ALSA backend") +endif() # Check OSS backend -OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF) -FIND_PACKAGE(OSS) -IF(OSS_FOUND) - OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON) - IF(ALSOFT_BACKEND_OSS) - SET(HAVE_OSS 1) - SET(BACKENDS "${BACKENDS} OSS,") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h) - IF(OSS_LIBRARIES) - SET(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS}) - ENDIF() - SET(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS) - MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend") -ENDIF() +option(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF) +find_package(OSS) +if(OSS_FOUND) + option(ALSOFT_BACKEND_OSS "Enable OSS backend" ON) + if(ALSOFT_BACKEND_OSS) + set(HAVE_OSS 1) + set(BACKENDS "${BACKENDS} OSS,") + set(ALC_OBJS ${ALC_OBJS} alc/backends/oss.cpp alc/backends/oss.h) + if(OSS_LIBRARIES) + set(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS}) + endif() + set(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS) + message(FATAL_ERROR "Failed to enabled required OSS backend") +endif() # Check Solaris backend -OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF) -FIND_PACKAGE(AudioIO) -IF(AUDIOIO_FOUND) - OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON) - IF(ALSOFT_BACKEND_SOLARIS) - SET(HAVE_SOLARIS 1) - SET(BACKENDS "${BACKENDS} Solaris,") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h) - SET(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS) - MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend") -ENDIF() +option(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF) +find_package(AudioIO) +if(AUDIOIO_FOUND) + option(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON) + if(ALSOFT_BACKEND_SOLARIS) + set(HAVE_SOLARIS 1) + set(BACKENDS "${BACKENDS} Solaris,") + set(ALC_OBJS ${ALC_OBJS} alc/backends/solaris.cpp alc/backends/solaris.h) + set(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS) + message(FATAL_ERROR "Failed to enabled required Solaris backend") +endif() # Check SndIO backend -OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF) -FIND_PACKAGE(SoundIO) -IF(SOUNDIO_FOUND) - OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON) - IF(ALSOFT_BACKEND_SNDIO) - SET(HAVE_SNDIO 1) - SET(BACKENDS "${BACKENDS} SndIO (linked),") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h) - SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS}) - SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend") -ENDIF() +option(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF) +find_package(SoundIO) +if(SOUNDIO_FOUND) + option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON) + if(ALSOFT_BACKEND_SNDIO) + set(HAVE_SNDIO 1) + set(BACKENDS "${BACKENDS} SndIO (linked),") + set(ALC_OBJS ${ALC_OBJS} alc/backends/sndio.cpp alc/backends/sndio.h) + set(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS}) + set(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO) + message(FATAL_ERROR "Failed to enabled required SndIO backend") +endif() # Check Windows-only backends -OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF) -OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF) -OPTION(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF) -IF(WIN32) - SET(WINSDK_LIB_DIRS ) - SET(WINSDK_INCLUDE_DIRS ) - FIND_PACKAGE(WindowsSDK) - IF(WINDOWSSDK_FOUND) +option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF) +option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF) +option(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF) +if(WIN32) + set(WINSDK_LIB_DIRS ) + set(WINSDK_INCLUDE_DIRS ) + find_package(WindowsSDK) + if(WINDOWSSDK_FOUND) get_windowssdk_library_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_LIB_DIRS) get_windowssdk_include_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_INCLUDE_DIRS) - ENDIF() + endif() # Check MMSystem backend check_include_files("windows.h;mmsystem.h" HAVE_MMSYSTEM_H) @@ -867,133 +867,133 @@ IF(WIN32) endif() # Check DSound backend - FIND_PACKAGE(DSound) - IF(DSOUND_FOUND) - OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON) - IF(ALSOFT_BACKEND_DSOUND) - SET(HAVE_DSOUND 1) - SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h) - ADD_BACKEND_LIBS(${DSOUND_LIBRARIES}) - SET(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS}) - ENDIF() - ENDIF() + find_package(DSound) + if(DSOUND_FOUND) + option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON) + if(ALSOFT_BACKEND_DSOUND) + set(HAVE_DSOUND 1) + set(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},") + set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h) + add_backend_libs(${DSOUND_LIBRARIES}) + set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS}) + endif() + endif() # Check for WASAPI backend - CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H) - IF(HAVE_MMDEVICEAPI_H) - OPTION(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON) - IF(ALSOFT_BACKEND_WASAPI) - SET(HAVE_WASAPI 1) - SET(BACKENDS "${BACKENDS} WASAPI,") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) - ENDIF() - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM) - MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend") -ENDIF() -IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND) - MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend") -ENDIF() -IF(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI) - MESSAGE(FATAL_ERROR "Failed to enabled required WASAPI backend") -ENDIF() + check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H) + if(HAVE_MMDEVICEAPI_H) + option(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON) + if(ALSOFT_BACKEND_WASAPI) + set(HAVE_WASAPI 1) + set(BACKENDS "${BACKENDS} WASAPI,") + set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) + endif() + endif() +endif() +if(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM) + message(FATAL_ERROR "Failed to enabled required WinMM backend") +endif() +if(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND) + message(FATAL_ERROR "Failed to enabled required DSound backend") +endif() +if(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI) + message(FATAL_ERROR "Failed to enabled required WASAPI backend") +endif() # Check PortAudio backend -OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF) -FIND_PACKAGE(PortAudio) -IF(PORTAUDIO_FOUND) - OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON) - IF(ALSOFT_BACKEND_PORTAUDIO) - SET(HAVE_PORTAUDIO 1) - SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h) - ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES}) - SET(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend") -ENDIF() +option(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF) +find_package(PortAudio) +if(PORTAUDIO_FOUND) + option(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON) + if(ALSOFT_BACKEND_PORTAUDIO) + set(HAVE_PORTAUDIO 1) + set(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},") + set(ALC_OBJS ${ALC_OBJS} alc/backends/portaudio.cpp alc/backends/portaudio.h) + add_backend_libs(${PORTAUDIO_LIBRARIES}) + set(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO) + message(FATAL_ERROR "Failed to enabled required PortAudio backend") +endif() # Check PulseAudio backend -OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF) -FIND_PACKAGE(PulseAudio) -IF(PULSEAUDIO_FOUND) - OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON) - IF(ALSOFT_BACKEND_PULSEAUDIO) - SET(HAVE_PULSEAUDIO 1) - SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h) - ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES}) - SET(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend") -ENDIF() +option(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF) +find_package(PulseAudio) +if(PULSEAUDIO_FOUND) + option(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON) + if(ALSOFT_BACKEND_PULSEAUDIO) + set(HAVE_PULSEAUDIO 1) + set(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},") + set(ALC_OBJS ${ALC_OBJS} alc/backends/pulseaudio.cpp alc/backends/pulseaudio.h) + add_backend_libs(${PULSEAUDIO_LIBRARIES}) + set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO) + message(FATAL_ERROR "Failed to enabled required PulseAudio backend") +endif() # Check JACK backend -OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF) -FIND_PACKAGE(JACK) -IF(JACK_FOUND) - OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON) - IF(ALSOFT_BACKEND_JACK) - SET(HAVE_JACK 1) - SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h) - ADD_BACKEND_LIBS(${JACK_LIBRARIES}) - SET(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK) - MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend") -ENDIF() +option(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF) +find_package(JACK) +if(JACK_FOUND) + option(ALSOFT_BACKEND_JACK "Enable JACK backend" ON) + if(ALSOFT_BACKEND_JACK) + set(HAVE_JACK 1) + set(BACKENDS "${BACKENDS} JACK${IS_LINKED},") + set(ALC_OBJS ${ALC_OBJS} alc/backends/jack.cpp alc/backends/jack.h) + add_backend_libs(${JACK_LIBRARIES}) + set(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK) + message(FATAL_ERROR "Failed to enabled required JACK backend") +endif() # Check CoreAudio backend -OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF) -FIND_LIBRARY(COREAUDIO_FRAMEWORK NAMES CoreAudio) -FIND_PATH(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h) -IF(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR) - OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON) - IF(ALSOFT_BACKEND_COREAUDIO) - SET(HAVE_COREAUDIO 1) - SET(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h) - SET(BACKENDS "${BACKENDS} CoreAudio,") - SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} /System/Library/Frameworks/AudioUnit.framework +option(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF) +find_library(COREAUDIO_FRAMEWORK NAMES CoreAudio) +find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h) +if(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR) + option(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON) + if(ALSOFT_BACKEND_COREAUDIO) + set(HAVE_COREAUDIO 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h) + set(BACKENDS "${BACKENDS} CoreAudio,") + set(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} /System/Library/Frameworks/AudioUnit.framework /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS}) # Some versions of OSX may need the AudioToolbox framework. Add it if # it's found. - FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox) - IF(AUDIOTOOLBOX_LIBRARY) - SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS}) - ENDIF() - - SET(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend") -ENDIF() + find_library(AUDIOTOOLBOX_LIBRARY NAMES AudioToolbox) + if(AUDIOTOOLBOX_LIBRARY) + set(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS}) + endif() + + set(INC_PATHS ${INC_PATHS} ${AUDIOUNIT_INCLUDE_DIR}) + endif() +endif() +if(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO) + message(FATAL_ERROR "Failed to enabled required CoreAudio backend") +endif() # Check for OpenSL (Android) backend -OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF) -FIND_PACKAGE(OpenSL) -IF(OPENSL_FOUND) - OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON) - IF(ALSOFT_BACKEND_OPENSL) - SET(HAVE_OPENSL 1) - SET(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h) - SET(BACKENDS "${BACKENDS} OpenSL,") - SET(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS}) - SET(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL) - MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend") -ENDIF() +option(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF) +find_package(OpenSL) +if(OPENSL_FOUND) + option(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON) + if(ALSOFT_BACKEND_OPENSL) + set(HAVE_OPENSL 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/opensl.cpp alc/backends/opensl.h) + set(BACKENDS "${BACKENDS} OpenSL,") + set(EXTRA_LIBS ${OPENSL_LIBRARIES} ${EXTRA_LIBS}) + set(INC_PATHS ${INC_PATHS} ${OPENSL_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL) + message(FATAL_ERROR "Failed to enabled required OpenSL backend") +endif() # Check for Oboe (Android) backend set(OBOE_TARGET ) @@ -1035,135 +1035,135 @@ if(ALSOFT_REQUIRE_OBOE AND NOT HAVE_OBOE) endif() # Check for SDL2 backend -OPTION(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF) -FIND_PACKAGE(SDL2) -IF(SDL2_FOUND) +option(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF) +find_package(SDL2) +if(SDL2_FOUND) # Off by default, since it adds a runtime dependency - OPTION(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF) - IF(ALSOFT_BACKEND_SDL2) - SET(HAVE_SDL2 1) - SET(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h) - SET(BACKENDS "${BACKENDS} SDL2,") - SET(EXTRA_LIBS ${SDL2_LIBRARY} ${EXTRA_LIBS}) - SET(INC_PATHS ${INC_PATHS} ${SDL2_INCLUDE_DIR}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_SDL2 AND NOT SDL2_FOUND) - MESSAGE(FATAL_ERROR "Failed to enabled required SDL2 backend") -ENDIF() + option(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF) + if(ALSOFT_BACKEND_SDL2) + set(HAVE_SDL2 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h) + set(BACKENDS "${BACKENDS} SDL2,") + set(EXTRA_LIBS ${SDL2_LIBRARY} ${EXTRA_LIBS}) + set(INC_PATHS ${INC_PATHS} ${SDL2_INCLUDE_DIR}) + endif() +endif() +if(ALSOFT_REQUIRE_SDL2 AND NOT SDL2_FOUND) + message(FATAL_ERROR "Failed to enabled required SDL2 backend") +endif() # Optionally enable the Wave Writer backend -OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON) -IF(ALSOFT_BACKEND_WAVE) - SET(HAVE_WAVE 1) - SET(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h) - SET(BACKENDS "${BACKENDS} WaveFile,") -ENDIF() +option(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON) +if(ALSOFT_BACKEND_WAVE) + set(HAVE_WAVE 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/wave.cpp alc/backends/wave.h) + set(BACKENDS "${BACKENDS} WaveFile,") +endif() # This is always available -SET(BACKENDS "${BACKENDS} Null") +set(BACKENDS "${BACKENDS} Null") -FIND_PACKAGE(Git) -IF(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") +find_package(Git) +if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") # Get the current working branch and its latest abbreviated commit hash - ADD_CUSTOM_TARGET(build_version + add_custom_target(build_version ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D LIB_VERSION=${LIB_VERSION} -D LIB_VERSION_NUM=${LIB_VERSION_NUM} -D SRC=${OpenAL_SOURCE_DIR}/version.h.in -D DST=${OpenAL_BINARY_DIR}/version.h -P ${OpenAL_SOURCE_DIR}/version.cmake WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" VERBATIM ) -ELSE() - SET(GIT_BRANCH "UNKNOWN") - SET(GIT_COMMIT_HASH "unknown") - CONFIGURE_FILE( +else() + set(GIT_BRANCH "UNKNOWN") + set(GIT_COMMIT_HASH "unknown") + configure_file( "${OpenAL_SOURCE_DIR}/version.h.in" "${OpenAL_BINARY_DIR}/version.h") -ENDIF() +endif() option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON) if(ALSOFT_EMBED_HRTF_DATA) - MACRO(make_hrtf_header FILENAME VARNAME) - SET(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}") - SET(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.h") + macro(make_hrtf_header FILENAME VARNAME) + set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}") + set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.h") - ADD_CUSTOM_COMMAND(OUTPUT "${outfile}" + add_custom_command(OUTPUT "${outfile}" COMMAND ${CMAKE_COMMAND} -D "INPUT_FILE=${infile}" -D "OUTPUT_FILE=${outfile}" -D "VARIABLE_NAME=${VARNAME}" -P "${CMAKE_MODULE_PATH}/bin2h.script.cmake" WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" DEPENDS "${infile}" "${CMAKE_MODULE_PATH}/bin2h.script.cmake" VERBATIM ) - SET(ALC_OBJS ${ALC_OBJS} "${outfile}") - ENDMACRO() + set(ALC_OBJS ${ALC_OBJS} "${outfile}") + endmacro() make_hrtf_header("Default HRTF.mhr" "hrtf_default") endif() -IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL) +if(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL) find_package(Qt5Widgets) -ENDIF() -IF(ALSOFT_EXAMPLES) - FIND_PACKAGE(SndFile) - FIND_PACKAGE(SDL2) - IF(SDL2_FOUND) - FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE) - ENDIF() -ENDIF() - -IF(NOT WIN32) - SET(LIBNAME "openal") -ELSE() - SET(LIBNAME "OpenAL32") -ENDIF() +endif() +if(ALSOFT_EXAMPLES) + find_package(SndFile) + find_package(SDL2) + if(SDL2_FOUND) + find_package(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE) + endif() +endif() + +if(NOT WIN32) + set(LIBNAME "openal") +else() + set(LIBNAME "OpenAL32") +endif() # Needed for openal.pc.in -SET(prefix ${CMAKE_INSTALL_PREFIX}) -SET(exec_prefix "\${prefix}") -SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") -SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}") -SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") -SET(PACKAGE_VERSION "${LIB_VERSION}") -SET(PKG_CONFIG_CFLAGS ) -SET(PKG_CONFIG_PRIVATE_LIBS ) -IF(LIBTYPE STREQUAL "STATIC") - SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC) - FOREACH(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix "\${prefix}") +set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") +set(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}") +set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +set(PACKAGE_VERSION "${LIB_VERSION}") +set(PKG_CONFIG_CFLAGS ) +set(PKG_CONFIG_PRIVATE_LIBS ) +if(LIBTYPE STREQUAL "STATIC") + set(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC) + foreach(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) # If this is already a linker flag, or is a full path+file, add it # as-is. Otherwise, it's a name intended to be dressed as -lname. - IF(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}") - SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}") - ELSE() - SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}") - ENDIF() - ENDFOREACH() -ENDIF() + if(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}") + set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}") + else() + set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}") + endif() + endforeach() +endif() # End configuration -CONFIGURE_FILE( +configure_file( "${OpenAL_SOURCE_DIR}/config.h.in" "${OpenAL_BINARY_DIR}/config.h") -CONFIGURE_FILE( +configure_file( "${OpenAL_SOURCE_DIR}/openal.pc.in" "${OpenAL_BINARY_DIR}/openal.pc" @ONLY) -ADD_LIBRARY(common STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS}) -TARGET_INCLUDE_DIRECTORIES(common PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/include) -TARGET_COMPILE_DEFINITIONS(common PRIVATE ${CPP_DEFS}) -TARGET_COMPILE_OPTIONS(common PRIVATE ${C_FLAGS}) -SET_TARGET_PROPERTIES(common PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +add_library(common STATIC EXCLUDE_FROM_ALL ${COMMON_OBJS}) +target_include_directories(common PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/include) +target_compile_definitions(common PRIVATE ${CPP_DEFS}) +target_compile_options(common PRIVATE ${C_FLAGS}) +set_target_properties(common PROPERTIES POSITION_INDEPENDENT_CODE TRUE) -UNSET(HAS_ROUTER) -SET(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal. +unset(HAS_ROUTER) +set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal. # Build main library -IF(LIBTYPE STREQUAL "STATIC") +if(LIBTYPE STREQUAL "STATIC") add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS}) target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC) target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) @@ -1176,21 +1176,21 @@ IF(LIBTYPE STREQUAL "STATIC") target_compile_definitions(${IMPL_TARGET} PRIVATE AL_NO_UID_DEFS) endif() endif() -ELSE() - SET(RC_CONFIG resources/openal32.rc) - IF(WIN32 AND ALSOFT_BUILD_ROUTER) - ADD_LIBRARY(OpenAL SHARED +else() + set(RC_CONFIG resources/openal32.rc) + if(WIN32 AND ALSOFT_BUILD_ROUTER) + add_library(OpenAL SHARED resources/router.rc router/router.cpp router/router.h router/alc.cpp router/al.cpp ) - TARGET_COMPILE_DEFINITIONS(OpenAL + target_compile_definitions(OpenAL PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS}) - TARGET_COMPILE_OPTIONS(OpenAL PRIVATE ${C_FLAGS}) - TARGET_LINK_LIBRARIES(OpenAL PRIVATE common ${LINKER_FLAGS}) - TARGET_INCLUDE_DIRECTORIES(OpenAL + target_compile_options(OpenAL PRIVATE ${C_FLAGS}) + target_link_libraries(OpenAL PRIVATE common ${LINKER_FLAGS}) + target_include_directories(OpenAL PUBLIC $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> @@ -1198,26 +1198,26 @@ ELSE() ${OpenAL_SOURCE_DIR}/common ${OpenAL_BINARY_DIR} ) - SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "") - SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME}) - IF(TARGET build_version) - ADD_DEPENDENCIES(OpenAL build_version) - ENDIF() - SET(HAS_ROUTER 1) - - SET(LIBNAME "soft_oal") - SET(IMPL_TARGET soft_oal) - SET(RC_CONFIG resources/soft_oal.rc) - ENDIF() - - ADD_LIBRARY(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${RC_CONFIG}) - IF(WIN32) - SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES PREFIX "") - ENDIF() - TARGET_LINK_LIBRARIES(${IMPL_TARGET} PRIVATE common ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) -ENDIF() - -TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET} + set_target_properties(OpenAL PROPERTIES PREFIX "") + set_target_properties(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME}) + if(TARGET build_version) + add_dependencies(OpenAL build_version) + endif() + set(HAS_ROUTER 1) + + set(LIBNAME "soft_oal") + set(IMPL_TARGET soft_oal) + set(RC_CONFIG resources/soft_oal.rc) + endif() + + add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${RC_CONFIG}) + if(WIN32) + set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "") + endif() + target_link_libraries(${IMPL_TARGET} PRIVATE common ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) +endif() + +target_include_directories(${IMPL_TARGET} PUBLIC $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> @@ -1229,61 +1229,61 @@ TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET} ${OpenAL_SOURCE_DIR}/common ) -SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME} +set_target_properties(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME} VERSION ${LIB_VERSION} SOVERSION ${LIB_MAJOR_VERSION} ) -TARGET_COMPILE_DEFINITIONS(${IMPL_TARGET} +target_compile_definitions(${IMPL_TARGET} PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS}) -TARGET_COMPILE_OPTIONS(${IMPL_TARGET} PRIVATE ${C_FLAGS}) - -IF(TARGET build_version) - ADD_DEPENDENCIES(${IMPL_TARGET} build_version) -ENDIF() - -IF(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC") - FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable") - FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable") - IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE) - MESSAGE(STATUS "") - IF(NOT SED_EXECUTABLE) - MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation") - ENDIF() - IF(NOT DLLTOOL_EXECUTABLE) - MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation") - ENDIF() - ELSE() - SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY +target_compile_options(${IMPL_TARGET} PRIVATE ${C_FLAGS}) + +if(TARGET build_version) + add_dependencies(${IMPL_TARGET} build_version) +endif() + +if(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC") + find_program(SED_EXECUTABLE NAMES sed DOC "sed executable") + find_program(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable") + if(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE) + message(STATUS "") + if(NOT SED_EXECUTABLE) + message(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation") + endif() + if(NOT DLLTOOL_EXECUTABLE) + message(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation") + endif() + else() + set_propertySET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--output-def,OpenAL32.def") - ADD_CUSTOM_COMMAND(TARGET OpenAL POST_BUILD + add_custom_command(TARGET OpenAL POST_BUILD COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def COMMAND "${DLLTOOL_EXECUTABLE}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..." VERBATIM ) - ENDIF() -ENDIF() + endif() +endif() if(HAS_ROUTER) message(STATUS "") message(STATUS "Building DLL router") endif() -MESSAGE(STATUS "") -MESSAGE(STATUS "Building OpenAL with support for the following backends:") -MESSAGE(STATUS " ${BACKENDS}") -MESSAGE(STATUS "") -MESSAGE(STATUS "Building with support for CPU extensions:") -MESSAGE(STATUS " ${CPU_EXTS}") -MESSAGE(STATUS "") -IF(FPMATH_SET) - MESSAGE(STATUS "Building with SSE${FPMATH_SET} codegen") - MESSAGE(STATUS "") -ENDIF() +message(STATUS " +Building OpenAL with support for the following backends: + ${BACKENDS} + +Building with support for CPU extensions: + ${CPU_EXTS} +") +if(FPMATH_SET) + message(STATUS "Building with SSE${FPMATH_SET} codegen +") +endif() if(ALSOFT_EMBED_HRTF_DATA) - message(STATUS "Embedding HRTF datasets") - message(STATUS "") + message(STATUS "Embedding HRTF datasets +") endif() # Install main library @@ -1334,10 +1334,10 @@ message(STATUS "") set(EXTRA_INSTALLS ) if(ALSOFT_UTILS) - ADD_EXECUTABLE(openal-info utils/openal-info.c) - TARGET_INCLUDE_DIRECTORIES(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common) - TARGET_COMPILE_OPTIONS(openal-info PRIVATE ${C_FLAGS}) - TARGET_LINK_LIBRARIES(openal-info PRIVATE ${LINKER_FLAGS} OpenAL) + add_executable(openal-info utils/openal-info.c) + target_include_directories(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common) + target_compile_options(openal-info PRIVATE ${C_FLAGS}) + target_link_libraries(openal-info PRIVATE ${LINKER_FLAGS} OpenAL) if(ALSOFT_INSTALL_EXAMPLES) set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info) endif() @@ -1390,13 +1390,13 @@ endif() # Add a static library with common functions used by multiple example targets -ADD_LIBRARY(ex-common STATIC EXCLUDE_FROM_ALL +add_library(ex-common STATIC EXCLUDE_FROM_ALL examples/common/alhelpers.c examples/common/alhelpers.h) -TARGET_COMPILE_DEFINITIONS(ex-common PUBLIC ${CPP_DEFS}) -TARGET_INCLUDE_DIRECTORIES(ex-common PUBLIC ${OpenAL_SOURCE_DIR}/common) -TARGET_COMPILE_OPTIONS(ex-common PUBLIC ${C_FLAGS}) -TARGET_LINK_LIBRARIES(ex-common PUBLIC OpenAL PRIVATE ${RT_LIB}) +target_compile_definitions(ex-common PUBLIC ${CPP_DEFS}) +target_include_directories(ex-common PUBLIC ${OpenAL_SOURCE_DIR}/common) +target_compile_options(ex-common PUBLIC ${C_FLAGS}) +target_link_libraries(ex-common PUBLIC OpenAL PRIVATE ${RT_LIB}) if(ALSOFT_EXAMPLES) add_executable(altonegen examples/altonegen.c) @@ -1443,57 +1443,57 @@ if(ALSOFT_EXAMPLES) message(STATUS "Building SndFile example programs") endif() - IF(SDL2_FOUND) - ADD_EXECUTABLE(alloopback examples/alloopback.c) - TARGET_INCLUDE_DIRECTORIES(alloopback PRIVATE ${SDL2_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(alloopback + if(SDL2_FOUND) + add_executable(alloopback examples/alloopback.c) + target_include_directories(alloopback PRIVATE ${SDL2_INCLUDE_DIR}) + target_link_libraries(alloopback PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ex-common ${MATH_LIB}) if(ALSOFT_INSTALL_EXAMPLES) set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback) endif() - MESSAGE(STATUS "Building SDL example programs") - - SET(FFVER_OK FALSE) - IF(FFMPEG_FOUND) - SET(FFVER_OK TRUE) - IF(AVFORMAT_VERSION VERSION_LESS "57.56.101") - MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 57.56.101)") - SET(FFVER_OK FALSE) - ENDIF() - IF(AVCODEC_VERSION VERSION_LESS "57.64.101") - MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 57.64.101)") - SET(FFVER_OK FALSE) - ENDIF() - IF(AVUTIL_VERSION VERSION_LESS "55.34.101") - MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 55.34.101)") - SET(FFVER_OK FALSE) - ENDIF() - IF(SWSCALE_VERSION VERSION_LESS "4.2.100") - MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 4.2.100)") - SET(FFVER_OK FALSE) - ENDIF() - IF(SWRESAMPLE_VERSION VERSION_LESS "2.3.100") - MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 2.3.100)") - SET(FFVER_OK FALSE) - ENDIF() - ENDIF() - IF(FFVER_OK) - ADD_EXECUTABLE(alffplay examples/alffplay.cpp) - TARGET_INCLUDE_DIRECTORIES(alffplay + message(STATUS "Building SDL example programs") + + set(FFVER_OK FALSE) + if(FFMPEG_FOUND) + set(FFVER_OK TRUE) + if(AVFORMAT_VERSION VERSION_LESS "57.56.101") + message(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 57.56.101)") + set(FFVER_OK FALSE) + endif() + if(AVCODEC_VERSION VERSION_LESS "57.64.101") + message(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 57.64.101)") + set(FFVER_OK FALSE) + endif() + if(AVUTIL_VERSION VERSION_LESS "55.34.101") + message(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 55.34.101)") + set(FFVER_OK FALSE) + endif() + if(SWSCALE_VERSION VERSION_LESS "4.2.100") + message(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 4.2.100)") + set(FFVER_OK FALSE) + endif() + if(SWRESAMPLE_VERSION VERSION_LESS "2.3.100") + message(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 2.3.100)") + set(FFVER_OK FALSE) + endif() + endif() + if(FFVER_OK) + add_executable(alffplay examples/alffplay.cpp) + target_include_directories(alffplay PRIVATE ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(alffplay + target_link_libraries(alffplay PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} ex-common) if(ALSOFT_INSTALL_EXAMPLES) set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay) endif() message(STATUS "Building SDL+FFmpeg example programs") - ENDIF() - ENDIF() - MESSAGE(STATUS "") -ENDIF() + endif() + endif() + message(STATUS "") +endif() if(EXTRA_INSTALLS) install(TARGETS ${EXTRA_INSTALLS} |