diff --git a/.github/workflows/ci-web.yml b/.github/workflows/ci-web.yml index 9278625..a9706ee 100644 --- a/.github/workflows/ci-web.yml +++ b/.github/workflows/ci-web.yml @@ -60,7 +60,7 @@ jobs: emcmake cmake .. \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release - echo "Note: Tests are automatically disabled for Emscripten builds due to testcoe compatibility issues" + echo "Note: Tests disabled for Emscripten due to testcoe/backward-cpp unwind conflicts" shell: bash - name: Build WebAssembly artifacts @@ -82,14 +82,14 @@ jobs: # Validate soundcoe library was built SOUNDCOE_LIB=$(find . -name "libsoundcoe.a" -type f) if [ -n "$SOUNDCOE_LIB" ]; then - echo "✅ soundcoe library built successfully at: $SOUNDCOE_LIB" + echo "soundcoe library built successfully at: $SOUNDCOE_LIB" else - echo "❌ soundcoe library missing" + echo "soundcoe library missing" exit 1 fi - echo "✅ WebAssembly build validation completed" - echo "Note: Tests are disabled for Emscripten due to testcoe compatibility issues" + echo "WebAssembly build validation completed" + echo "Note: Tests disabled for Emscripten due to testcoe/backward-cpp unwind conflicts" shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d53c93..736d83b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,17 +8,26 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(FetchContent) include(cmake/soundcoe_config.cmake) -message(STATUS "[soundcoe] Fetching OpenAL-Soft from source...") - -FetchContent_Declare( - openal - GIT_REPOSITORY https://github.com/kcat/openal-soft.git - GIT_TAG 1.24.3 -) - -configure_openal() -FetchContent_MakeAvailable(openal) -ignore_external_warnings(OpenAL) +find_package(Threads REQUIRED) + +# Configure OpenAL: Use Emscripten's built-in OpenAL or fetch OpenAL-Soft +if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + message(STATUS "[soundcoe] Using Emscripten's built-in OpenAL implementation") + # Emscripten provides its own OpenAL implementation via -lopenal linker flag + # No need to fetch or configure OpenAL-Soft +else() + message(STATUS "[soundcoe] Fetching OpenAL-Soft from source...") + + FetchContent_Declare( + openal + GIT_REPOSITORY https://github.com/kcat/openal-soft.git + GIT_TAG 1.24.3 + ) + + configure_openal() + FetchContent_MakeAvailable(openal) + ignore_external_warnings(OpenAL) +endif() message(STATUS "[soundcoe] Fetching logcoe from source...") diff --git a/cmake/openal_config.cmake b/cmake/openal_config.cmake index bd8da0e..ca69c3e 100644 --- a/cmake/openal_config.cmake +++ b/cmake/openal_config.cmake @@ -37,21 +37,7 @@ endfunction() # Configure OpenAL-Soft based on target platform function(configure_openal_for_platform) - if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") - # ================================================================ - # Emscripten/Web Build - Use Emscripten's built-in OpenAL - # ================================================================ - message(STATUS "[soundcoe] Configuring OpenAL-Soft for Emscripten/Web build") - - # Disable tests for web builds due to testcoe incompatibility with Emscripten - set(SOUNDCOE_BUILD_TESTS OFF CACHE BOOL "Tests disabled for Emscripten" FORCE) - message(STATUS "[soundcoe] Tests disabled for Emscripten due to testcoe compatibility issues") - - # Disable ALL native backends except NULL backend - disable_all_backends_except("NULL") - disable_all_require_flags() - - elseif(WIN32) + if(WIN32) # ================================================================ # Windows Build # ================================================================ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bcf8066..0e998dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,9 +17,22 @@ target_include_directories(soundcoe ${CMAKE_CURRENT_SOURCE_DIR}/../external ) -target_link_libraries(soundcoe - PUBLIC - soundcoe_headers - OpenAL - logcoe -) \ No newline at end of file +# Link libraries based on platform +if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + target_link_libraries(soundcoe + PUBLIC + soundcoe_headers + logcoe + Threads::Threads + ) + # Link with Emscripten's built-in OpenAL implementation + target_link_options(soundcoe PUBLIC -lopenal) +else() + target_link_libraries(soundcoe + PUBLIC + soundcoe_headers + OpenAL + logcoe + Threads::Threads + ) +endif() \ No newline at end of file