diff --git a/CMakeLists.txt b/CMakeLists.txt index 37342276..55951d66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,8 @@ option(ENABLE_GDAL "Set to ON to build SimGear with GDAL support" OFF) option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON) option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON) option(USE_AEONWAVE "Set to ON to use AeonWave instead of OpenAL" ON) +option(USE_OPENALSOFT "Set to ON to use OpenAL from OpenAL-soft" OFF) + option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" ON) option(ENABLE_SIMD "Enable SSE/SSE2 support for compilers" ON) option(ENABLE_SIMD_CODE "Enable SSE/SSE2 support code for compilers" OFF) @@ -147,13 +149,26 @@ else() if(NOT AAX_FOUND) set(USE_AEONWAVE FALSE) - find_package(OpenAL REQUIRED) + if (USE_OPENALSOFT) + message(STATUS "Sound requested to use OpenAL-soft: ensure Config.cmake files are in CMAKE_PREFIX_PATH") + find_package(OpenAL REQUIRED CONFIG) + if (TARGET OpenAL::OpenAL) + set(SG_SOUND_USES_OPENALSOFT 1) + endif() + else() + # regular OpenAL is found via the CMake distro-suppling FindOpenAL + find_package(OpenAL REQUIRED) + endif() + + message(STATUS "OpenAL: ${OPENAL_LIBRARY}") endif() if(AAX_FOUND) message(STATUS "Sound support: AeonWave") + elseif (TARGET OpenAL::OpenAL) + message(STATUS "Sound support: OpenAL-soft") else() - message(STATUS "Sound support: OpenAL") + message(STATUS "Sound support: OpenAL (from system)") endif() endif(ENABLE_SOUND) diff --git a/SimGearConfig.cmake.in b/SimGearConfig.cmake.in index fa1007cc..43a337a8 100644 --- a/SimGearConfig.cmake.in +++ b/SimGearConfig.cmake.in @@ -10,6 +10,8 @@ find_dependency(CURL) set(SIMGEAR_HEADLESS @SIMGEAR_HEADLESS@) set(SIMGEAR_SOUND @ENABLE_SOUND@) set(USE_AEONWAVE @USE_AEONWAVE@) +set(SG_SOUND_USES_OPENALSOFT @SG_SOUND_USES_OPENALSOFT@) + set(ENABLE_ASAN @ENABLE_ASAN@) set(SIMGEAR_SHARED @SIMGEAR_SHARED@) @@ -23,6 +25,21 @@ if(SG_HAVE_DDS) find_dependency(CycloneDDS) endif() + +if (SIMGEAR_SOUND) + # find the sound dependency + if (USE_AEONWAVE) + find_dependency(AAX) + elseif(SG_SOUND_USES_OPENALSOFT) + # must force CONFIG mode when using OpenAL soft, to avoid picking + # the CMake supplied FindOpenAL and hence defaults to the system + # framework on macOS + find_dependency(OpenAL CONFIG) + else() + find_dependency(OpenAL) + endif() +endif() + # OpenRTI support set(ENABLE_RTI @ENABLE_RTI@) if(ENABLE_RTI) diff --git a/simgear/simgear_config_cmake.h.in b/simgear/simgear_config_cmake.h.in index f7cb02a8..5be90c9b 100644 --- a/simgear/simgear_config_cmake.h.in +++ b/simgear/simgear_config_cmake.h.in @@ -26,6 +26,7 @@ #cmakedefine SYSTEM_EXPAT #cmakedefine ENABLE_SOUND #cmakedefine USE_AEONWAVE +#cmakedefine SG_SOUND_USES_OPENALSOFT #cmakedefine ENABLE_SIMD #cmakedefine ENABLE_SIMD_CODE #cmakedefine ENABLE_GDAL