Skip to content

Commit

Permalink
Add AX_USE_ALSOFT_STATIC CMake option to compile and link OpenAL-soft…
Browse files Browse the repository at this point in the history
… as a static library. (#1654)
  • Loading branch information
j-jorge authored Feb 5, 2024
1 parent 583dcdc commit 5f747b9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ option(AX_WITH_OBOE "Build with oboe support" OFF)
# by default, enable ios,macOS openal-soft framework for legal license LGPL-2.1
option(ALSOFT_OSX_FRAMEWORK "" ON)

# Enable static library for openal-soft. This has an impact on the
# license of the final product since the source of the whole game must
# then be available under terms compatible with the LGPL (e.g. GPL,
# MPL). Consequently, we set it to OFF by default.
option(
AX_USE_ALSOFT_STATIC
"Link with OpenAL as a static library (LGPL-compatible apps only)."
OFF
)

set(ANDROID_SHARED_LOADS "" CACHE INTERNAL "The android shared libraries load source code" )
set(ANDROID_SHARED_LOAD_FILE_NAME "SharedLoader.java" CACHE INTERNAL "The android shared load java file name" )
set(ANDROID_SHARED_LOAD_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_SHARED_LOAD_FILE_NAME}.in" CACHE INTERNAL "The android shared libraries load config code file" )
Expand Down Expand Up @@ -58,11 +68,11 @@ if(AX_ISA_LEVEL)
macro(ax_check_c_source source outputVar)
if (NOT CMAKE_CROSSCOMPILING)
check_c_source_runs("${source}" ${outputVar})
else()
else()
check_c_source_compiles("${source}" ${outputVar})
endif()
endmacro(ax_check_c_source source var)

# Checking intel SIMD Intrinsics
include(CheckCSourceRuns)
if(APPLE)
Expand Down Expand Up @@ -250,7 +260,7 @@ ax_add_3rd(fmt EXCLUDE_FROM_ALL TARGETS fmt-header-only)
# bellow are non header only libs

# cpufeatures
if(ANDROID)
if(ANDROID)
add_subdirectory(android-specific/cpufeatures)
endif()

Expand Down Expand Up @@ -388,6 +398,11 @@ endif()
# The openal-soft(LGPL 2.1)
if(AX_USE_ALSOFT AND NOT EMSCRIPTEN)
set(alsoft_opts "ALSOFT_DLOPEN OFF" "ALSOFT_UTILS OFF" "ALSOFT_EXAMPLES OFF" "ALSOFT_INSTALL OFF")

if (AX_USE_ALSOFT_STATIC)
list(APPEND alsoft_opts "LIBTYPE STATIC")
endif()

if (ANDROID)
if(AX_WITH_OBOE)
_1kfetch(oboe)
Expand All @@ -408,7 +423,9 @@ if(AX_USE_ALSOFT AND NOT EMSCRIPTEN)
target_compile_definitions(thirdparty INTERFACE AX_USE_ALSOFT=1)
set_target_properties(OpenAL alcommon PROPERTIES CXX_STANDARD ${_AX_CXX_STD})

if(ANDROID)
if (AX_USE_ALSOFT_STATIC)
target_compile_definitions(thirdparty INTERFACE AL_LIBTYPE_STATIC=1)
elseif(ANDROID)
set(ANDROID_SHARED_LOADS "${ANDROID_SHARED_LOADS}System.loadLibrary(\"openal\");" CACHE INTERNAL "Android Shared Loads" )
endif()
endif()
Expand Down

0 comments on commit 5f747b9

Please sign in to comment.