diff options
author | Sven Gothel <[email protected]> | 2023-05-03 16:17:49 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-03 16:17:49 +0200 |
commit | ec167fd05661a5b02dd406c87081f84a0f8dd77d (patch) | |
tree | 9c4669e471c9969bda59265381b18d2d416db060 /CMakeLists.txt | |
parent | 0d14d30808cfe7b9e3413353e3eef8a0f201399a (diff) | |
parent | d3875f333fb6abe2f39d82caca329414871ae53b (diff) |
Merge branch 'v1.23.1'
Resolved Conflicts:
CMakeLists.txt
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 2614 |
1 files changed, 1410 insertions, 1204 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 824659b7..963c4346 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,67 +2,128 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0) -PROJECT(OpenAL) - -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) - CMAKE_POLICY(SET CMP0005 NEW) - IF(POLICY CMP0020) - CMAKE_POLICY(SET CMP0020 NEW) - ENDIF(POLICY CMP0020) - IF(POLICY CMP0042) - CMAKE_POLICY(SET CMP0042 NEW) - ENDIF(POLICY CMP0042) - IF(POLICY CMP0054) - CMAKE_POLICY(SET CMP0054 NEW) - ENDIF(POLICY CMP0054) - IF(POLICY CMP0075) - CMAKE_POLICY(SET CMP0075 NEW) - ENDIF(POLICY CMP0075) -ENDIF(COMMAND CMAKE_POLICY) - -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING +if(APPLE) + # The workaround for try_compile failing with code signing + # since cmake-3.18.2, not required + set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + ${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES} + "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED" + "CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED") + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + # Fix compile failure with armv7 deployment target >= 11.0, xcode clang + # will report: + # error: invalid iOS deployment version '--target=armv7-apple-ios13.6', + # iOS 10 is the maximum deployment target for 32-bit targets + # If CMAKE_OSX_DEPLOYMENT_TARGET is not defined, cmake will choose latest + # deployment target + if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*armv7.*") + if(NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET + OR NOT CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "11.0") + message(STATUS "Forcing iOS deployment target to 10.0 for armv7") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.0" CACHE STRING "Minimum OS X deployment version" + FORCE) + endif() + endif() +endif() + +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +if(COMMAND CMAKE_POLICY) + cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0005 NEW) + if(POLICY CMP0020) + cmake_policy(SET CMP0020 NEW) + endif(POLICY CMP0020) + if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) + endif(POLICY CMP0042) + if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) + endif(POLICY CMP0054) + if(POLICY CMP0058) + cmake_policy(SET CMP0058 NEW) + endif(POLICY CMP0058) + if(POLICY CMP0063) + cmake_policy(SET CMP0063 NEW) + endif(POLICY CMP0063) + if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) + endif(POLICY CMP0075) + if(POLICY CMP0092) + cmake_policy(SET CMP0092 NEW) + endif(POLICY CMP0092) + if(POLICY CMP0117) + cmake_policy(SET CMP0117 NEW) + endif(POLICY CMP0117) +endif(COMMAND CMAKE_POLICY) + +project(OpenAL) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) -ENDIF() -IF(NOT CMAKE_DEBUG_POSTFIX) - SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING +endif() +if(NOT CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Library postfix for debug builds. Normally left blank." FORCE) -ENDIF() - -SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake") - +endif() -INCLUDE(CheckFunctionExists) -INCLUDE(CheckLibraryExists) -INCLUDE(CheckIncludeFile) -INCLUDE(CheckIncludeFiles) -INCLUDE(CheckSymbolExists) -INCLUDE(CheckCCompilerFlag) -INCLUDE(CheckCXXCompilerFlag) -INCLUDE(CheckCSourceCompiles) -INCLUDE(CheckCXXSourceCompiles) -INCLUDE(CheckTypeSize) +set(DEFAULT_TARGET_PROPS + # Require C++14. + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED TRUE + # Prefer C11, but support C99 and earlier when possible. + C_STANDARD 11) + +set(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake") + +include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckSymbolExists) +include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) include(CheckStructHasMember) +include(CMakePackageConfigHelpers) include(GNUInstallDirs) +find_package(PkgConfig) +find_package(SDL2 QUIET) -OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON) -OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF) +option(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON) -OPTION(ALSOFT_UTILS "Build and install utility programs" ON) -OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF) +option(ALSOFT_WERROR "Treat compile warnings as errors" OFF) -OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON) -OPTION(ALSOFT_TESTS "Build and install test programs" ON) +option(ALSOFT_UTILS "Build utility programs" ON) +option(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF) -OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON) -OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON) -OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON) -OPTION(ALSOFT_INSTALL "Install headers and libraries" ON) +option(ALSOFT_EXAMPLES "Build example programs" ON) + +option(ALSOFT_INSTALL "Install main library" ON) +option(ALSOFT_INSTALL_CONFIG "Install alsoft.conf sample configuration file" ON) +option(ALSOFT_INSTALL_HRTF_DATA "Install HRTF data files" ON) +option(ALSOFT_INSTALL_AMBDEC_PRESETS "Install AmbDec preset files" ON) +option(ALSOFT_INSTALL_EXAMPLES "Install example programs (alplay, alstream, ...)" ON) +option(ALSOFT_INSTALL_UTILS "Install utility programs (openal-info, alsoft-config, ...)" ON) +option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON) + +option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32}) + +option(ALSOFT_SEARCH_INSTALL_DATADIR "Search the installation data directory" OFF) +if(ALSOFT_SEARCH_INSTALL_DATADIR) + set(ALSOFT_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}) +endif() if(DEFINED SHARE_INSTALL_DIR) message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead") @@ -72,160 +133,167 @@ endif() if(DEFINED LIB_SUFFIX) message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead") endif() +if(DEFINED ALSOFT_CONFIG) + message(WARNING "ALSOFT_CONFIG is deprecated. Use ALSOFT_INSTALL_CONFIG instead") +endif() +if(DEFINED ALSOFT_HRTF_DEFS) + message(WARNING "ALSOFT_HRTF_DEFS is deprecated. Use ALSOFT_INSTALL_HRTF_DATA instead") +endif() +if(DEFINED ALSOFT_AMBDEC_PRESETS) + message(WARNING "ALSOFT_AMBDEC_PRESETS is deprecated. Use ALSOFT_INSTALL_AMBDEC_PRESETS instead") +endif() -SET(CPP_DEFS ) # C pre-processor, not C++ -SET(INC_PATHS ) -SET(C_FLAGS ) -SET(LINKER_FLAGS ) -SET(EXTRA_LIBS ) - -IF(WIN32) - SET(CPP_DEFS ${CPP_DEFS} _WIN32 _WIN32_WINNT=0x0502) - - OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF) +set(CPP_DEFS ) # C pre-processor, not C++ +set(INC_PATHS ) +set(C_FLAGS ) +set(LINKER_FLAGS ) +set(EXTRA_LIBS ) - # This option is mainly for static linking OpenAL Soft into another project - # that already defines the IDs. It is up to that project to ensure all - # required IDs are defined. - OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF) +if(WIN32) + set(CPP_DEFS ${CPP_DEFS} _WIN32 NOMINMAX) + if(MINGW) + set(CPP_DEFS ${CPP_DEFS} __USE_MINGW_ANSI_STDIO) + endif() - IF(MINGW) - OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON) - IF(NOT DLLTOOL) - IF(HOST) - SET(DLLTOOL "${HOST}-dlltool") - ELSE() - SET(DLLTOOL "dlltool") - ENDIF() - ENDIF() - ENDIF() -ENDIF() + option(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF) + if(MINGW) + option(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON) + endif() +elseif(APPLE) + option(ALSOFT_OSX_FRAMEWORK "Build as macOS framework" OFF) +endif() # QNX's gcc do not uses /usr/include and /usr/lib pathes by default -IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX") - SET(INC_PATHS ${INC_PATHS} /usr/include) - SET(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib) -ENDIF() - -IF(NOT LIBTYPE) - SET(LIBTYPE SHARED) -ENDIF() - -SET(LIB_MAJOR_VERSION "1") -SET(LIB_MINOR_VERSION "20") -SET(LIB_REVISION "0") -SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}") -SET(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0) - -SET(EXPORT_DECL "") - - -CHECK_TYPE_SIZE("long" SIZEOF_LONG) +if("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX") + set(INC_PATHS ${INC_PATHS} /usr/include) + set(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib) +endif() +# When the library is built for static linking, apps should define +# AL_LIBTYPE_STATIC when including the AL headers. +if(NOT LIBTYPE) + set(LIBTYPE SHARED) +endif() -# Require C++11 -SET(CMAKE_CXX_STANDARD 11) -SET(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(LIB_MAJOR_VERSION "1") +set(LIB_MINOR_VERSION "23") +set(LIB_REVISION "1") +set(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}") +set(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0) -# Prefer C11, but support C99 and C90 too. -SET(CMAKE_C_STANDARD 11) +set(EXPORT_DECL "") if(NOT WIN32) # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions - CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT) - IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT) - SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600") - CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX) - IF(NOT HAVE_POSIX_MEMALIGN_POSIX) - SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) - ELSE() - SET(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600) - ENDIF() - ENDIF() - UNSET(OLD_REQUIRED_FLAGS) -ENDIF() + check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT) + if(NOT HAVE_POSIX_MEMALIGN_DEFAULT) + set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600") + check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX) + if(NOT HAVE_POSIX_MEMALIGN_POSIX) + set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) + else() + set(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600) + endif() + endif() + unset(OLD_REQUIRED_FLAGS) +endif() # C99 has restrict, but C++ does not, so we can only utilize __restrict. -SET(RESTRICT_DECL ) -CHECK_CXX_SOURCE_COMPILES("int *__restrict foo; +check_cxx_source_compiles("int *__restrict foo; int main() { return 0; }" HAVE___RESTRICT) -IF(HAVE___RESTRICT) - SET(RESTRICT_DECL "__restrict") -ENDIF() +if(HAVE___RESTRICT) + set(CPP_DEFS ${CPP_DEFS} RESTRICT=__restrict) +else() + set(CPP_DEFS ${CPP_DEFS} "RESTRICT=") +endif() # Some systems may need libatomic for atomic functions to work -SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) -SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic) -CHECK_CXX_SOURCE_COMPILES("#include <atomic> +set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic) +check_cxx_source_compiles("#include <atomic> std::atomic<int> foo{0}; int main() { return foo.fetch_add(2); }" HAVE_LIBATOMIC) -IF(NOT HAVE_LIBATOMIC) - SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}") -ELSE() - SET(EXTRA_LIBS atomic ${EXTRA_LIBS}) -ENDIF() -UNSET(OLD_REQUIRED_LIBRARIES) - -# Include liblog for Android logging -CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG) -IF(HAVE_LIBLOG) - SET(EXTRA_LIBS log ${EXTRA_LIBS}) - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log) -ENDIF() - -IF(MSVC) - SET(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS NOMINMAX) - CHECK_CXX_COMPILER_FLAG(/permissive- HAVE_PERMISSIVE_SWITCH) - IF(HAVE_PERMISSIVE_SWITCH) - SET(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->) - ENDIF() - SET(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4268 /wd4324) +if(NOT HAVE_LIBATOMIC) + set(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}") +else() + set(EXTRA_LIBS atomic ${EXTRA_LIBS}) +endif() +unset(OLD_REQUIRED_LIBRARIES) + +if(ANDROID) + # Include liblog for Android logging + check_library_exists(log __android_log_print "" HAVE_LIBLOG) + if(HAVE_LIBLOG) + set(EXTRA_LIBS log ${EXTRA_LIBS}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log) + endif() +endif() - IF(NOT DXSDK_DIR) - STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}") - ELSE() - STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}") - ENDIF() - IF(DXSDK_DIR) - MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}") - ENDIF() +if(MSVC) + set(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS) + check_cxx_compiler_flag(/permissive- HAVE_PERMISSIVE_SWITCH) + if(HAVE_PERMISSIVE_SWITCH) + set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:/permissive->) + endif() + set(C_FLAGS ${C_FLAGS} /W4 /w14640 /wd4065 /wd4127 /wd4268 /wd4324 /wd5030 /wd5051) + + if(NOT DXSDK_DIR) + string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}") + else() + string(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}") + endif() + if(DXSDK_DIR) + message(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}") + endif() - OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF) - IF(FORCE_STATIC_VCRT) - FOREACH(flag_var + option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF) + if(FORCE_STATIC_VCRT) + foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) - IF(${flag_var} MATCHES "/MD") - STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - ENDIF() - ENDFOREACH(flag_var) - ENDIF() -ELSE() - SET(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif() + endforeach(flag_var) + endif() +else() + set(C_FLAGS ${C_FLAGS} -Winline -Wunused -Wall -Wextra -Wshadow -Wconversion -Wcast-align -Wpedantic $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual>) - IF(ALSOFT_WERROR) - SET(C_FLAGS ${C_FLAGS} -Werror) - ENDIF() + check_cxx_compiler_flag(-Wno-c++20-attribute-extensions HAVE_WNO_CXX20_ATTR_EXT) + if(HAVE_WNO_CXX20_ATTR_EXT) + set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-attribute-extensions>) + else() + check_cxx_compiler_flag(-Wno-c++20-extensions HAVE_WNO_CXX20_EXT) + if(HAVE_WNO_CXX20_EXT) + set(C_FLAGS ${C_FLAGS} $<$<COMPILE_LANGUAGE:CXX>:-Wno-c++20-extensions>) + endif() + endif() + + if(ALSOFT_WERROR) + set(C_FLAGS ${C_FLAGS} -Werror) + endif() # We want RelWithDebInfo to actually include debug stuff (define _DEBUG # instead of NDEBUG) - FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO) - IF(${flag_var} MATCHES "-DNDEBUG") - STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}") - ENDIF() - ENDFOREACH() + foreach(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "-DNDEBUG") + string(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}") + endif() + endforeach() - CHECK_C_COMPILER_FLAG(-fno-math-errno HAVE_FNO_MATH_ERRNO) - IF(HAVE_FNO_MATH_ERRNO) - SET(C_FLAGS ${C_FLAGS} -fno-math-errno) - ENDIF() + check_c_compiler_flag(-fno-math-errno HAVE_FNO_MATH_ERRNO) + if(HAVE_FNO_MATH_ERRNO) + set(C_FLAGS ${C_FLAGS} -fno-math-errno) + endif() option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF) if(ALSOFT_STATIC_LIBGCC) @@ -270,190 +338,225 @@ ELSE() set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state") endif() endif() -ENDIF() +endif() # Set visibility/export options if available -IF(WIN32) - SET(EXPORT_DECL "__declspec(dllexport)") -ELSE() - SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") +if(WIN32) + if(NOT LIBTYPE STREQUAL "STATIC") + set(EXPORT_DECL "__declspec(dllexport)") + endif() +else() + set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") # Yes GCC, really don't accept visibility modes you don't support - SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror") + set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror") - CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\"))); + check_c_source_compiles("int foo() __attribute__((visibility(\"protected\"))); int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY) - IF(HAVE_GCC_PROTECTED_VISIBILITY) - SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))") - ELSE() - CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\"))); + if(HAVE_GCC_PROTECTED_VISIBILITY) + if(NOT LIBTYPE STREQUAL "STATIC") + set(EXPORT_DECL "__attribute__((visibility(\"protected\")))") + endif() + else() + check_c_source_compiles("int foo() __attribute__((visibility(\"default\"))); int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY) - IF(HAVE_GCC_DEFAULT_VISIBILITY) - SET(EXPORT_DECL "__attribute__((visibility(\"default\")))") - ENDIF() - ENDIF() + if(HAVE_GCC_DEFAULT_VISIBILITY) + if(NOT LIBTYPE STREQUAL "STATIC") + set(EXPORT_DECL "__attribute__((visibility(\"default\")))") + endif() + endif() + endif() - IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY) - CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH) - IF(HAVE_VISIBILITY_HIDDEN_SWITCH) - SET(C_FLAGS ${C_FLAGS} -fvisibility=hidden) - ENDIF() - ENDIF() + set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}") +endif() - SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}") -ENDIF() - -SET(SSE2_SWITCH "") -SET(SSE3_SWITCH "") -SET(SSE4_1_SWITCH "") -SET(FPU_NEON_SWITCH "") - -CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH) -IF(HAVE_MSSE2_SWITCH) - SET(SSE2_SWITCH "-msse2") -ENDIF() -CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH) -IF(HAVE_MSSE3_SWITCH) - SET(SSE3_SWITCH "-msse3") -ENDIF() -CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH) -IF(HAVE_MSSE4_1_SWITCH) - SET(SSE4_1_SWITCH "-msse4.1") -ENDIF() -CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH) -IF(HAVE_MFPU_NEON_SWITCH) - SET(FPU_NEON_SWITCH "-mfpu=neon") -ENDIF() - -CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}") -CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}") -CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}") -CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}") -CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}") - -SET(SSE_FLAGS ) -SET(FPMATH_SET "0") -IF(CMAKE_SIZEOF_VOID_P MATCHES "4") - IF(SSE2_SWITCH OR MSVC) - OPTION(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE) - ENDIF() - IF(ALSOFT_ENABLE_SSE2_CODEGEN) - IF(SSE2_SWITCH) - CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2) - IF(HAVE_MFPMATH_SSE_2) - SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse) - SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) - SET(FPMATH_SET 2) - ENDIF() - ELSEIF(MSVC) - CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2) - IF(HAVE_ARCH_SSE2) - SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2") - SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) - SET(FPMATH_SET 2) - ENDIF() - ENDIF() - ENDIF() -ENDIF() +set(SSE2_SWITCH "") + +if(NOT MSVC) + set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + # Yes GCC, really don't accept command line options you don't support + set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror") + check_c_compiler_flag(-msse2 HAVE_MSSE2_SWITCH) + if(HAVE_MSSE2_SWITCH) + set(SSE2_SWITCH "-msse2") + endif() + set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) + unset(OLD_REQUIRED_FLAGS) +endif() + +check_include_file(xmmintrin.h HAVE_XMMINTRIN_H) +check_include_file(emmintrin.h HAVE_EMMINTRIN_H) +check_include_file(pmmintrin.h HAVE_PMMINTRIN_H) +check_include_file(smmintrin.h HAVE_SMMINTRIN_H) +check_include_file(arm_neon.h HAVE_ARM_NEON_H) + +set(HAVE_SSE 0) +set(HAVE_SSE2 0) +set(HAVE_SSE3 0) +set(HAVE_SSE4_1 0) +set(HAVE_NEON 0) + +# Check for SSE support +option(ALSOFT_CPUEXT_SSE "Enable SSE support" ON) +option(ALSOFT_REQUIRE_SSE "Require SSE support" OFF) +if(ALSOFT_CPUEXT_SSE AND HAVE_XMMINTRIN_H) + set(HAVE_SSE 1) +endif() +if(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE) + message(FATAL_ERROR "Failed to enabled required SSE CPU extensions") +endif() -IF(HAVE_EMMINTRIN_H) - SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - FOREACH(flag_var ${SSE_FLAGS}) - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}") - ENDFOREACH() +option(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON) +option(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF) +if(ALSOFT_CPUEXT_SSE2 AND HAVE_SSE AND HAVE_EMMINTRIN_H) + set(HAVE_SSE2 1) +endif() +if(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2) + message(FATAL_ERROR "Failed to enable required SSE2 CPU extensions") +endif() - CHECK_C_SOURCE_COMPILES("#include <emmintrin.h> - int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS) +option(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON) +option(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF) +if(ALSOFT_CPUEXT_SSE3 AND HAVE_SSE2 AND HAVE_PMMINTRIN_H) + set(HAVE_SSE3 1) +endif() +if(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3) + message(FATAL_ERROR "Failed to enable required SSE3 CPU extensions") +endif() - SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) -ENDIF() +option(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON) +option(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF) +if(ALSOFT_CPUEXT_SSE4_1 AND HAVE_SSE3 AND HAVE_SMMINTRIN_H) + set(HAVE_SSE4_1 1) +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_CPUEXT_NEON "Enable ARM NEON support" ON) +option(ALSOFT_REQUIRE_NEON "Require ARM NEON support" OFF) +if(ALSOFT_CPUEXT_NEON AND HAVE_ARM_NEON_H) + check_c_source_compiles("#include <arm_neon.h> + int main() + { + int32x4_t ret4 = vdupq_n_s32(0); + return vgetq_lane_s32(ret4, 0); + }" HAVE_NEON_INTRINSICS) + if(HAVE_NEON_INTRINSICS) + set(HAVE_NEON 1) + endif() +endif() +if(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON) + message(FATAL_ERROR "Failed to enabled required ARM NEON CPU extensions") +endif() -CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2))); - int main() {return 0;}" HAVE_GCC_FORMAT) -CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H) -CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) -CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H) -CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H) -CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H) -CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H) -IF(NOT HAVE_GUIDDEF_H) - CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H) -ENDIF() +set(SSE_FLAGS ) +set(FPMATH_SET "0") +if(CMAKE_SIZEOF_VOID_P MATCHES "4" AND HAVE_SSE2) + option(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE) + if(ALSOFT_ENABLE_SSE2_CODEGEN) + if(MSVC) + check_c_compiler_flag("/arch:SSE2" HAVE_ARCH_SSE2) + if(HAVE_ARCH_SSE2) + set(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2") + set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) + set(FPMATH_SET 2) + endif() + elseif(SSE2_SWITCH) + check_c_compiler_flag("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2) + if(HAVE_MFPMATH_SSE_2) + set(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse) + set(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) + set(FPMATH_SET 2) + endif() + # SSE depends on a 16-byte aligned stack, and by default, GCC + # assumes the stack is suitably aligned. Older Linux code or other + # OSs don't guarantee this on 32-bit, so externally-callable + # functions need to ensure an aligned stack. + set(EXPORT_DECL "${EXPORT_DECL}__attribute__((force_align_arg_pointer))") + endif() + endif() +endif() + +if(HAVE_SSE2) + set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + foreach(flag_var ${SSE_FLAGS}) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}") + endforeach() + + check_c_source_compiles("#include <emmintrin.h> + int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS) + + set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) +endif() + + +check_include_file(malloc.h HAVE_MALLOC_H) +check_include_file(cpuid.h HAVE_CPUID_H) +check_include_file(intrin.h HAVE_INTRIN_H) +check_include_file(guiddef.h HAVE_GUIDDEF_H) +if(NOT HAVE_GUIDDEF_H) + check_include_file(initguid.h HAVE_INITGUID_H) +endif() # Some systems need libm for some math functions to work -SET(MATH_LIB ) -CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM) -IF(HAVE_LIBM) - SET(MATH_LIB ${MATH_LIB} m) - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) -ENDIF() +set(MATH_LIB ) +check_library_exists(m pow "" HAVE_LIBM) +if(HAVE_LIBM) + set(MATH_LIB ${MATH_LIB} m) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) +endif() # Some systems need to link with -lrt for clock_gettime as used by the common # eaxmple functions. -SET(RT_LIB ) -CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT) -IF(HAVE_LIBRT) - SET(RT_LIB rt) -ENDIF() +set(RT_LIB ) +check_library_exists(rt clock_gettime "" HAVE_LIBRT) +if(HAVE_LIBRT) + set(RT_LIB rt) +endif() # Check for the dlopen API (for dynamicly loading backend libs) -IF(ALSOFT_DLOPEN) - CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) - CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL) - IF(HAVE_LIBDL) - SET(EXTRA_LIBS dl ${EXTRA_LIBS}) - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl) - ENDIF() -ENDIF() +if(ALSOFT_DLOPEN) + check_include_file(dlfcn.h HAVE_DLFCN_H) + check_library_exists(dl dlopen "" HAVE_LIBDL) + if(HAVE_LIBDL) + set(EXTRA_LIBS dl ${EXTRA_LIBS}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl) + endif() +endif() # Check for a cpuid intrinsic -IF(HAVE_CPUID_H) - CHECK_C_SOURCE_COMPILES("#include <cpuid.h> +if(HAVE_CPUID_H) + check_c_source_compiles("#include <cpuid.h> int main() { unsigned int eax, ebx, ecx, edx; return __get_cpuid(0, &eax, &ebx, &ecx, &edx); }" HAVE_GCC_GET_CPUID) -ENDIF() -IF(HAVE_INTRIN_H) - CHECK_C_SOURCE_COMPILES("#include <intrin.h> +endif() +if(HAVE_INTRIN_H) + check_c_source_compiles("#include <intrin.h> int main() { int regs[4]; __cpuid(regs, 0); return regs[0]; }" HAVE_CPUID_INTRINSIC) - CHECK_C_SOURCE_COMPILES("#include <intrin.h> - int main() - { - unsigned long idx = 0; - _BitScanForward64(&idx, 1); - return idx; - }" HAVE_BITSCANFORWARD64_INTRINSIC) - CHECK_C_SOURCE_COMPILES("#include <intrin.h> - int main() - { - unsigned long idx = 0; - _BitScanForward(&idx, 1); - return idx; - }" HAVE_BITSCANFORWARD_INTRINSIC) -ENDIF() - -CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) -CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC) -CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH) +endif() -CHECK_FUNCTION_EXISTS(stat HAVE_STAT) +check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) +check_symbol_exists(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC) +check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH) -IF(NOT WIN32) +if(NOT WIN32) # We need pthreads outside of Windows, for semaphores. It's also used to # set the priority and name of threads, when possible. - CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) - IF(NOT HAVE_PTHREAD_H) - MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!") - ENDIF() + check_include_file(pthread.h HAVE_PTHREAD_H) + if(NOT HAVE_PTHREAD_H) + message(FATAL_ERROR "PThreads is required for non-Windows builds!") + endif() CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD) IF(NOT HAVE_ANDROID_H) @@ -472,105 +575,201 @@ IF(NOT WIN32) CHECK_LIBRARY_EXISTS(c pthread_create "" HAVE_LIBPTHREAD) ENDIF() - CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM) + check_symbol_exists(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM) # Some systems need pthread_np.h to get pthread_setname_np - CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H) - IF(HAVE_PTHREAD_NP_H) - CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP) - IF(NOT HAVE_PTHREAD_SETNAME_NP) - CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP) - ELSE() - CHECK_C_SOURCE_COMPILES(" -#include <pthread.h> -#include <pthread_np.h> -int main() -{ - pthread_setname_np(\"testname\"); - return 0; -}" - PTHREAD_SETNAME_NP_ONE_PARAM - ) - CHECK_C_SOURCE_COMPILES(" -#include <pthread.h> -#include <pthread_np.h> -int main() -{ - pthread_setname_np(pthread_self(), \"%s\", \"testname\"); - return 0; -}" - PTHREAD_SETNAME_NP_THREE_PARAMS - ) - ENDIF() - ELSE() - CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP) - IF(NOT HAVE_PTHREAD_SETNAME_NP) - CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP) - ELSE() - CHECK_C_SOURCE_COMPILES(" -#include <pthread.h> -int main() -{ - pthread_setname_np(\"testname\"); - return 0; -}" - PTHREAD_SETNAME_NP_ONE_PARAM - ) - CHECK_C_SOURCE_COMPILES(" -#include <pthread.h> -int main() -{ - pthread_setname_np(pthread_self(), \"%s\", \"testname\"); - return 0; -}" - PTHREAD_SETNAME_NP_THREE_PARAMS - ) - ENDIF() - ENDIF() -ENDIF() + check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H) + if(HAVE_PTHREAD_NP_H) + check_symbol_exists(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP) + if(NOT HAVE_PTHREAD_SETNAME_NP) + check_symbol_exists(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP) + endif() + else() + check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP) + if(NOT HAVE_PTHREAD_SETNAME_NP) + check_symbol_exists(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP) + endif() + endif() +endif() -CHECK_SYMBOL_EXISTS(getopt unistd.h HAVE_GETOPT) +check_symbol_exists(getopt unistd.h HAVE_GETOPT) -# Common sources used by both the OpenAL implementation library and potentially -# the OpenAL router. -SET(COMMON_OBJS +# Common sources used by both the OpenAL implementation library, the OpenAL +# router, and certain tools and examples. +set(COMMON_OBJS + common/albit.h common/albyte.h common/alcomplex.cpp common/alcomplex.h - common/alexcpt.cpp - common/alexcpt.h + common/aldeque.h common/alfstream.cpp common/alfstream.h common/almalloc.cpp common/almalloc.h + common/alnumbers.h common/alnumeric.h common/aloptional.h common/alspan.h common/alstring.cpp common/alstring.h + common/altraits.h common/atomic.h + common/comptr.h common/dynload.cpp common/dynload.h - common/endiantest.h common/intrusive_ptr.h - common/math_defs.h common/opthelpers.h + common/phase_shifter.h + common/polyphase_resampler.cpp + common/polyphase_resampler.h common/pragmadefs.h + common/ringbuffer.cpp + common/ringbuffer.h common/strutils.cpp common/strutils.h common/threads.cpp common/threads.h common/vecmat.h - common/vector.h -) -SET(OPENAL_OBJS + common/vector.h) + +# Core library routines +set(CORE_OBJS + core/ambdec.cpp + core/ambdec.h + core/ambidefs.cpp + core/ambidefs.h + core/async_event.h + core/bformatdec.cpp + core/bformatdec.h + core/bs2b.cpp + core/bs2b.h + core/bsinc_defs.h + core/bsinc_tables.cpp + core/bsinc_tables.h + core/bufferline.h + core/buffer_storage.cpp + core/buffer_storage.h + core/context.cpp + core/context.h + core/converter.cpp + core/converter.h + core/cpu_caps.cpp + core/cpu_caps.h + core/cubic_defs.h + core/cubic_tables.cpp + core/cubic_tables.h + core/devformat.cpp + core/devformat.h + core/device.cpp + core/device.h + core/effects/base.h + core/effectslot.cpp + core/effectslot.h + core/except.cpp + core/except.h + core/filters/biquad.h + core/filters/biquad.cpp + core/filters/nfc.cpp + core/filters/nfc.h + core/filters/splitter.cpp + core/filters/splitter.h + core/fmt_traits.cpp + core/fmt_traits.h + core/fpu_ctrl.cpp + core/fpu_ctrl.h + core/front_stablizer.h + core/helpers.cpp + core/helpers.h + core/hrtf.cpp + core/hrtf.h + core/logging.cpp + core/logging.h + core/mastering.cpp + core/mastering.h + core/mixer.cpp + core/mixer.h + core/resampler_limits.h + core/uhjfilter.cpp + core/uhjfilter.h + core/uiddefs.cpp + core/voice.cpp + core/voice.h + core/voice_change.h) + +set(HAVE_RTKIT 0) +if(NOT WIN32) + option(ALSOFT_RTKIT "Enable RTKit support" ON) + option(ALSOFT_REQUIRE_RTKIT "Require RTKit/D-Bus support" FALSE) + if(ALSOFT_RTKIT) + find_package(DBus1 QUIET) + if(NOT DBus1_FOUND AND PkgConfig_FOUND) + pkg_check_modules(DBUS dbus-1) + endif() + if(DBus1_FOUND OR DBUS_FOUND) + set(HAVE_RTKIT 1) + set(CORE_OBJS ${CORE_OBJS} core/dbus_wrap.cpp core/dbus_wrap.h + core/rtkit.cpp core/rtkit.h) + if(NOT DBus1_FOUND) + set(INC_PATHS ${INC_PATHS} ${DBUS_INCLUDE_DIRS}) + set(CPP_DEFS ${CPP_DEFS} ${DBUS_CFLAGS_OTHER}) + if(NOT HAVE_DLFCN_H) + set(EXTRA_LIBS ${EXTRA_LIBS} ${DBUS_LINK_LIBRARIES}) + endif() + elseif(HAVE_DLFCN_H) + set(INC_PATHS ${INC_PATHS} ${DBus1_INCLUDE_DIRS}) + set(CPP_DEFS ${CPP_DEFS} ${DBus1_DEFINITIONS}) + else() + set(EXTRA_LIBS ${EXTRA_LIBS} ${DBus1_LIBRARIES}) + endif() + endif() + else() + set(MISSING_VARS "") + if(NOT DBus1_INCLUDE_DIRS) + set(MISSING_VARS "${MISSING_VARS} DBus1_INCLUDE_DIRS") + endif() + if(NOT DBus1_LIBRARIES) + set(MISSING_VARS "${MISSING_VARS} DBus1_LIBRARIES") + endif() + message(STATUS "Could NOT find DBus1 (missing:${MISSING_VARS})") + unset(MISSING_VARS) + endif() +endif() +if(ALSOFT_REQUIRE_RTKIT AND NOT HAVE_RTKIT) + message(FATAL_ERROR "Failed to enabled required RTKit support") +endif() + +# Default mixers, always available +set(CORE_OBJS ${CORE_OBJS} + core/mixer/defs.h + core/mixer/hrtfbase.h + core/mixer/hrtfdefs.h + core/mixer/mixer_c.cpp) + +# AL and related routines +set(OPENAL_OBJS al/auxeffectslot.cpp al/auxeffectslot.h al/buffer.cpp al/buffer.h al/effect.cpp al/effect.h + al/effects/autowah.cpp + al/effects/chorus.cpp + al/effects/compressor.cpp + al/effects/convolution.cpp + al/effects/dedicated.cpp + al/effects/distortion.cpp + al/effects/echo.cpp + al/effects/effects.cpp + al/effects/effects.h + al/effects/equalizer.cpp + al/effects/fshifter.cpp + al/effects/modulator.cpp + al/effects/null.cpp + al/effects/pshifter.cpp + al/effects/reverb.cpp + al/effects/vmorpher.cpp al/error.cpp al/event.cpp al/event.h @@ -581,32 +780,24 @@ SET(OPENAL_OBJS al/listener.h al/source.cpp al/source.h - al/state.cpp -) -SET(ALC_OBJS + al/state.cpp) + +# ALC and related routines +set(ALC_OBJS alc/alc.cpp - alc/alcmain.h alc/alu.cpp alc/alu.h alc/alconfig.cpp alc/alconfig.h - alc/alcontext.h - alc/ambdec.cpp - alc/ambdec.h - alc/ambidefs.h - alc/bformatdec.cpp - alc/bformatdec.h - alc/bs2b.cpp - alc/bs2b.h - alc/compat.h - alc/converter.cpp - alc/converter.h - alc/cpu_caps.h - alc/devformat.h + alc/context.cpp + alc/context.h + alc/device.cpp + alc/device.h alc/effects/base.h alc/effects/autowah.cpp alc/effects/chorus.cpp alc/effects/compressor.cpp + alc/effects/convolution.cpp alc/effects/dedicated.cpp alc/effects/distortion.cpp alc/effects/echo.cpp @@ -617,146 +808,84 @@ SET(ALC_OBJS alc/effects/pshifter.cpp alc/effects/reverb.cpp alc/effects/vmorpher.cpp - alc/filters/biquad.h - alc/filters/biquad.cpp - alc/filters/nfc.cpp - alc/filters/nfc.h - alc/filters/splitter.cpp - alc/filters/splitter.h - alc/fpu_modes.h - alc/helpers.cpp - alc/hrtf.cpp - alc/hrtf.h alc/inprogext.h - alc/logging.h - alc/mastering.cpp - alc/mastering.h - alc/panning.cpp - alc/ringbuffer.cpp - alc/ringbuffer.h - alc/uhjfilter.cpp - alc/uhjfilter.h - alc/uiddefs.cpp - alc/voice.cpp - alc/voice.h - alc/mixer/defs.h - alc/mixer/hrtfbase.h - alc/mixer/mixer_c.cpp -) + alc/panning.cpp) + +if(ALSOFT_EAX) + set(OPENAL_OBJS + ${OPENAL_OBJS} + al/eax/api.cpp + al/eax/api.h + al/eax/call.cpp + al/eax/call.h + al/eax/effect.h + al/eax/exception.cpp + al/eax/exception.h + al/eax/fx_slot_index.cpp + al/eax/fx_slot_index.h + al/eax/fx_slots.cpp + al/eax/fx_slots.h + al/eax/globals.cpp + al/eax/globals.h + al/eax/utils.cpp + al/eax/utils.h + al/eax/x_ram.h + ) +endif() +# Include SIMD mixers +set(CPU_EXTS "Default") +if(HAVE_SSE) + set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse.cpp) + set(CPU_EXTS "${CPU_EXTS}, SSE") +endif() +if(HAVE_SSE2) + set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse2.cpp) + set(CPU_EXTS "${CPU_EXTS}, SSE2") +endif() +if(HAVE_SSE3) + set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse3.cpp) + set(CPU_EXTS "${CPU_EXTS}, SSE3") +endif() +if(HAVE_SSE4_1) + set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_sse41.cpp) + set(CPU_EXTS "${CPU_EXTS}, SSE4.1") +endif() +if(HAVE_NEON) + set(CORE_OBJS ${CORE_OBJS} core/mixer/mixer_neon.cpp) + set(CPU_EXTS "${CPU_EXTS}, Neon") +endif() -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 - 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() -# 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() - - -SET(HAVE_ALSA 0) -SET(HAVE_OSS 0) -SET(HAVE_SOLARIS 0) -SET(HAVE_SNDIO 0) -SET(HAVE_QSA 0) -SET(HAVE_DSOUND 0) -SET(HAVE_WASAPI 0) -SET(HAVE_WINMM 0) -SET(HAVE_PORTAUDIO 0) -SET(HAVE_PULSEAUDIO 0) -SET(HAVE_COREAUDIO 0) -SET(HAVE_OPENSL 0) -SET(HAVE_WAVE 0) -SET(HAVE_SDL2 0) - -IF(WIN32 OR HAVE_DLFCN_H) - SET(IS_LINKED "") - MACRO(ADD_BACKEND_LIBS _LIBS) - ENDMACRO() -ELSE() - SET(IS_LINKED " (linked)") - MACRO(ADD_BACKEND_LIBS _LIBS) - SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS}) - ENDMACRO() -ENDIF() - -SET(BACKENDS "") -SET(ALC_OBJS ${ALC_OBJS} +set(HAVE_ALSA 0) +set(HAVE_OSS 0) +set(HAVE_PIPEWIRE 0) +set(HAVE_SOLARIS 0) +set(HAVE_SNDIO 0) +set(HAVE_DSOUND 0) +set(HAVE_WASAPI 0) +set(HAVE_WINMM 0) +set(HAVE_PORTAUDIO 0) +set(HAVE_PULSEAUDIO 0) +set(HAVE_COREAUDIO 0) +set(HAVE_OPENSL 0) +set(HAVE_OBOE 0) +set(HAVE_WAVE 0) +set(HAVE_SDL2 0) + +if(WIN32 OR HAVE_DLFCN_H) + set(IS_LINKED "") + macro(ADD_BACKEND_LIBS _LIBS) + endmacro() +else() + set(IS_LINKED " (linked)") + macro(ADD_BACKEND_LIBS _LIBS) + set(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS}) + endmacro() +endif() + +set(BACKENDS "") +set(ALC_OBJS ${ALC_OBJS} alc/backends/base.cpp alc/backends/base.h # Default backends, always available @@ -766,643 +895,727 @@ SET(ALC_OBJS ${ALC_OBJS} alc/backends/null.h ) -# 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() - -# 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() - -# 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() - -# 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() - -# Check QSA backend -OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF) -FIND_PACKAGE(QSA) -IF(QSA_FOUND) - OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON) - IF(ALSOFT_BACKEND_QSA) - SET(HAVE_QSA 1) - SET(BACKENDS "${BACKENDS} QSA (linked),") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/qsa.cpp alc/backends/qsa.h) - SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS}) - SET(INC_PATHS ${INC_PATHS} ${QSA_INCLUDE_DIRS}) - ENDIF() -ENDIF() -IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA) - MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend") -ENDIF() +# Check PipeWire backend +option(ALSOFT_BACKEND_PIPEWIRE "Enable PipeWire backend" ON) +option(ALSOFT_REQUIRE_PIPEWIRE "Require PipeWire backend" OFF) +if(ALSOFT_BACKEND_PIPEWIRE AND PkgConfig_FOUND) + pkg_check_modules(PIPEWIRE libpipewire-0.3>=0.3.23) + if(PIPEWIRE_FOUND) + set(HAVE_PIPEWIRE 1) + set(BACKENDS "${BACKENDS} PipeWire${IS_LINKED},") + set(ALC_OBJS ${ALC_OBJS} alc/backends/pipewire.cpp alc/backends/pipewire.h) + add_backend_libs(${PIPEWIRE_LIBRARIES}) + set(INC_PATHS ${INC_PATHS} ${PIPEWIRE_INCLUDE_DIRS}) + endif() +endif() +if(ALSOFT_REQUIRE_PIPEWIRE AND NOT HAVE_PIPEWIRE) + message(FATAL_ERROR "Failed to enabled required PipeWire 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) - get_windowssdk_library_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_LIB_DIRS) - get_windowssdk_include_dirs(${WINDOWSSDK_PREFERRED_DIR} WINSDK_INCLUDE_DIRS) - ENDIF() +# Check PulseAudio backend +option(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON) +option(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF) +if(ALSOFT_BACKEND_PULSEAUDIO) + find_package(PulseAudio) + if(PULSEAUDIO_FOUND) + 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_LIBRARY}) + set(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIR}) + endif() +endif() +if(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO) + message(FATAL_ERROR "Failed to enabled required PulseAudio backend") +endif() - SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) - SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502) +if(NOT WIN32) + # Check ALSA backend + option(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON) + option(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF) + if(ALSOFT_BACKEND_ALSA) + find_package(ALSA) + if(ALSA_FOUND) + 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() - # Check MMSystem backend - CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H) - FIND_LIBRARY(WINMM_LIBRARY NAMES winmm - PATHS ${WINSDK_LIB_DIRS} - PATH_SUFFIXES lib lib/x86 lib/x64) - IF(HAVE_MMSYSTEM_H AND WINMM_LIBRARY) - OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON) - IF(ALSOFT_BACKEND_WINMM) - SET(HAVE_WINMM 1) - SET(BACKENDS "${BACKENDS} WinMM,") - SET(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h) - SET(EXTRA_LIBS ${WINMM_LIBRARY} ${EXTRA_LIBS}) - ENDIF() - ENDIF() + # Check OSS backend + option(ALSOFT_BACKEND_OSS "Enable OSS backend" ON) + option(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF) + if(ALSOFT_BACKEND_OSS) + find_package(OSS) + if(OSS_FOUND) + 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() - # 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() + # Check Solaris backend + option(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON) + option(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF) + if(ALSOFT_BACKEND_SOLARIS) + find_package(AudioIO) + if(AUDIOIO_FOUND) + 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() - # 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() + # Check SndIO backend + option(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON) + option(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF) + if(ALSOFT_BACKEND_SNDIO) + find_package(SoundIO) + if(SOUNDIO_FOUND) + 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() +endif() +if(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA) + message(FATAL_ERROR "Failed to enabled required ALSA backend") +endif() +if(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS) + message(FATAL_ERROR "Failed to enabled required OSS backend") +endif() +if(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS) + message(FATAL_ERROR "Failed to enabled required Solaris backend") +endif() +if(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO) + message(FATAL_ERROR "Failed to enabled required SndIO backend") +endif() - SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS}) - UNSET(OLD_REQUIRED_DEFINITIONS) -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 Windows-only backends +if(WIN32) + # Check MMSystem backend + option(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON) + option(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF) + if(ALSOFT_BACKEND_WINMM) + set(HAVE_WINMM 1) + set(BACKENDS "${BACKENDS} WinMM,") + set(ALC_OBJS ${ALC_OBJS} alc/backends/winmm.cpp alc/backends/winmm.h) + # There doesn't seem to be good way to search for winmm.lib for MSVC. + # find_library doesn't find it without being told to look in a specific + # place in the WindowsSDK, but it links anyway. If there ends up being + # Windows targets without this, another means to detect it is needed. + set(EXTRA_LIBS winmm ${EXTRA_LIBS}) + 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() + # Check DSound backend + option(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON) + option(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF) + if(ALSOFT_BACKEND_DSOUND) + check_include_file(dsound.h HAVE_DSOUND_H) + if(DXSDK_DIR) + find_path(DSOUND_INCLUDE_DIR NAMES "dsound.h" + PATHS "${DXSDK_DIR}" PATH_SUFFIXES include + DOC "The DirectSound include directory") + endif() + if(HAVE_DSOUND_H OR DSOUND_INCLUDE_DIR) + set(HAVE_DSOUND 1) + set(BACKENDS "${BACKENDS} DirectSound,") + set(ALC_OBJS ${ALC_OBJS} alc/backends/dsound.cpp alc/backends/dsound.h) -# 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() + if(NOT HAVE_DSOUND_H) + set(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIR}) + endif() + endif() + endif() + + # Check for WASAPI backend + option(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON) + option(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF) + if(ALSOFT_BACKEND_WASAPI) + check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H) + if(HAVE_MMDEVICEAPI_H) + 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 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_BACKEND_JACK "Enable JACK backend" ON) +option(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF) +if(ALSOFT_BACKEND_JACK) + find_package(JACK) + if(JACK_FOUND) + 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 - PATHS /System/Library/Frameworks -) -IF(COREAUDIO_FRAMEWORK) - 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} ${EXTRA_LIBS}) - SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS}) - SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS}) +option(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON) +option(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF) +if(ALSOFT_BACKEND_COREAUDIO) + find_library(COREAUDIO_FRAMEWORK NAMES CoreAudio) + find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit/AudioUnit.h) + if(COREAUDIO_FRAMEWORK AND AUDIOUNIT_INCLUDE_DIR) + set(HAVE_COREAUDIO 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/coreaudio.cpp alc/backends/coreaudio.h) + set(BACKENDS "${BACKENDS} CoreAudio,") + + set(EXTRA_LIBS -Wl,-framework,CoreAudio ${EXTRA_LIBS}) + if(CMAKE_SYSTEM_NAME MATCHES "^(iOS|tvOS)$") + find_library(COREFOUNDATION_FRAMEWORK NAMES CoreFoundation) + if(COREFOUNDATION_FRAMEWORK) + set(EXTRA_LIBS -Wl,-framework,CoreFoundation ${EXTRA_LIBS}) + endif() + else() + set(EXTRA_LIBS -Wl,-framework,AudioUnit,-framework,ApplicationServices ${EXTRA_LIBS}) + endif() # Some versions of OSX may need the AudioToolbox framework. Add it if # it's found. - FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY - NAMES AudioToolbox - PATHS - ~/Library/Frameworks - /Library/Frameworks - /System/Library/Frameworks - ) - IF(AUDIOTOOLBOX_LIBRARY) - SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS}) - ENDIF() - 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 -Wl,-framework,AudioToolbox ${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 Oboe (Android) backend +option(ALSOFT_BACKEND_OBOE "Enable Oboe backend" ON) +option(ALSOFT_REQUIRE_OBOE "Require Oboe backend" OFF) +if(ALSOFT_BACKEND_OBOE) + set(OBOE_TARGET ) + if(ANDROID) + set(OBOE_SOURCE "" CACHE STRING "Source directory for Oboe.") + if(OBOE_SOURCE) + add_subdirectory(${OBOE_SOURCE} ./oboe) + set(OBOE_TARGET oboe) + else() + find_package(oboe CONFIG) + if(NOT TARGET oboe::oboe) + find_package(Oboe) + endif() + if(TARGET oboe::oboe) + set(OBOE_TARGET "oboe::oboe") + endif() + endif() + endif() + + if(OBOE_TARGET) + set(HAVE_OBOE 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/oboe.cpp alc/backends/oboe.h) + set(BACKENDS "${BACKENDS} Oboe,") + set(EXTRA_LIBS ${OBOE_TARGET} ${EXTRA_LIBS}) + endif() +endif() +if(ALSOFT_REQUIRE_OBOE AND NOT HAVE_OBOE) + message(FATAL_ERROR "Failed to enabled required Oboe 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_BACKEND_OPENSL "Enable OpenSL backend" ON) +option(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF) +if(ALSOFT_BACKEND_OPENSL) + find_package(OpenSL) + if(OPENSL_FOUND) + 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::OpenSLES" ${EXTRA_LIBS}) + endif() +endif() +if(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL) + message(FATAL_ERROR "Failed to enabled required OpenSL backend") +endif() + +# Check PortAudio backend +option(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON) +option(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF) +if(ALSOFT_BACKEND_PORTAUDIO) + find_package(PortAudio) + if(PORTAUDIO_FOUND) + 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 for SDL2 backend -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() +# Off by default, since it adds a runtime dependency +option(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF) +option(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF) +if(ALSOFT_BACKEND_SDL2) + if(SDL2_FOUND) + set(HAVE_SDL2 1) + set(ALC_OBJS ${ALC_OBJS} alc/backends/sdl2.cpp alc/backends/sdl2.h) + set(BACKENDS "${BACKENDS} SDL2,") + set(EXTRA_LIBS ${EXTRA_LIBS} SDL2::SDL2) + else() + message(STATUS "Could NOT find SDL2") + 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") + set(GIT_DIR "${OpenAL_SOURCE_DIR}/.git") + + # Check if this is a submodule, if it is then find the .git directory + if(NOT IS_DIRECTORY "${OpenAL_SOURCE_DIR}/.git") + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule}) + string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() -FIND_PACKAGE(Git) -IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") # Get the current working branch and its latest abbreviated commit hash - ADD_CUSTOM_TARGET(build_version - ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D LIB_VERSION=${LIB_VERSION} + add_custom_command(OUTPUT "${OpenAL_BINARY_DIR}/version_witness.txt" + BYPRODUCTS "${OpenAL_BINARY_DIR}/version.h" + COMMAND ${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 + COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/version_witness.txt" WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" + MAIN_DEPENDENCY "${OpenAL_SOURCE_DIR}/version.h.in" + DEPENDS "${GIT_DIR}/index" "${OpenAL_SOURCE_DIR}/version.cmake" VERBATIM ) -ELSE() - SET(GIT_BRANCH "UNKNOWN") - SET(GIT_COMMIT_HASH "unknown") - CONFIGURE_FILE( + + add_custom_target(build_version DEPENDS "${OpenAL_BINARY_DIR}/version_witness.txt") +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() IF(NOT CMAKE_CROSSCOMPILING) -SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/native-tools") - -SET(ALSOFT_NATIVE_TOOLS_PATH "" CACHE STRING "Path to prebuilt native tools (leave blank to auto-build)") -IF(ALSOFT_NATIVE_TOOLS_PATH) - find_program(BIN2H_NATIVE_COMMAND NAMES bin2h - PATHS "${ALSOFT_NATIVE_TOOLS_PATH}" - NO_DEFAULT_PATH) - find_program(BSINCGEN_NATIVE_COMMAND NAMES bsincgen - PATHS "${ALSOFT_NATIVE_TOOLS_PATH}" - NO_DEFAULT_PATH) - if(NOT BIN2H_NATIVE_COMMAND OR NOT BSINCGEN_NATIVE_COMMAND) - message(FATAL_ERROR "Failed to find native tools in ${ALSOFT_NATIVE_TOOLS_PATH}. -bin2h: ${BIN2H_NATIVE_COMMAND} -bsincgen: ${BSINCGEN_NATIVE_COMMAND}") - endif() - SET(BIN2H_COMMAND ${BIN2H_NATIVE_COMMAND}) - SET(BSINCGEN_COMMAND ${BSINCGEN_NATIVE_COMMAND}) -ELSE() - SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools") - FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}") - - SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}/bin2h") - SET(BSINCGEN_COMMAND "${NATIVE_BIN_DIR}/bsincgen") - ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}" - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "${NATIVE_SRC_DIR}" - COMMAND ${CMAKE_COMMAND} -E remove "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}" - COMMAND ${CMAKE_COMMAND} --build . --config "Release" - WORKING_DIRECTORY "${NATIVE_BIN_DIR}" - DEPENDS "${NATIVE_SRC_DIR}/CMakeLists.txt" - IMPLICIT_DEPENDS - C "${NATIVE_SRC_DIR}/bin2h.c" - C "${NATIVE_SRC_DIR}/bsincgen.c" - VERBATIM - ) -ENDIF() -ADD_CUSTOM_TARGET(native-tools - DEPENDS "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}" - VERBATIM -) - 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}/${FILENAME}.h") - - ADD_CUSTOM_COMMAND(OUTPUT "${outfile}" - COMMAND "${BIN2H_COMMAND}" "${infile}" "${outfile}" ${VARNAME} - DEPENDS native-tools "${infile}" + macro(make_hrtf_header FILENAME VARNAME) + set(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}") + set(outfile "${OpenAL_BINARY_DIR}/${VARNAME}.txt") + + add_custom_command(OUTPUT "${outfile}" + COMMAND ${CMAKE_COMMAND} -D "INPUT_FILE=${infile}" -D "OUTPUT_FILE=${outfile}" + -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-44100.mhr "hrtf_default_44100") - make_hrtf_header(default-48000.mhr "hrtf_default_48000") + make_hrtf_header("Default HRTF.mhr" "default_hrtf") endif() -ADD_CUSTOM_COMMAND(OUTPUT "${OpenAL_BINARY_DIR}/bsinc_inc.h" - COMMAND "${BSINCGEN_COMMAND}" "${OpenAL_BINARY_DIR}/bsinc_inc.h" - DEPENDS native-tools "${NATIVE_SRC_DIR}/bsincgen.c" - VERBATIM -) -SET(ALC_OBJS ${ALC_OBJS} "${OpenAL_BINARY_DIR}/bsinc_inc.h") - - -IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL) - add_subdirectory(utils/alsoft-config) -ENDIF() -IF(ALSOFT_EXAMPLES) - IF(NOT SDL2_FOUND) - FIND_PACKAGE(SDL2) - ENDIF() - IF(SDL2_FOUND) - FIND_PACKAGE(SDL_sound) - FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE) - ENDIF() -ENDIF() - -# For crosscompiling, caller must provide the bsinc_inc.h file -# SET(ALC_OBJS ${ALC_OBJS} "${OpenAL_BINARY_DIR}/bsinc_inc.h") -ENDIF(NOT CMAKE_CROSSCOMPILING) +if(ALSOFT_UTILS) + find_package(MySOFA) + if(NOT ALSOFT_NO_CONFIG_UTIL) + find_package(Qt5Widgets QUIET) + if(NOT Qt5Widgets_FOUND) + message(STATUS "Could NOT find Qt5Widgets") + endif() + endif() +endif() +if(ALSOFT_UTILS OR ALSOFT_EXAMPLES) + find_package(SndFile) + 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() +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 "${CMAKE_INSTALL_FULL_LIBDIR}") +set(bindir "${CMAKE_INSTALL_FULL_BINDIR}") +set(includedir "${CMAKE_INSTALL_FULL_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() + # as-is. If it's an SDL2 target, add the link flag for it. 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}") + elseif(FLAG MATCHES "^SDL2::SDL2") + set(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -lSDL2") + 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 ${DEFAULT_TARGET_PROPS} POSITION_INDEPENDENT_CODE TRUE) -UNSET(HAS_ROUTER) -SET(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal. -SET(SUBSYS_FLAG ) +unset(HAS_ROUTER) +set(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal. # Build main library -IF(LIBTYPE STREQUAL "STATIC") - SET(CPP_DEFS ${CPP_DEFS} AL_LIBTYPE_STATIC) - IF(WIN32 AND ALSOFT_NO_UID_DEFS) - SET(CPP_DEFS ${CPP_DEFS} AL_NO_UID_DEFS) - ENDIF() - ADD_LIBRARY(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS}) - TARGET_LINK_LIBRARIES(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) -ELSE() - IF(WIN32) - IF(MSVC) - SET(SUBSYS_FLAG ${SUBSYS_FLAG} "/SUBSYSTEM:WINDOWS") - ELSEIF(CMAKE_COMPILER_IS_GNUCC) - SET(SUBSYS_FLAG ${SUBSYS_FLAG} "-mwindows") - ENDIF() - ENDIF() +if(LIBTYPE STREQUAL "STATIC") + add_library(${IMPL_TARGET} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS}) + target_compile_definitions(${IMPL_TARGET} PUBLIC AL_LIBTYPE_STATIC) + target_link_libraries(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) - SET(RC_CONFIG resources/openal32.rc) - IF(WIN32 AND ALSOFT_BUILD_ROUTER) - ADD_LIBRARY(OpenAL SHARED + if(WIN32) + # This option is for static linking OpenAL Soft into another project + # that already defines the IDs. It is up to that project to ensure all + # required IDs are defined. + option(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF) + if(ALSOFT_NO_UID_DEFS) + 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 resources/router.rc router/router.cpp router/router.h router/alc.cpp router/al.cpp ) - 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_definitions(OpenAL + PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" + "AL_API=${EXPORT_DECL}" ${CPP_DEFS}) + 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> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> PRIVATE ${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_target_properties(OpenAL PROPERTIES ${DEFAULT_TARGET_PROPS} PREFIX "" + 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() + 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() + # !important: for osx framework public header works, the headers must be in + # the project + set(TARGET_PUBLIC_HEADERS include/AL/al.h include/AL/alc.h include/AL/alext.h include/AL/efx.h + include/AL/efx-presets.h) -TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET} + add_library(${IMPL_TARGET} SHARED ${OPENAL_OBJS} ${ALC_OBJS} ${CORE_OBJS} ${RC_CONFIG} + ${TARGET_PUBLIC_HEADERS}) + if(WIN32) + set_target_properties(${IMPL_TARGET} PROPERTIES PREFIX "") + endif() + target_link_libraries(${IMPL_TARGET} PRIVATE common ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB}) + + if(NOT WIN32 AND NOT APPLE) + # FIXME: This doesn't put a dependency on the version script. Changing + # the version script will not cause a relink as it should. + set_property(TARGET ${IMPL_TARGET} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--version-script=${OpenAL_SOURCE_DIR}/libopenal.version") + endif() + + if(APPLE AND ALSOFT_OSX_FRAMEWORK) + # Sets framework name to soft_oal to avoid ambiguity with the system OpenAL.framework + set(LIBNAME "soft_oal") + if(GIT_FOUND) + execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD + TIMEOUT 5 + OUTPUT_VARIABLE BUNDLE_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + set(BUNDLE_VERSION 1) + endif() + + # Build: Fix rpath in iOS shared libraries + # If this flag is not set, the final dylib binary ld path will be + # /User/xxx/*/soft_oal.framework/soft_oal, which can't be loaded by iOS devices. + # See also: https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c80ddef7a4ce21ace9e3ca0fd190d320cc8cdaeb + if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) + set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") + endif() + + set_target_properties(${IMPL_TARGET} PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION C + MACOSX_FRAMEWORK_NAME "${IMPL_TARGET}" + MACOSX_FRAMEWORK_IDENTIFIER "org.openal-soft.openal" + MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${LIB_VERSION}" + MACOSX_FRAMEWORK_BUNDLE_VERSION "${BUNDLE_VERSION}" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" + PUBLIC_HEADER "${TARGET_PUBLIC_HEADERS}" + MACOSX_RPATH TRUE) + endif() +endif() + +target_include_directories(${IMPL_TARGET} PUBLIC $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include> - $<INSTALL_INTERFACE:include> + INTERFACE + $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include/AL> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/AL> PRIVATE ${INC_PATHS} ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR} - ${OpenAL_SOURCE_DIR}/alc ${OpenAL_SOURCE_DIR}/common ) -SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME} +set_target_properties(${IMPL_TARGET} PROPERTIES ${DEFAULT_TARGET_PROPS} + OUTPUT_NAME ${LIBNAME} VERSION ${LIB_VERSION} SOVERSION ${LIB_MAJOR_VERSION} ) -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_definitions(${IMPL_TARGET} + PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES "ALC_API=${EXPORT_DECL}" "AL_API=${EXPORT_DECL}" + ${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") + if(NOT SED_EXECUTABLE OR NOT CMAKE_DLLTOOL) + message(STATUS "") + if(NOT SED_EXECUTABLE) + message(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation") + endif() + if(NOT CMAKE_DLLTOOL) + message(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation") + endif() + else() + set_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 + COMMAND "${CMAKE_DLLTOOL}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll + # Technically OpenAL32.def was created by the build, but cmake + # doesn't recognize it due to -Wl,--output-def,OpenAL32.def being + # manually specified. But declaring the file here allows it to be + # properly cleaned, e.g. during make clean. + BYPRODUCTS OpenAL32.def OpenAL32.lib 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() + +if(ALSOFT_EAX) + message(STATUS "Building with legacy EAX extension support") + message(STATUS "") +endif() + +if(ALSOFT_EMBED_HRTF_DATA) + message(STATUS "Embedding HRTF datasets") + message(STATUS "") +endif() + +# An alias for sub-project builds +add_library(OpenAL::OpenAL ALIAS OpenAL) -IF(ALSOFT_INSTALL) - INSTALL(TARGETS OpenAL EXPORT OpenAL +# Install main library +if(ALSOFT_INSTALL) + configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL) + install(TARGETS OpenAL EXPORT OpenAL RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL) - EXPORT(TARGETS OpenAL + export(TARGETS OpenAL NAMESPACE OpenAL:: - FILE OpenALConfig.cmake) - INSTALL(EXPORT OpenAL + FILE OpenALTargets.cmake) + install(EXPORT OpenAL DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL NAMESPACE OpenAL:: - FILE OpenALConfig.cmake) - INSTALL(FILES - include/AL/al.h - include/AL/alc.h - include/AL/alext.h - include/AL/efx.h - include/AL/efx-creative.h - include/AL/efx-presets.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/AL) - INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc" + FILE OpenALTargets.cmake) + install(DIRECTORY include/AL + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES "${OpenAL_BINARY_DIR}/openal.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - IF(TARGET soft_oal) - INSTALL(TARGETS soft_oal + install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL") + if(TARGET soft_oal) + install(TARGETS soft_oal RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - ENDIF() -ENDIF() + endif() + message(STATUS "Installing library and headers") +else() + message(STATUS "NOT installing library and headers") +endif() +if(ALSOFT_INSTALL_CONFIG) + install(FILES alsoftrc.sample + DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) + message(STATUS "Installing sample configuration") +endif() -if(HAS_ROUTER) - message(STATUS "") - message(STATUS "Building DLL router") +if(ALSOFT_INSTALL_HRTF_DATA) + install(DIRECTORY hrtf + DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) + message(STATUS "Installing HRTF data files") 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() +if(ALSOFT_INSTALL_AMBDEC_PRESETS) + install(DIRECTORY presets + DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) + message(STATUS "Installing AmbDec presets") +endif() +message(STATUS "") -if(ALSOFT_EMBED_HRTF_DATA) - message(STATUS "Embedding HRTF datasets") - message(STATUS "") +set(UNICODE_FLAG ) +if(MINGW) + set(UNICODE_FLAG ${UNICODE_FLAG} -municode) endif() +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 ${UNICODE_FLAG}) + set_target_properties(openal-info PROPERTIES ${DEFAULT_TARGET_PROPS}) + if(ALSOFT_INSTALL_EXAMPLES) + set(EXTRA_INSTALLS ${EXTRA_INSTALLS} openal-info) + endif() -# Install alsoft.conf configuration file -IF(ALSOFT_CONFIG) - INSTALL(FILES alsoftrc.sample - DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) - MESSAGE(STATUS "Installing sample configuration") - MESSAGE(STATUS "") -ENDIF() - -# Install HRTF definitions -IF(ALSOFT_HRTF_DEFS) - INSTALL(FILES hrtf/default-44100.mhr hrtf/default-48000.mhr - DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/hrtf) - MESSAGE(STATUS "Installing HRTF definitions") - MESSAGE(STATUS "") -ENDIF() - -# Install AmbDec presets -IF(ALSOFT_AMBDEC_PRESETS) - INSTALL(FILES - presets/3D7.1.ambdec - presets/hexagon.ambdec - presets/itu5.1.ambdec - presets/itu5.1-nocenter.ambdec - presets/rectangle.ambdec - presets/square.ambdec - presets/presets.txt - DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/presets) - MESSAGE(STATUS "Installing AmbDec presets") - MESSAGE(STATUS "") -ENDIF() - -IF(ALSOFT_UTILS) - set(UTIL_TARGETS ) - - 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) - set(UTIL_TARGETS ${UTIL_TARGETS} openal-info) + if(SNDFILE_FOUND) + add_executable(uhjdecoder utils/uhjdecoder.cpp) + target_compile_definitions(uhjdecoder PRIVATE ${CPP_DEFS}) + target_include_directories(uhjdecoder + PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) + target_compile_options(uhjdecoder PRIVATE ${C_FLAGS}) + target_link_libraries(uhjdecoder PUBLIC common + PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG}) + set_target_properties(uhjdecoder PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(uhjencoder utils/uhjencoder.cpp) + target_compile_definitions(uhjencoder PRIVATE ${CPP_DEFS}) + target_include_directories(uhjencoder + PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) + target_compile_options(uhjencoder PRIVATE ${C_FLAGS}) + target_link_libraries(uhjencoder PUBLIC common + PRIVATE ${LINKER_FLAGS} SndFile::SndFile ${UNICODE_FLAG}) + set_target_properties(uhjencoder PROPERTIES ${DEFAULT_TARGET_PROPS}) + endif() - find_package(MySOFA) if(MYSOFA_FOUND) + set(SOFA_SUPPORT_SRCS + utils/sofa-support.cpp + utils/sofa-support.h) + add_library(sofa-support STATIC EXCLUDE_FROM_ALL ${SOFA_SUPPORT_SRCS}) + target_compile_definitions(sofa-support PRIVATE ${CPP_DEFS}) + target_include_directories(sofa-support PUBLIC ${OpenAL_SOURCE_DIR}/common) + target_compile_options(sofa-support PRIVATE ${C_FLAGS}) + target_link_libraries(sofa-support PUBLIC common MySOFA::MySOFA PRIVATE ${LINKER_FLAGS}) + set_target_properties(sofa-support PROPERTIES ${DEFAULT_TARGET_PROPS}) + set(MAKEMHR_SRCS utils/makemhr/loaddef.cpp utils/makemhr/loaddef.h @@ -1416,168 +1629,161 @@ IF(ALSOFT_UTILS) add_executable(makemhr ${MAKEMHR_SRCS}) target_compile_definitions(makemhr PRIVATE ${CPP_DEFS}) target_include_directories(makemhr - PRIVATE ${OpenAL_SOURCE_DIR}/common ${OpenAL_BINARY_DIR}) + PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/utils) target_compile_options(makemhr PRIVATE ${C_FLAGS}) - target_link_libraries(makemhr PRIVATE common ${LINKER_FLAGS} MySOFA::MySOFA) - set(UTIL_TARGETS ${UTIL_TARGETS} makemhr) + target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} sofa-support ${UNICODE_FLAG}) + set_target_properties(makemhr PROPERTIES ${DEFAULT_TARGET_PROPS}) + if(ALSOFT_INSTALL_EXAMPLES) + set(EXTRA_INSTALLS ${EXTRA_INSTALLS} makemhr) + endif() set(SOFAINFO_SRCS utils/sofa-info.cpp) add_executable(sofa-info ${SOFAINFO_SRCS}) target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS}) - target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/common) + target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/utils) target_compile_options(sofa-info PRIVATE ${C_FLAGS}) - target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} MySOFA::MySOFA) + target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} sofa-support ${UNICODE_FLAG}) + set_target_properties(sofa-info PROPERTIES ${DEFAULT_TARGET_PROPS}) endif() + message(STATUS "Building utility programs") - IF(ALSOFT_INSTALL) - INSTALL(TARGETS ${UTIL_TARGETS} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - ENDIF() - - MESSAGE(STATUS "Building utility programs") - IF(TARGET alsoft-config) - MESSAGE(STATUS "Building configuration program") - ENDIF() - MESSAGE(STATUS "") -ENDIF() + if(NOT ALSOFT_NO_CONFIG_UTIL) + add_subdirectory(utils/alsoft-config) + endif() + message(STATUS "") +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}) - -IF(ALSOFT_TESTS) - ADD_EXECUTABLE(altonegen examples/altonegen.c) - TARGET_COMPILE_DEFINITIONS(altonegen PRIVATE ${CPP_DEFS}) - TARGET_INCLUDE_DIRECTORIES(altonegen PRIVATE ${OpenAL_SOURCE_DIR}/common) - TARGET_COMPILE_OPTIONS(altonegen PRIVATE ${C_FLAGS}) - TARGET_LINK_LIBRARIES(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} ex-common) - - IF(ALSOFT_INSTALL) - INSTALL(TARGETS altonegen - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - ENDIF() +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}) +set_target_properties(ex-common PROPERTIES ${DEFAULT_TARGET_PROPS}) + +if(ALSOFT_EXAMPLES) + add_executable(altonegen examples/altonegen.c) + target_link_libraries(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} ex-common ${UNICODE_FLAG}) + set_target_properties(altonegen PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(alrecord examples/alrecord.c) + target_link_libraries(alrecord PRIVATE ${LINKER_FLAGS} ex-common ${UNICODE_FLAG}) + set_target_properties(alrecord PROPERTIES ${DEFAULT_TARGET_PROPS}) + + if(ALSOFT_INSTALL_EXAMPLES) + set(EXTRA_INSTALLS ${EXTRA_INSTALLS} altonegen alrecord) + endif() - MESSAGE(STATUS "Building test programs") - MESSAGE(STATUS "") -ENDIF() + message(STATUS "Building example programs") + + if(SNDFILE_FOUND) + add_executable(alplay examples/alplay.c) + target_link_libraries(alplay PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common + ${UNICODE_FLAG}) + set_target_properties(alplay PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(alstream examples/alstream.c) + target_link_libraries(alstream PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common + ${UNICODE_FLAG}) + set_target_properties(alstream PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(alreverb examples/alreverb.c) + target_link_libraries(alreverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common + ${UNICODE_FLAG}) + set_target_properties(alreverb PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(almultireverb examples/almultireverb.c) + target_link_libraries(almultireverb + PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common ${MATH_LIB} ${UNICODE_FLAG}) + set_target_properties(almultireverb PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(allatency examples/allatency.c) + target_link_libraries(allatency PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common + ${UNICODE_FLAG}) + set_target_properties(allatency PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(alhrtf examples/alhrtf.c) + target_link_libraries(alhrtf + PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common ${MATH_LIB} ${UNICODE_FLAG}) + set_target_properties(alhrtf PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(alstreamcb examples/alstreamcb.cpp) + target_link_libraries(alstreamcb PRIVATE ${LINKER_FLAGS} SndFile::SndFile ex-common + ${UNICODE_FLAG}) + set_target_properties(alstreamcb PROPERTIES ${DEFAULT_TARGET_PROPS}) + + add_executable(alconvolve examples/alconvolve.c) + target_link_libraries(alconvolve PRIVATE ${LINKER_FLAGS} common SndFile::SndFile ex-common + ${UNICODE_FLAG}) + set_target_properties(alconvolve PROPERTIES ${DEFAULT_TARGET_PROPS}) + + if(ALSOFT_INSTALL_EXAMPLES) + set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alplay alstream alreverb almultireverb allatency + alhrtf) + endif() -IF(ALSOFT_EXAMPLES) - ADD_EXECUTABLE(alrecord examples/alrecord.c) - TARGET_LINK_LIBRARIES(alrecord PRIVATE ${LINKER_FLAGS} ex-common) + message(STATUS "Building SndFile example programs") + endif() - IF(ALSOFT_INSTALL) - INSTALL(TARGETS alrecord - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - ENDIF() + if(SDL2_FOUND) + add_executable(alloopback examples/alloopback.c) + target_link_libraries(alloopback + PRIVATE ${LINKER_FLAGS} SDL2::SDL2 ex-common ${MATH_LIB}) + set_target_properties(alloopback PROPERTIES ${DEFAULT_TARGET_PROPS}) - MESSAGE(STATUS "Building example programs") - - IF(SDL2_FOUND) - IF(SDL_SOUND_FOUND) - ADD_EXECUTABLE(alplay examples/alplay.c) - TARGET_INCLUDE_DIRECTORIES(alplay - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(alplay - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common) - - ADD_EXECUTABLE(alstream examples/alstream.c) - TARGET_INCLUDE_DIRECTORIES(alstream - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(alstream - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common) - - ADD_EXECUTABLE(alreverb examples/alreverb.c) - TARGET_INCLUDE_DIRECTORIES(alreverb - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(alreverb - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common) - - ADD_EXECUTABLE(almultireverb examples/almultireverb.c) - TARGET_INCLUDE_DIRECTORIES(almultireverb - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(almultireverb - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common - ${MATH_LIB}) - - ADD_EXECUTABLE(allatency examples/allatency.c) - TARGET_INCLUDE_DIRECTORIES(allatency - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(allatency - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common) - - ADD_EXECUTABLE(alloopback examples/alloopback.c) - TARGET_INCLUDE_DIRECTORIES(alloopback - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(alloopback - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB}) - - ADD_EXECUTABLE(alhrtf examples/alhrtf.c) - TARGET_INCLUDE_DIRECTORIES(alhrtf - PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(alhrtf - PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB}) - - IF(ALSOFT_INSTALL) - INSTALL(TARGETS alplay alstream alreverb almultireverb allatency alloopback alhrtf - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - ENDIF() - - MESSAGE(STATUS "Building SDL_sound example programs") - ENDIF() + if(ALSOFT_INSTALL_EXAMPLES) + set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alloopback) + endif() - 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 - PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} ex-common) - - IF(ALSOFT_INSTALL) - INSTALL(TARGETS alffplay - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - ENDIF() - MESSAGE(STATUS "Building SDL+FFmpeg example programs") - ENDIF() - MESSAGE(STATUS "") - ENDIF() -ENDIF() + message(STATUS "Building SDL example programs") + + set(FFVER_OK FALSE) + if(FFMPEG_FOUND) + set(FFVER_OK TRUE) + if(AVFORMAT_VERSION VERSION_LESS "59.27.100") + message(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 59.27.100)") + set(FFVER_OK FALSE) + endif() + if(AVCODEC_VERSION VERSION_LESS "59.37.100") + message(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 59.37.100)") + set(FFVER_OK FALSE) + endif() + if(AVUTIL_VERSION VERSION_LESS "57.28.100") + message(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 57.28.100)") + set(FFVER_OK FALSE) + endif() + if(SWSCALE_VERSION VERSION_LESS "6.7.100") + message(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 6.7.100)") + set(FFVER_OK FALSE) + endif() + if(SWRESAMPLE_VERSION VERSION_LESS "4.7.100") + message(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 4.7.100)") + set(FFVER_OK FALSE) + endif() + endif() + if(FFVER_OK) + add_executable(alffplay examples/alffplay.cpp) + target_include_directories(alffplay PRIVATE ${FFMPEG_INCLUDE_DIRS}) + target_link_libraries(alffplay + PRIVATE ${LINKER_FLAGS} SDL2::SDL2 ${FFMPEG_LIBRARIES} ex-common) + set_target_properties(alffplay PROPERTIES ${DEFAULT_TARGET_PROPS}) + + if(ALSOFT_INSTALL_EXAMPLES) + set(EXTRA_INSTALLS ${EXTRA_INSTALLS} alffplay) + endif() + message(STATUS "Building SDL+FFmpeg example programs") + endif() + endif() + message(STATUS "") +endif() + +if(EXTRA_INSTALLS) + install(TARGETS ${EXTRA_INSTALLS} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() |