diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 01f320db..7bc25dd5 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-14, windows-latest] + os: [ macos-14, windows-latest ] steps: - name: Checkout @@ -272,6 +272,30 @@ jobs: Write-Warning "Could not find lib or lib/intel64 under MKLROOT" Get-ChildItem "$env:MKLROOT" -Recurse -Depth 2 } + # --- vcpkg Setup (Windows) --- + - name: Export GitHub Actions cache environment variables + if: runner.os == 'Windows' + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Setup vcpkg + if: runner.os == 'Windows' + shell: powershell + run: | + echo "VCPKG_ROOT=C:\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append + cd C:\vcpkg + git pull + .\bootstrap-vcpkg.bat + + # --- Install vcpkg dependencies (Windows) --- + - name: Install vcpkg dependencies + if: runner.os == 'Windows' + shell: powershell + run: | + vcpkg install --triplet x64-windows # --- Configure (Windows) --- - name: Configure CMake (Windows) @@ -283,8 +307,10 @@ jobs: -DBUILD_TESTING=ON ` -DZMQ_BUILD_TESTS=OFF ` -DMKL_ROOT="$env:MKLROOT" ` + -DVCPKG_ROOT="$env:VCPKG_ROOT" ` -DVCPKG_TARGET_TRIPLET=x64-windows ` - -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" + -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" ` + -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="${{ github.workspace }}/cmake/toolchains/windows.cmake" # --- Configure (macOS) --- - name: Configure CMake (macOS) @@ -295,7 +321,8 @@ jobs: -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER=clang \ -DBUILD_TESTING=ON \ - -DZMQ_BUILD_TESTS=OFF + -DZMQ_BUILD_TESTS=OFF \ + -DCMAKE_TOOLCHAIN_FILE="cmake/toolchains/macos.cmake" # --- Build --- - name: Build diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a0abc1f..446f7e26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,64 +14,29 @@ cmake_minimum_required(VERSION 3.30.0) -if(WIN32) - # Disable vcpkg automatic DLL copying (applocal) - it fails without dumpbin in PATH - set(X_VCPKG_APPLOCAL_DEPS_INSTALL OFF CACHE BOOL "") - - # Increase stack size to 16MB to prevent stack overflows - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:16777216") -endif() +#==================================================================== +#Cmake Policies +#==================================================================== +cmake_policy(SET CMP0167 NEW) +cmake_policy(SET CMP0077 NEW) +cmake_policy(SET CMP0169 OLD) +#==================================================================== # Disable vcpkg from finding Boost and Protobuf (provided by libiamf) +#==================================================================== set(CMAKE_DISABLE_FIND_PACKAGE_Boost ON CACHE BOOL "" FORCE) set(CMAKE_DISABLE_FIND_PACKAGE_Protobuf ON CACHE BOOL "" FORCE) +#==================================================================== # Clear any cached Protobuf references +#==================================================================== unset(Protobuf_INCLUDE_DIRS CACHE) unset(Protobuf_LIBRARIES CACHE) unset(Protobuf_DIR CACHE) unset(Protobuf_FOUND CACHE) unset(Protobuf_PROTOC_EXECUTABLE CACHE) -cmake_policy(SET CMP0167 NEW) -cmake_policy(SET CMP0077 NEW) -cmake_policy(SET CMP0169 OLD) -set(CMAKE_CXX_EXTENSIONS OFF) - -# Configure release or debug builds -set(BUILD_LIB_DIR "$,Debug,Release>") - -# Windows vcpkg setup -if(WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - # Try environment variable first (respects user's existing setup) - if(DEFINED ENV{VCPKG_ROOT}) - set(VCPKG_ROOT "$ENV{VCPKG_ROOT}" CACHE PATH "Path to vcpkg root") - endif() - - # Configure vcpkg if VCPKG_ROOT is set - if(DEFINED VCPKG_ROOT) - set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "vcpkg toolchain file") - - # Validate toolchain file exists - if(NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}") - message(FATAL_ERROR "vcpkg toolchain file not found at: ${CMAKE_TOOLCHAIN_FILE}") - endif() - - # Set default triplet if not specified - if(NOT DEFINED VCPKG_TARGET_TRIPLET) - set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "vcpkg target triplet") - endif() - - message(WARNING "vcpkg toolchain: ${CMAKE_TOOLCHAIN_FILE}") - message(WARNING "vcpkg triplet: ${VCPKG_TARGET_TRIPLET}") - else() - message(WARNING "vcpkg not configured. Please either:") - message(WARNING " 1. Set VCPKG_ROOT environment variable, or") - message(WARNING " 2. Pass -DVCPKG_ROOT= to CMake") - message(WARNING "Build will continue without vcpkg - dependencies must be installed manually") - endif() -endif() - +#==================================================================== # Version configuration # The version can be set in multiple ways (in order of precedence): # 1. Pass via command line: cmake -DECLIPSA_VERSION=1.2.3 ... @@ -84,66 +49,72 @@ endif() # - Or extract from git tag in your build script and pass it to CMake # # The version appears as a watermark in the bottom-left corner of both plugins. -if(NOT DEFINED ECLIPSA_VERSION) +#==================================================================== +if (NOT DEFINED ECLIPSA_VERSION) set(ECLIPSA_VERSION "0.0.1" CACHE STRING "Version for Eclipsa project") -endif() +endif () project(Eclipsa LANGUAGES C CXX VERSION ${ECLIPSA_VERSION}) +#==================================================================== +# Compiler Settings +#==================================================================== +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +#==================================================================== +# Plugin Formats +#==================================================================== +set(ECLIPSA_PLUGIN_FORMATS Standalone) + +if (BUILD_VST3) + list(APPEND ECLIPSA_PLUGIN_FORMATS VST3) +endif () +if (BUILD_AAX) + list(APPEND ECLIPSA_PLUGIN_FORMATS AAX) +endif () + +list(APPEND ECLIPSA_PLUGIN_FORMATS ${ECLIPSA_PLATFORM_PLUGIN_FORMATS}) + +#==================================================================== +# Build Configuration +#==================================================================== +set(BUILD_LIB_DIR "$,Debug,Release>") add_compile_definitions(ECLIPSA_VERSION="${ECLIPSA_VERSION}") +#==================================================================== +# Plugin Naming +#==================================================================== # Make company name configurable via command line with a default value -if(NOT DEFINED ECLIPSA_COMPANY_NAME) +if (NOT DEFINED ECLIPSA_COMPANY_NAME) set(ECLIPSA_COMPANY_NAME "Eclipsa Project" CACHE STRING "Company name for Eclipsa project") -endif() - -if(WIN32 AND NOT CMAKE_RC_COMPILER) - find_program(CMAKE_RC_COMPILER rc.exe - HINTS "C:/Program Files (x86)/Windows Kits/10/bin/*/x64") -endif() - +endif () # Make manufacturer code configurable via command line with a default value -if(NOT DEFINED ECLIPSA_MANUFACTURER_CODE) +if (NOT DEFINED ECLIPSA_MANUFACTURER_CODE) set(ECLIPSA_MANUFACTURER_CODE "Eclp" CACHE STRING "Manufacturer code for Eclipsa project") -endif() - +endif () # Make bundle IDs configurable via command line with default values -if(NOT DEFINED ECLIPSA_RENDERER_BUNDLE_ID) +if (NOT DEFINED ECLIPSA_RENDERER_BUNDLE_ID) set(ECLIPSA_RENDERER_BUNDLE_ID "com.eclipsaproject.renderer" CACHE STRING "Bundle ID for the renderer plugin") -endif() - -if(NOT DEFINED ECLIPSA_PANNER_BUNDLE_ID) +endif () +if (NOT DEFINED ECLIPSA_PANNER_BUNDLE_ID) set(ECLIPSA_PANNER_BUNDLE_ID "com.eclipsaproject.panner" CACHE STRING "Bundle ID for the panner plugin") -endif() +endif () -# Build configuration for different DAW targets +#==================================================================== +# Build Options +#==================================================================== option(ECLIPSA_LOGIC_PRO_BUILD "Build AU plugin optimized for Logic Pro (7.1.4 layout)" OFF) - -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_BUILD_RPATH "@loader_path/../Resources;${CMAKE_SOURCE_DIR}") - -# Set default plugin formats per platform -if(APPLE) - set(PLUGIN_FORMATS "AU") -elseif(WIN32) - set(PLUGIN_FORMATS "Standalone") -else() - set(PLUGIN_FORMATS "") -endif() - option(INTERNAL_TEST OFF) option(CI_TEST OFF) option(JUCE_COPY_PLUGIN_AFTER_BUILD "Automatically copy built plugins to standard locations after build" ON) -if(APPLE) - # Add vendored libraries path (for CI/GitHub Actions) - set(VENDOR_LIB_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/macos") - link_directories(${VENDOR_LIB_PATH}) -endif() - -if(CI_TEST OR INTERNAL_TEST) +#==================================================================== +# Testing +#==================================================================== +if (CI_TEST OR INTERNAL_TEST) message(STATUS "Unit tests enabled") include(FetchContent) FetchContent_Declare( @@ -162,60 +133,86 @@ if(CI_TEST OR INTERNAL_TEST) if (FFMPEG_TOOLS_FOUND) message(STATUS "FFmpeg found. Enabling tests that require FFmpeg.") add_compile_definitions(ECLIPSA_FFMPEG_AVAILABLE=1) - else() + else () message(STATUS "FFmpeg not found. Tests requiring FFmpeg will be disabled.") - endif() + endif () # FFmpeg is required for CI tests - if(CI_TEST AND NOT FFMPEG_TOOLS_FOUND) + if (CI_TEST AND NOT FFMPEG_TOOLS_FOUND) message(FATAL_ERROR "FFmpeg tools not found. Required for CI tests.") - endif() -endif() + endif () +endif () -add_subdirectory(third_party) +#==================================================================== +# Cmake Functions +#==================================================================== +include("${CMAKE_SOURCE_DIR}/cmake/copy_resources.cmake") +include("${CMAKE_SOURCE_DIR}/cmake/eclipsa_plugin_defaults.cmake") -# ZLIB configuration for Windows builds +#==================================================================== +# Dependencies +#==================================================================== +add_subdirectory(third_party) if(WIN32) find_package(ZLIB REQUIRED) - message(STATUS "ZLIB found at: ${ZLIB_LIBRARIES}") - # Fix link targets that request 'z' link_libraries(ZLIB::ZLIB) endif() +#==================================================================== +# AAX Setup +#==================================================================== +if (BUILD_AAX) + find_path(AAX_SDK_ROOT + NAMES "Interfaces/AAX_Exports.cpp" + HINTS "${AAX_SDK_SEARCH_HINT}" + DOC "Path to AAX SDK" + ) -include("${CMAKE_SOURCE_DIR}/cmake/copy_resources.cmake") - -if(BUILD_AAX) - if(WIN32) - set(AAX_SDK_VER "2-8-1" CACHE STRING "AAX SDK Version") - list(APPEND PLUGIN_FORMATS "AAX") - - # Allow team members to specify their own AAX SDK path - if(NOT DEFINED AAX_SDK_ROOT) - set(AAX_SDK_ROOT "C:/Code/Repos/aax-sdk-${AAX_SDK_VER}" CACHE PATH "Path to AAX SDK") - endif() - else() - set(AAX_SDK_VER "2-7-0" CACHE STRING "Default AAX SDK Version") - list(APPEND PLUGIN_FORMATS "AAX") - find_path(AAX_SDK_ROOT NAMES "aax-sdk-${AAX_SDK_VER}" HINTS "/opt" "/usr/local") - set(AAX_SDK_ROOT "${AAX_SDK_ROOT}/aax-sdk-${AAX_SDK_VER}") - endif() - - if(EXISTS "${AAX_SDK_ROOT}") - message(STATUS "Using AAX SDK at ${AAX_SDK_ROOT}") + if (AAX_SDK_ROOT) + message(STATUS "AAX SDK found: ${AAX_SDK_ROOT}") juce_set_aax_sdk_path("${AAX_SDK_ROOT}") - else() - message(FATAL_ERROR "AAX SDK not found at ${AAX_SDK_ROOT}. Set AAX_SDK_ROOT to the correct path.") - endif() -endif() - -if(BUILD_VST3) - list(APPEND PLUGIN_FORMATS "VST3") -endif() - + else () + message(FATAL_ERROR "AAX SDK not found. Please set AAX_SDK_ROOT.") + endif () +endif () + +#==================================================================== +# Add Sub Directories +#==================================================================== add_subdirectory(common) +message(STATUS "ECLIPSA_PLUGIN_FORMATS = ${ECLIPSA_PLUGIN_FORMATS}") add_subdirectory(rendererplugin) add_subdirectory(audioelementplugin) +#==================================================================== +# Dependency List +#==================================================================== +if (NOT DEFINED ECLIPSA_PLATFORM_LIBS) + message(WARNING "ECLIPSA_PLATFORM_LIBS not set—are you using a platform toolchain?") + set(ECLIPSA_PLATFORM_LIBS "") +endif () + +add_library(eclipsa_dependencies INTERFACE) + +target_link_libraries(eclipsa_dependencies INTERFACE + # Vendored shared libs + vendored_gpac + vendored_iamf_tools + libzmq + + # Static libs from third_party + saf + Libear + LUFSMeter + spatialaudiolib + ${IAMF_LIB_NAME} + + # Platform-specific (from toolchain) + ${ECLIPSA_PLATFORM_LIBS} +) + +#==================================================================== +# Testing #2 +#==================================================================== if (CI_TEST OR INTERNAL_TEST) eclipsa_build_tests() -endif() \ No newline at end of file +endif () \ No newline at end of file diff --git a/README.md b/README.md index 0dd4f40d..de23002c 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ The CMake build supports the following flags: On MacOS, run the following command to configure the CMake build, adding any desired flags as needed ``` -cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S ./ -B ./build -G "Unix Makefiles" +cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S ./ -B ./build -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/macos.cmake + ``` Or using Ninja @@ -94,7 +95,8 @@ Then execute the Configure and Build commands via the CMake extension. On Windows, run the following command to configure the CMake build: ``` -cmake.exe -DVCPKG_ROOT:STRING=C:\Code\Repos\vcpkg "-DMKL_ROOT:STRING=C:\Program Files (x86)\Intel\oneAPI\mkl\2025.3" -DVCPKG_TARGET_TRIPLET:STRING=x64-windows -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S ./ -B ./build -G "Visual Studio 17 2022" -T host=x64 -A x64 +cmake.exe -DVCPKG_ROOT:STRING=C:\Code\Repos\vcpkg "-DMKL_ROOT:STRING=C:\Program Files (x86)\Intel\oneAPI\mkl\2025.3" -DVCPKG_TARGET_TRIPLET:STRING=x64-windows -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S ./ -B ./build -G "Visual Studio 17 2022" -T host=x64 -A x64 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/windows.cmake + ``` The plugin can then be built with the following command: @@ -102,7 +104,7 @@ The plugin can then be built with the following command: cmake --build ./build --config=Release ``` -Alternativel, use the CMake extension for Visual Studio Code adding the following to settings.json: +Alternatively, use the CMake extension for Visual Studio Code adding the following to settings.json: ``` "cmake.configureSettings": { "VCPKG_ROOT": "C:\\Code\\Repos\\vcpkg", diff --git a/audioelementplugin/CMakeLists.txt b/audioelementplugin/CMakeLists.txt index 02ee6b89..b47588fe 100644 --- a/audioelementplugin/CMakeLists.txt +++ b/audioelementplugin/CMakeLists.txt @@ -12,14 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +#==================================================================== # Set plugin code and name based on build type -if(ECLIPSA_LOGIC_PRO_BUILD) +#==================================================================== +if (ECLIPSA_LOGIC_PRO_BUILD) set(AUDIO_ELEMENT_PLUGIN_CODE "Eacl") set(AUDIO_ELEMENT_PRODUCT_NAME "Eclipsa Audio Element Plugin for Logic Pro") -else() +else () set(AUDIO_ELEMENT_PLUGIN_CODE "Ecae") set(AUDIO_ELEMENT_PRODUCT_NAME "Eclipsa Audio Element Plugin") -endif() +endif () juce_add_plugin(AudioElementPlugin PLUGIN_MANUFACTURER_CODE ${ECLIPSA_MANUFACTURER_CODE} @@ -31,7 +33,7 @@ juce_add_plugin(AudioElementPlugin IS_MIDI_EFFECT FALSE EDITOR_WANTS_KEYBOARD_FOCUS FALSE COPY_PLUGIN_AFTER_BUILD ${JUCE_COPY_PLUGIN_AFTER_BUILD} - FORMATS ${PLUGIN_FORMATS} + FORMATS ${ECLIPSA_PLUGIN_FORMATS} PRODUCT_NAME ${AUDIO_ELEMENT_PRODUCT_NAME} AAX_CATEGORY "AAX_ePlugInCategory_SoundField") @@ -44,6 +46,8 @@ target_sources(AudioElementPlugin src/screens/PositionSelectionScreen.cpp src/screens/TrackMonitorScreen.cpp) +eclipsa_plugin_defaults(AudioElementPlugin) + target_compile_definitions(AudioElementPlugin PUBLIC JUCE_WEB_BROWSER=0 @@ -53,24 +57,13 @@ target_compile_definitions(AudioElementPlugin JUCE_ENABLE_LIVE_CONSTANT_EDITOR=1 JucePlugin_Category="Spatial") -# Add DAW-specific build flags when enabled -if(ECLIPSA_LOGIC_PRO_BUILD) +if (ECLIPSA_LOGIC_PRO_BUILD) target_compile_definitions(AudioElementPlugin PRIVATE ECLIPSA_LOGIC_PRO_BUILD=1) -endif() - -# Platform-specific settings -if(APPLE) - target_link_options(AudioElementPlugin - PUBLIC - "-Wl" - "-ld_classic") -elseif(WIN32) - # MSVC flags for math constants - target_compile_definitions(AudioElementPlugin PRIVATE _USE_MATH_DEFINES) -endif() - -target_include_directories(AudioElementPlugin PUBLIC "${BOOST_LIBRARY_INCLUDES}/include") +endif () +#==================================================================== +#Link libraries +#==================================================================== target_link_libraries(AudioElementPlugin PRIVATE substream_rdr @@ -83,78 +76,35 @@ target_link_libraries(AudioElementPlugin juce::juce_recommended_lto_flags juce::juce_recommended_warning_flags) -if(WIN32) - target_link_libraries(AudioElementPlugin PRIVATE delayimp) -endif() - -# Platform-specific Boost linking -if(WIN32) - # Windows: Boost headers only (lockfree is header-only) - target_include_directories(AudioElementPlugin PRIVATE ${Boost_INCLUDE_DIRS}) -else() - # macOS: Modern CMake target - target_link_libraries(AudioElementPlugin PRIVATE Boost::lockfree) -endif() - -# Windows-specific: Link ZLIB -if(WIN32) - find_package(ZLIB REQUIRED) - if(ZLIB_FOUND) - message(STATUS "Linking AudioElementPlugin against ZLIB: ${ZLIB_LIBRARIES}") - target_link_libraries(AudioElementPlugin PRIVATE ZLIB::ZLIB) - if(TARGET AudioElementPlugin_VST3) - target_link_libraries(AudioElementPlugin_VST3 PRIVATE ZLIB::ZLIB) - endif() - else() - message(FATAL_ERROR "ZLIB not found for AudioElementPlugin") - endif() -endif() - -if(CI_TEST OR INTERNAL_TEST) +#==================================================================== +#Testing +#==================================================================== +if (CI_TEST OR INTERNAL_TEST) add_subdirectory(test) -endif() +endif () +#==================================================================== # Copy resources for each plugin format -if(BUILD_AAX AND TARGET AudioElementPlugin_AAX) - message(STATUS "AAX build detected. Setting up audio element plugin path and copying resources.") - set(AUDIO_ELEMENT_AAX_PATH "${CMAKE_BINARY_DIR}/audioelementplugin/AudioElementPlugin_artefacts/$/AAX/Eclipsa Audio Element Plugin.aaxplugin") - copy_resources(AudioElementPlugin_AAX "${AUDIO_ELEMENT_AAX_PATH}") - - if(WIN32) - foreach(dll IN LISTS DELAYLOAD_DLLS) - target_link_options(AudioElementPlugin_AAX PRIVATE /DELAYLOAD:${dll}) - endforeach() - endif() -endif() - -if(BUILD_VST3 AND TARGET AudioElementPlugin_VST3) - message(STATUS "VST3 build detected. Setting up Audio Element plugin path and copying resources.") - set(AUDIO_ELEMENT_VST3_PATH "${CMAKE_BINARY_DIR}/audioelementplugin/AudioElementPlugin_artefacts/$/VST3/Eclipsa Audio Element Plugin.vst3") - copy_resources(AudioElementPlugin_VST3 "${AUDIO_ELEMENT_VST3_PATH}") - - if (WIN32) - foreach(dll IN LISTS DELAYLOAD_DLLS) - target_link_options(AudioElementPlugin_VST3 PRIVATE /DELAYLOAD:${dll}) - endforeach() - endif() -endif() - -if(CMAKE_BUILD_TYPE STREQUAL "Release" AND APPLE) - message(STATUS "MacOS release build detected. Copying Audio Element Resources for AU Plugins.") - if(ECLIPSA_LOGIC_PRO_BUILD) - set(AUDIO_PLUGIN_PATH "${CMAKE_BINARY_DIR}/audioelementplugin/AudioElementPlugin_artefacts/Release/AU/Eclipsa Audio Element Plugin for Logic Pro.component") - else() - set(AUDIO_PLUGIN_PATH "${CMAKE_BINARY_DIR}/audioelementplugin/AudioElementPlugin_artefacts/Release/AU/Eclipsa Audio Element Plugin.component") - endif() - copy_resources(AudioElementPlugin ${AUDIO_PLUGIN_PATH}) -endif() - -if(TARGET AudioElementPlugin_Standalone) - message(STATUS "Standalone build detected. Setting up Audio Element plugin path and copying resources.") - set(AUDIO_ELEMENT_STANDALONE_PATH "${CMAKE_BINARY_DIR}/audioelementplugin/AudioElementPlugin_artefacts/$/Standalone") - copy_resources(AudioElementPlugin_Standalone "${AUDIO_ELEMENT_STANDALONE_PATH}") -endif() - -if(NOT BUILD_AAX AND NOT BUILD_VST3 AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") - message(STATUS "No supported plugin formats detected. Skipping resource setup and resource copy for Audio Element Plugin.") -endif() \ No newline at end of file +#==================================================================== +set(_ARTEFACTS_BASE "${CMAKE_BINARY_DIR}/audioelementplugin/AudioElementPlugin_artefacts") +set(_PLUGIN_NAME "Eclipsa Audio Element Plugin") + +if (TARGET AudioElementPlugin_AAX) + copy_resources(AudioElementPlugin_AAX "${_ARTEFACTS_BASE}/$/AAX/${_PLUGIN_NAME}.aaxplugin") +endif () + +if (TARGET AudioElementPlugin_VST3) + copy_resources(AudioElementPlugin_VST3 "${_ARTEFACTS_BASE}/$/VST3/${_PLUGIN_NAME}.vst3") +endif () + +if (TARGET AudioElementPlugin_Standalone) + copy_resources(AudioElementPlugin_Standalone "${_ARTEFACTS_BASE}/$/Standalone") +endif () + +if (TARGET AudioElementPlugin_AU) + if (ECLIPSA_LOGIC_PRO_BUILD) + copy_resources(AudioElementPlugin_AU "${_ARTEFACTS_BASE}/$/AU/${_PLUGIN_NAME} for Logic Pro.component") + else () + copy_resources(AudioElementPlugin_AU "${_ARTEFACTS_BASE}/$/AU/${_PLUGIN_NAME}.component") + endif () +endif () diff --git a/cmake/boost.cmake b/cmake/boost.cmake index e63d0bab..4a190e47 100644 --- a/cmake/boost.cmake +++ b/cmake/boost.cmake @@ -9,33 +9,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # Suppress CMake 3.31+ warning about FindBoost being deprecated -if(POLICY CMP0167) +if (POLICY CMP0167) cmake_policy(SET CMP0167 OLD) -endif() - -set(BOOST_COMPONENTS log log_setup thread filesystem math) +endif () message(STATUS "Fetching Boost") -include(FetchContent) -set(BOOST_ENABLE_CMAKE ON) - -if(WIN32) - set(Boost_USE_STATIC_RUNTIME OFF) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - add_definitions(-DBOOST_ALL_NO_LIB) - -endif() +set(BOOST_COMPONENTS log log_setup thread filesystem math) +set(BOOST_ENABLE_CMAKE ON) set(BOOST_LOCALE_ENABLE_ICU OFF) +include(FetchContent) FetchContent_Declare( Boost USES_TERMINAL_DOWNLOAD TRUE DOWNLOAD_NO_EXTRACT FALSE OVERRIDE_FIND_PACKAGE URL "https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz" - CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF) + CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF +) FetchContent_MakeAvailable(Boost) -find_package(Boost 1.86.0 COMPONENTS ${BOOST_COMPONENTS}) - - +find_package(Boost 1.86.0 COMPONENTS ${BOOST_COMPONENTS}) \ No newline at end of file diff --git a/cmake/copy_resources.cmake b/cmake/copy_resources.cmake index 6dcf9769..db6042b3 100644 --- a/cmake/copy_resources.cmake +++ b/cmake/copy_resources.cmake @@ -13,96 +13,50 @@ # limitations under the License. function(copy_resources target plugin_path) - if(APPLE) - # macOS: Copy dylibs to Resources - set(LIB_OBR_PATH "${CMAKE_SOURCE_DIR}/third_party/obr/lib/obr.dylib") - set(LIB_IAMF_TOOLS_PATH "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/libiamf_tools.dylib") - set(LIB_ZMQ_5_2_6_PATH "${CMAKE_BINARY_DIR}/_deps/zeromq-build/lib/libzmq.5.2.6.dylib") - set(LIB_GPAC_PATH "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/libgpac.dylib") - # Set Resources directory and external subdirectories - set(RESOURCES_DIR "${plugin_path}/Contents/Resources") - set(EXTERNAL_IAMF_DIR "${RESOURCES_DIR}/third_party/iamftools/lib") - set(EXTERNAL_OBR_DIR "${RESOURCES_DIR}/third_party/obr/lib") - set(EXTERNAL_GPAC_DIR "${RESOURCES_DIR}/third_party/gpac/lib") + if (APPLE) + set(DEST_ROOT "${plugin_path}/Contents/Resources") - # Copy libraries to the appropriate directories - add_custom_command(TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTERNAL_IAMF_DIR} - COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTERNAL_OBR_DIR} - COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTERNAL_GPAC_DIR} - COMMAND ${CMAKE_COMMAND} -E copy ${LIB_OBR_PATH} ${EXTERNAL_OBR_DIR}/obr.dylib - COMMAND ${CMAKE_COMMAND} -E copy ${LIB_IAMF_TOOLS_PATH} ${EXTERNAL_IAMF_DIR}/libiamf_tools.dylib - COMMAND ${CMAKE_COMMAND} -E copy ${LIB_GPAC_PATH} ${EXTERNAL_GPAC_DIR}/libgpac.dylib - COMMAND ${CMAKE_COMMAND} -E copy ${LIB_ZMQ_5_2_6_PATH} ${RESOURCES_DIR}/libzmq.5.2.6.dylib - - # Create symbolic links for libzmq - COMMAND ${CMAKE_COMMAND} -E create_symlink libzmq.5.2.6.dylib ${RESOURCES_DIR}/libzmq.5.dylib - COMMAND ${CMAKE_COMMAND} -E create_symlink libzmq.5.dylib ${RESOURCES_DIR}/libzmq.dylib - ) - - elseif(WIN32) - # Set DLL names using generator expressions for multi-config generators - set(GPAC_DLL "libgpac.dll") - set(CRYPTOMD_DLL "libcryptoMD.dll") - set(LIBSSLMD_DLL "libsslMD.dll") - set(IAMF_TOOLS_DLL "iamf_tools.dll") - set(OPENSVC_DECODER "OpenSVCDecoder.dll") - set(ZMQ_DLL "libzmq-v143-mt$<$:-gd>-4_3_6.dll") - - # Export DLL list to parent scope for DELAYLOAD configuration - set(DELAYLOAD_DLLS - ${GPAC_DLL} - ${CRYPTOMD_DLL} - ${LIBSSLMD_DLL} - ${IAMF_TOOLS_DLL} - ${OPENSVC_DECODER} - ${ZMQ_DLL} - PARENT_SCOPE + add_custom_command(TARGET ${target} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_ROOT}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_ROOT}/third_party/gpac/lib" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_ROOT}/third_party/iamftools/lib" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_ROOT}/third_party/obr/lib" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${DEST_ROOT}/third_party/gpac/lib/" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${DEST_ROOT}/third_party/iamftools/lib/" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${DEST_ROOT}/third_party/obr/lib/" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${DEST_ROOT}/" + COMMAND ${CMAKE_COMMAND} -E create_symlink "$" "${DEST_ROOT}/libzmq.5.dylib" + COMMAND ${CMAKE_COMMAND} -E create_symlink "libzmq.5.dylib" "${DEST_ROOT}/libzmq.dylib" ) - # Set the paths to the DLLs - set(GPAC_DLL_PATH "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/$/${GPAC_DLL}") - set(CRYPTOMD_DLL_PATH "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/$/${CRYPTOMD_DLL}") - set(LIBSSLMD_DLL_PATH "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/$/${LIBSSLMD_DLL}") - set(IAMF_TOOLS_DLL_PATH "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/Windows/$/${IAMF_TOOLS_DLL}") - set(OPENSVC_DECODER_PATH "${CMAKE_SOURCE_DIR}/third_party/OpenSVC/lib/Windows/$/${OPENSVC_DECODER}") - set(ZMQ_DLL_PATH "${CMAKE_BINARY_DIR}/_deps/zeromq-build/bin/$/${ZMQ_DLL}") - - - if("${target}" MATCHES ".*_VST3$") - set(PLUGIN_BINARY_DIR "${plugin_path}/Contents/x86_64-win") - elseif("${target}" MATCHES ".*_AAX$") - set(PLUGIN_BINARY_DIR "${plugin_path}/Contents/x64") - elseif("${target}" MATCHES ".*_Standalone$") - set(PLUGIN_BINARY_DIR "${plugin_path}") - else() - message(WARNING "Unknown plugin format for target: ${target}. Skipping DLL copy.") + elseif (WIN32) + if ("${target}" MATCHES ".*_VST3$") + set(DEST_ROOT "${plugin_path}/Contents/x86_64-win") + elseif ("${target}" MATCHES ".*_AAX$") + set(DEST_ROOT "${plugin_path}/Contents/x64") + elseif ("${target}" MATCHES ".*_Standalone$") + set(DEST_ROOT "${plugin_path}") + else () + message(WARNING "Unknown plugin format: ${target}") return() - endif() + endif () - # Single POST_BUILD command per target - add_custom_command(TARGET ${target} PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${PLUGIN_BINARY_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GPAC_DLL_PATH} "${PLUGIN_BINARY_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CRYPTOMD_DLL_PATH} "${PLUGIN_BINARY_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBSSLMD_DLL_PATH} "${PLUGIN_BINARY_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${IAMF_TOOLS_DLL_PATH} "${PLUGIN_BINARY_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZMQ_DLL_PATH} "${PLUGIN_BINARY_DIR}/" - COMMENT "Copied DLLs to ${PLUGIN_BINARY_DIR}" - ) + set(COPY_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_ROOT}") + foreach (_dep IN LISTS ECLIPSA_VENDORED_LIBS) + list(APPEND COPY_COMMANDS + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${DEST_ROOT}/") + target_link_options(${target} PRIVATE "/DELAYLOAD:$") + endforeach () + add_custom_command(TARGET ${target} PRE_BUILD ${COPY_COMMANDS}) - # Copy DLLs to Debug folder in build directory for use by the JUCE VST3 tool - # The tool runs from this directory and runs the plugins, so the DLLs need to be here as well set(VST3_SIGNING_DIR "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB_DIR}") - add_custom_command(TARGET ${target} PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${VST3_SIGNING_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GPAC_DLL_PATH} "${VST3_SIGNING_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CRYPTOMD_DLL_PATH} "${VST3_SIGNING_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBSSLMD_DLL_PATH} "${VST3_SIGNING_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${IAMF_TOOLS_DLL_PATH} "${VST3_SIGNING_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZMQ_DLL_PATH} "${VST3_SIGNING_DIR}/" - COMMENT "Copied DLLs to ${VST3_SIGNING_DIR}" - ) - endif() + set(SIGNING_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory "${VST3_SIGNING_DIR}") + foreach (_dep IN LISTS ECLIPSA_VENDORED_LIBS) + list(APPEND SIGNING_COMMANDS + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${VST3_SIGNING_DIR}/") + endforeach () + add_custom_command(TARGET ${target} PRE_BUILD ${SIGNING_COMMANDS}) + endif () + endfunction() \ No newline at end of file diff --git a/cmake/deploy_runtime_deps.cmake b/cmake/deploy_runtime_deps.cmake new file mode 100644 index 00000000..ce930b4a --- /dev/null +++ b/cmake/deploy_runtime_deps.cmake @@ -0,0 +1,84 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +function(deploy_runtime_deps target) + + set(_BASE "$") + + # Determine destination based on platform + if (TARGET vendored_obr) + # macOS: bundle structure + set(DEST_ROOT "$/Resources") + set(DEST_IAMF "${DEST_ROOT}/third_party/iamftools/lib") + set(DEST_GPAC "${DEST_ROOT}/third_party/gpac/lib") + set(DEST_OBR "${DEST_ROOT}/third_party/obr/lib") + else () + # Windows: flat structure based on target type + if ("${target}" MATCHES ".*_VST3$") + set(DEST_ROOT "${_BASE}/Contents/x86_64-win") + elseif ("${target}" MATCHES ".*_AAX$") + set(DEST_ROOT "${_BASE}/Contents/x64") + else () + set(DEST_ROOT "${_BASE}") + endif () + set(DEST_IAMF "${DEST_ROOT}") + set(DEST_GPAC "${DEST_ROOT}") + endif () + + # Delay-load (Windows only) + if (DEFINED ECLIPSA_DELAYLOAD_LIBS) + foreach (_lib ${ECLIPSA_DELAYLOAD_LIBS}) + target_link_options(${target} PRIVATE "/DELAYLOAD:$") + endforeach () + endif () + + # Create directories + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_ROOT}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_IAMF}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_GPAC}" + COMMENT "Deploying runtime deps to ${target}" + ) + + # Copy vendored libs (uses ECLIPSA_VENDORED_LIBS from prebuiltLibs) + foreach (_lib ${ECLIPSA_VENDORED_LIBS}) + if (TARGET ${_lib}) + if ("${_lib}" STREQUAL "vendored_gpac") + set(_dest "${DEST_GPAC}") + elseif ("${_lib}" STREQUAL "vendored_iamf_tools") + set(_dest "${DEST_IAMF}") + elseif ("${_lib}" STREQUAL "vendored_obr") + set(_dest "${DEST_OBR}") + add_custom_command(TARGET ${target} POST_BUILD APPEND + COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_OBR}" + ) + else () + set(_dest "${DEST_ROOT}") + endif () + + add_custom_command(TARGET ${target} POST_BUILD APPEND + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${_dest}/" + ) + endif () + endforeach () + + # macOS symlinks for zmq + if (TARGET vendored_obr) + add_custom_command(TARGET ${target} POST_BUILD APPEND + COMMAND ${CMAKE_COMMAND} -E create_symlink "$" "${DEST_ROOT}/libzmq.5.dylib" + COMMAND ${CMAKE_COMMAND} -E create_symlink "libzmq.5.dylib" "${DEST_ROOT}/libzmq.dylib" + ) + endif () + +endfunction() \ No newline at end of file diff --git a/cmake/eclipsa_build_tests.cmake b/cmake/eclipsa_build_tests.cmake index 42095fb0..0d06914c 100644 --- a/cmake/eclipsa_build_tests.cmake +++ b/cmake/eclipsa_build_tests.cmake @@ -12,57 +12,63 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Function to build a single test executable from all the collected test sources function(eclipsa_build_tests) get_property(test_sources GLOBAL PROPERTY ECLIPSA_TEST_SOURCES) get_property(test_link_libs GLOBAL PROPERTY ECLIPSA_TEST_LINK_LIBS) - # Remove duplicates from the list of libraries list(REMOVE_DUPLICATES test_link_libs) add_executable(eclipsa_tests ${test_sources}) target_compile_definitions(eclipsa_tests - PUBLIC + PUBLIC JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_VST3_CAN_REPLACE_VST2=0 - JUCE_SILENCE_XCODE_15_LINKER_WARNING) + JUCE_SILENCE_XCODE_15_LINKER_WARNING + ) - if(APPLE) - set(VENDOR_LIB_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/macos") - target_link_directories(eclipsa_tests PRIVATE ${VENDOR_LIB_PATH}) - elseif(WIN32) - set(VENDOR_LIB_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/Windows/${CMAKE_BUILD_TYPE}") - target_link_directories(eclipsa_tests PRIVATE ${VENDOR_LIB_PATH}) + # Vendor library path (set in toolchain) + if (DEFINED LIBIAMF_VENDOR_PATH) + target_link_directories(eclipsa_tests PRIVATE "${LIBIAMF_VENDOR_PATH}") + elseif (DEFINED LIBIAMF_VENDOR_RELEASE_PATH) + target_link_directories(eclipsa_tests PRIVATE + "$,${LIBIAMF_VENDOR_DEBUG_PATH},${LIBIAMF_VENDOR_RELEASE_PATH}>" + ) + endif () - # Move the dlls required for the unit tests as well - # This can be done in the post build, since we'll run the tests after the build is complete - set(ZMQ_DLL "${CMAKE_BINARY_DIR}/_deps/zeromq-build/bin/${BUILD_LIB_DIR}/libzmq-v143-mt$<$:-gd>-4_3_6.dll") - set(CRYPTOMD_DLL "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/${CMAKE_BUILD_TYPE}/libcryptoMD.dll") - set(LIBSSLMD_DLL "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/${CMAKE_BUILD_TYPE}/libsslMD.dll") - - set(TEST_DIR "${CMAKE_BINARY_DIR}/${BUILD_LIB_DIR}") + if (WIN32 AND DEFINED ECLIPSA_TEST_DLLS) add_custom_command(TARGET eclipsa_tests POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${TEST_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZMQ_DLL} "${TEST_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CRYPTOMD_DLL} "${TEST_DIR}/" - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBSSLMD_DLL} "${TEST_DIR}/" - COMMENT "Copied Test DLLs to ${TEST_DIR}" + COMMAND ${CMAKE_COMMAND} -E make_directory "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${ECLIPSA_TEST_DLLS} + "$/" + COMMAND_EXPAND_LISTS + COMMENT "Copying test DLLs to $" ) - endif() + endif () - if(DEFINED LIBIAMF_INCLUDE_DIRS) + if (DEFINED LIBIAMF_INCLUDE_DIRS) target_include_directories(eclipsa_tests PRIVATE ${LIBIAMF_INCLUDE_DIRS}) - endif() - + endif () + target_link_libraries(eclipsa_tests - PRIVATE + PRIVATE ${test_link_libs} - PUBLIC + PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_warning_flags - GTest::gtest_main) + GTest::gtest_main + ) + + if (WIN32) + add_custom_command(TARGET eclipsa_tests POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + COMMAND_EXPAND_LISTS + COMMENT "Copying runtime DLLs for eclipsa_tests" + ) + endif () - gtest_discover_tests(eclipsa_tests - DISCOVERY_MODE PRE_TEST) + gtest_discover_tests(eclipsa_tests DISCOVERY_MODE PRE_TEST) endfunction() \ No newline at end of file diff --git a/cmake/eclipsa_plugin_defaults.cmake b/cmake/eclipsa_plugin_defaults.cmake new file mode 100644 index 00000000..1a577b75 --- /dev/null +++ b/cmake/eclipsa_plugin_defaults.cmake @@ -0,0 +1,25 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +function(eclipsa_plugin_defaults target) + target_compile_definitions(${target} + PUBLIC + JUCE_WEB_BROWSER=0 + JUCE_USE_CURL=0 + JUCE_VST3_CAN_REPLACE_VST2=0 + JUCE_SILENCE_XCODE_15_LINKER_WARNING + JUCE_ENABLE_LIVE_CONSTANT_EDITOR=1) + + target_include_directories(${target} PUBLIC "${BOOST_LIBRARY_INCLUDES}/include") +endfunction() \ No newline at end of file diff --git a/cmake/eclipsa_test.cmake b/cmake/eclipsa_test.cmake index 2fb99d8d..baea97e0 100644 --- a/cmake/eclipsa_test.cmake +++ b/cmake/eclipsa_test.cmake @@ -17,45 +17,51 @@ # test_source: Test source file name. # test_libs: Test link libraries as ';' separated list. function(eclipsa_add_test test_name test_source test_libs) - # Construct the absolute path to the test source file set(absolute_test_source "${CMAKE_CURRENT_SOURCE_DIR}/${test_source}") - # Append the absolute test source path to a global list of sources get_property(test_sources GLOBAL PROPERTY ECLIPSA_TEST_SOURCES) set_property(GLOBAL PROPERTY ECLIPSA_TEST_SOURCES "${test_sources};${absolute_test_source}") - # Append the test libraries to a global list of libraries - get_property(test_link_libs GLOBAL PROPERTY ECLIPSA_TEST_LINK_LIBS) - set_property(GLOBAL PROPERTY ECLIPSA_TEST_LINK_LIBS "${test_link_libs};${test_libs}") + # Only add codec libs when a test needs IAMF decode/encode stack + set(_needs_iamf_codecs FALSE) + if ("${test_libs}" MATCHES "(^|;)iamf(;|$)" OR "${test_libs}" MATCHES "(^|;)iamfdec_utils(;|$)") + set(_needs_iamf_codecs TRUE) + endif () + + if (_needs_iamf_codecs) + if (APPLE) + set(LIBIAMF_CODEC_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/macos") + list(APPEND test_libs + "${LIBIAMF_CODEC_PATH}/libopus.a" + "${LIBIAMF_CODEC_PATH}/libogg.a" + ) + elseif (WIN32) + set(LIBIAMF_CODEC_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/Windows") + list(APPEND test_libs + $,${LIBIAMF_CODEC_PATH}/Debug/opus.lib,${LIBIAMF_CODEC_PATH}/Release/opus.lib> + $,${LIBIAMF_CODEC_PATH}/Debug/ogg.lib,${LIBIAMF_CODEC_PATH}/Release/ogg.lib> + ) + endif () + endif () + + # IAMF include dirs warning + if (_needs_iamf_codecs AND NOT DEFINED LIBIAMF_INCLUDE_DIRS) + message(WARNING "LIBIAMF_INCLUDE_DIRS not defined, but required by ${test_name}") + endif () - # Add codec libraries for all test targets if on macOS - if(APPLE) - # Append only if not already present in test_libs - list(FIND test_libs "opus" opus_found) - if(opus_found EQUAL -1) - list(APPEND test_libs opus) - endif() - list(FIND test_libs "ogg" ogg_found) - if(ogg_found EQUAL -1) - list(APPEND test_libs ogg) - endif() - endif() - - # Add IAMF include directories if 'iamf' or 'iamfdec_utils' is requested - if("${test_libs}" MATCHES "iamf" OR "${test_libs}" MATCHES "iamfdec_utils") - if(NOT DEFINED LIBIAMF_INCLUDE_DIRS) - message(WARNING "LIBIAMF_INCLUDE_DIRS not defined, but required by ${test_name}") - endif() - endif() - - # If iamfdec_utils was requested, make sure iamf is also linked (dependency) - if(TARGET iamf AND "${test_libs}" MATCHES "iamfdec_utils") - # Check if iamf is already in the list to avoid duplicates + # If iamfdec_utils requested, ensure iamf is also linked + if (TARGET iamf AND "${test_libs}" MATCHES "(^|;)iamfdec_utils(;|$)") list(FIND test_libs "iamf" iamf_already_linked) - if(iamf_already_linked EQUAL -1) - # Link iamf privately as it's a dependency of a private lib + if (iamf_already_linked EQUAL -1) list(APPEND test_libs iamf) - message(STATUS "Also linking core 'iamf' library as dependency for ${test_name}") - endif() - endif() -endfunction() \ No newline at end of file + endif () + endif () + + get_property(test_link_libs GLOBAL PROPERTY ECLIPSA_TEST_LINK_LIBS) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test_resources") + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/test_resources" + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") + endif () + + set_property(GLOBAL PROPERTY ECLIPSA_TEST_LINK_LIBS "${test_link_libs};${test_libs}") +endfunction() diff --git a/cmake/pffft.cmake b/cmake/pffft.cmake index 5eb61825..7b0c2ec5 100644 --- a/cmake/pffft.cmake +++ b/cmake/pffft.cmake @@ -12,38 +12,32 @@ # See the License for the specific language governing permissions and # limitations under the License. -message(STATUS "Using prebuilt pffft from obr build") +include(FetchContent) -if (WIN32) - # Fetch pffft from source on Windows too - include(FetchContent) - FetchContent_Declare( - pffft - GIT_REPOSITORY "https://github.com/marton78/pffft.git" - SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/pffft-src - ) - FetchContent_GetProperties(pffft) - if(NOT pffft_POPULATED) - FetchContent_Populate(pffft) - add_library(pffft STATIC IMPORTED) - set_target_properties(pffft PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/third_party/Windows/pffft.lib" - ) - target_include_directories(pffft INTERFACE ${pffft_SOURCE_DIR}) - endif() -else() +FetchContent_Declare( + pffft + GIT_REPOSITORY "https://github.com/marton78/pffft.git" + SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/pffft-src +) - # macOS/Linux - fetch and build from source - include(FetchContent) - FetchContent_Declare( - pffft - GIT_REPOSITORY "https://github.com/marton78/pffft.git" - SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/pffft-src - ) - FetchContent_GetProperties(pffft) - if(NOT pffft_POPULATED) +FetchContent_GetProperties(pffft) +if (NOT pffft_POPULATED) FetchContent_Populate(pffft) - add_library(pffft STATIC ${pffft_SOURCE_DIR}/pffft.c) - target_include_directories(pffft PUBLIC ${pffft_SOURCE_DIR}) - endif() -endif() \ No newline at end of file + + if (DEFINED PFFFT_RELEASE_LIB) + # Use prebuilt library (set in toolchain) + message(STATUS "Using prebuilt pffft from: ${PFFFT_RELEASE_LIB}") + add_library(pffft STATIC IMPORTED) + set_target_properties(pffft PROPERTIES + IMPORTED_LOCATION "${PFFFT_RELEASE_LIB}" + IMPORTED_LOCATION_DEBUG "${PFFFT_DEBUG_LIB}" + IMPORTED_LOCATION_RELEASE "${PFFFT_RELEASE_LIB}" + ) + target_include_directories(pffft INTERFACE ${pffft_SOURCE_DIR}) + else () + # Build from source + message(STATUS "Building pffft from source") + add_library(pffft STATIC ${pffft_SOURCE_DIR}/pffft.c) + target_include_directories(pffft PUBLIC ${pffft_SOURCE_DIR}) + endif () +endif () \ No newline at end of file diff --git a/cmake/prebuiltLibs/macos.cmake b/cmake/prebuiltLibs/macos.cmake new file mode 100644 index 00000000..6876f966 --- /dev/null +++ b/cmake/prebuiltLibs/macos.cmake @@ -0,0 +1,52 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +#==================================================================== +# Prebuilt Libraries +#==================================================================== + +# GPAC +add_library(gpac_impl SHARED IMPORTED GLOBAL) +set_target_properties(gpac_impl PROPERTIES + IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/libgpac.dylib" +) +add_library(vendored_gpac ALIAS gpac_impl) + +# IAMF Tools +add_library(iamftools_impl SHARED IMPORTED GLOBAL) +set_target_properties(iamftools_impl PROPERTIES + IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/libiamf_tools.dylib" +) +add_library(vendored_iamf_tools ALIAS iamftools_impl) + +# OBR +add_library(obr_impl SHARED IMPORTED GLOBAL) +set_target_properties(obr_impl PROPERTIES + IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/third_party/obr/lib/obr.dylib" +) +add_library(vendored_obr ALIAS obr_impl) + +# Libear +add_library(libear_impl STATIC IMPORTED GLOBAL) +set_target_properties(libear_impl PROPERTIES + IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/third_party/libear/lib/libear.a" +) + +#==================================================================== +# Vendored Libraries +#==================================================================== +set(ECLIPSA_VENDORED_LIBS + vendored_gpac + vendored_iamf_tools + vendored_obr + libzmq + CACHE STRING "" +) \ No newline at end of file diff --git a/cmake/prebuiltLibs/windows.cmake b/cmake/prebuiltLibs/windows.cmake new file mode 100644 index 00000000..5bbb2e41 --- /dev/null +++ b/cmake/prebuiltLibs/windows.cmake @@ -0,0 +1,76 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +#==================================================================== +# Prebuilt Libraries +#==================================================================== + +# GPAC +add_library(gpac_impl SHARED IMPORTED GLOBAL) +set_target_properties(gpac_impl PROPERTIES + IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Release/libgpac.dll" + IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Debug/libgpac.dll" + IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Release/libgpac.lib" + IMPORTED_IMPLIB_DEBUG "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Debug/libgpac.lib" +) +add_library(vendored_gpac ALIAS gpac_impl) + +# IAMF Tools +add_library(iamftools_impl SHARED IMPORTED GLOBAL) +set_target_properties(iamftools_impl PROPERTIES + IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/Windows/Release/iamf_tools.dll" + IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/Windows/Debug/iamf_tools.dll" + IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/Windows/Release/iamf_tools.if.lib" + IMPORTED_IMPLIB_DEBUG "${CMAKE_SOURCE_DIR}/third_party/iamftools/lib/Windows/Debug/iamf_tools.if.lib" +) +add_library(vendored_iamf_tools ALIAS iamftools_impl) + +# GPAC Crypto +add_library(vendored_gpac_crypto SHARED IMPORTED GLOBAL) +set_target_properties(vendored_gpac_crypto PROPERTIES + IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Release/libcryptoMD.dll" + IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Debug/libcryptoMD.dll" +) + +# GPAC SSL +add_library(vendored_gpac_ssl SHARED IMPORTED GLOBAL) +set_target_properties(vendored_gpac_ssl PROPERTIES + IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Release/libsslMD.dll" + IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/Debug/libsslMD.dll" +) + +# OBR (static) +add_library(obr_impl INTERFACE) +target_link_libraries(obr_impl INTERFACE + $<$:${CMAKE_SOURCE_DIR}/third_party/obr/lib/Windows/Debug/obr.lib> + $<$:${CMAKE_SOURCE_DIR}/third_party/obr/lib/Windows/Release/obr.lib> + $<$:${CMAKE_SOURCE_DIR}/third_party/obr/lib/Windows/Debug/pffft.lib> + $<$:${CMAKE_SOURCE_DIR}/third_party/obr/lib/Windows/Release/pffft.lib> +) + +# Libear +add_library(libear_impl STATIC IMPORTED GLOBAL) +set_target_properties(libear_impl PROPERTIES + IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/third_party/libear/lib/Windows/Release/libear.lib" + IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/third_party/libear/lib/Windows/Debug/libear.lib" +) + +#==================================================================== +# Vendored Libraries +#==================================================================== +set(ECLIPSA_VENDORED_LIBS + vendored_gpac + vendored_iamf_tools + vendored_gpac_crypto + vendored_gpac_ssl + libzmq + CACHE STRING "" +) \ No newline at end of file diff --git a/cmake/toolchains/macos.cmake b/cmake/toolchains/macos.cmake new file mode 100644 index 00000000..84c4305c --- /dev/null +++ b/cmake/toolchains/macos.cmake @@ -0,0 +1,72 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to add writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#==================================================================== +# Include Guard +#==================================================================== +if (DEFINED _MACOS_TOOLCHAIN_INCLUDED) + return() +endif () +set(_MACOS_TOOLCHAIN_INCLUDED TRUE) + +#==================================================================== +# Platform Identifier +#==================================================================== +set(ECLIPSA_PLATFORM "macos" CACHE STRING "") + +#==================================================================== +# Deployment Target +#==================================================================== +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum macOS version") + +#==================================================================== +# RPATH Configuration +#==================================================================== +get_filename_component(_ECLIPSA_ROOT "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) +set(CMAKE_BUILD_RPATH + "${_ECLIPSA_ROOT}" + "@loader_path/../Resources" + "${_ECLIPSA_ROOT}/third_party/gpac/lib" + "${_ECLIPSA_ROOT}/third_party/iamftools/lib" + "${_ECLIPSA_ROOT}/third_party/obr/lib" + CACHE STRING "" +) +#==================================================================== +# Linker Settings +#==================================================================== +add_link_options("-Wl,-ld_classic") + +#==================================================================== +# AAX SDK Path +#==================================================================== +if (BUILD_AAX) + set(AAX_SDK_VER "2-7-0" CACHE STRING "AAX SDK Version") + set(AAX_SDK_SEARCH_HINT "/opt/aax-sdk-${AAX_SDK_VER}" CACHE INTERNAL "") +endif () + +#==================================================================== +# Build Settings +#==================================================================== +set(IAMF_LIB_NAME "libiamf" CACHE STRING "") +set(ECLIPSA_IAMF_LIB_DIR "${CMAKE_BINARY_DIR}/_deps/libiamf-build" CACHE STRING "") +set(ECLIPSA_STATIC_LIB_SUFFIX ".a" CACHE STRING "") +set(ECLIPSA_PLATFORM_PLUGIN_FORMATS AU CACHE STRING "") +set(ECLIPSA_PLATFORM_LIBS vendored_obr CACHE STRING "") +set(SAF_PERFORMANCE_LIB "SAF_USE_APPLE_ACCELERATE" CACHE STRING "") +set(LIBIAMF_VENDOR_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/macos" CACHE PATH "") + +#==================================================================== +# Bundle Structure +#==================================================================== +set(ECLIPSA_BUNDLE_RESOURCES_SUBDIR "Resources" CACHE STRING "") \ No newline at end of file diff --git a/cmake/toolchains/windows.cmake b/cmake/toolchains/windows.cmake new file mode 100644 index 00000000..1ace91cf --- /dev/null +++ b/cmake/toolchains/windows.cmake @@ -0,0 +1,159 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#==================================================================== +# Include Guard +#==================================================================== +if (DEFINED _WINDOWS_TOOLCHAIN_INCLUDED) + return() +endif () +set(_WINDOWS_TOOLCHAIN_INCLUDED TRUE) + +#==================================================================== +# Platform Identifier +#==================================================================== +set(ECLIPSA_PLATFORM "windows" CACHE STRING "" FORCE) + +#==================================================================== +# AAX SDK Path +#==================================================================== +if (BUILD_AAX) + set(AAX_SDK_VER "2-8-1" CACHE STRING "AAX SDK Version") + set(AAX_SDK_SEARCH_HINT "C:/Code/Repos/aax-sdk-${AAX_SDK_VER}" CACHE INTERNAL "") +endif () + +#==================================================================== +# Compiler Settings +#==================================================================== +add_compile_definitions(_USE_MATH_DEFINES) +set(CMAKE_C_FLAGS_RELEASE "/O1 /MD /DNDEBUG" CACHE STRING "" FORCE) + +#==================================================================== +# Resource Compiler +#==================================================================== +if (NOT CMAKE_RC_COMPILER) + find_program(CMAKE_RC_COMPILER rc.exe + HINTS "C:/Program Files (x86)/Windows Kits/10/bin/*/x64") +endif () + +#==================================================================== +# VCPKG +#==================================================================== +set(X_VCPKG_APPLOCAL_DEPS_INSTALL OFF CACHE BOOL "") + +if (NOT DEFINED VCPKG_ROOT AND DEFINED ENV{VCPKG_ROOT}) + set(VCPKG_ROOT "$ENV{VCPKG_ROOT}" CACHE PATH "Path to vcpkg root") +endif () + +if (DEFINED VCPKG_ROOT) + set(_VCPKG_TOOLCHAIN "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") + + if (NOT EXISTS "${_VCPKG_TOOLCHAIN}") + message(FATAL_ERROR "vcpkg toolchain not found at: ${_VCPKG_TOOLCHAIN}") + endif () + + if (NOT DEFINED VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "vcpkg target triplet") + endif () + + message(STATUS "vcpkg toolchain: ${_VCPKG_TOOLCHAIN}") + message(STATUS "vcpkg triplet: ${VCPKG_TARGET_TRIPLET}") + + include("${_VCPKG_TOOLCHAIN}") +else () + message(WARNING "vcpkg not configured. Set VCPKG_ROOT environment variable or pass -DVCPKG_ROOT=") +endif () + +#==================================================================== +# Dependencies +#==================================================================== +link_libraries(delayimp) + +#==================================================================== +# Build Settings +#==================================================================== +set(IAMF_LIB_NAME "iamf" CACHE STRING "") +set(ECLIPSA_IAMF_LIB_DIR "${CMAKE_BINARY_DIR}/_deps/libiamf-build/$" CACHE STRING "") +set(ECLIPSA_STATIC_LIB_SUFFIX ".lib" CACHE STRING "") +set(ECLIPSA_PLATFORM_LIBS + vendored_gpac_crypto + vendored_gpac_ssl + ZLIB::ZLIB + delayimp + CACHE STRING "" +) + +#==================================================================== +# SAF Performance Library (Intel MKL) +#==================================================================== +if (NOT DEFINED CACHE{SAF_PERFORMANCE_LIB}) + if (NOT DEFINED MKL_ROOT) + set(MKL_ROOT "$ENV{MKLROOT}" CACHE PATH "Path to Intel MKL root directory") + endif () + + if (NOT MKL_ROOT OR NOT EXISTS "${MKL_ROOT}") + message(STATUS "SAF: Intel MKL not found, falling back to OpenBLAS/LAPACKE") + set(SAF_PERFORMANCE_LIB "SAF_USE_OPEN_BLAS_AND_LAPACKE" CACHE STRING "" FORCE) + else () + message(STATUS "SAF: Found Intel MKL at: ${MKL_ROOT}") + set(SAF_PERFORMANCE_LIB "SAF_USE_INTEL_MKL_LP64" CACHE STRING "" FORCE) + set(INTEL_MKL_HEADER_PATH "${MKL_ROOT}/include" CACHE STRING "" FORCE) + set(INTEL_MKL_LIB + "${MKL_ROOT}/lib/mkl_intel_lp64.lib" + "${MKL_ROOT}/lib/mkl_sequential.lib" + "${MKL_ROOT}/lib/mkl_core.lib" + CACHE STRING "" FORCE + ) + + if (NOT EXISTS "${INTEL_MKL_HEADER_PATH}/mkl.h") + message(FATAL_ERROR "SAF: MKL header not found at ${INTEL_MKL_HEADER_PATH}/mkl.h") + endif () + + foreach (lib_file ${INTEL_MKL_LIB}) + if (NOT EXISTS "${lib_file}") + message(FATAL_ERROR "SAF: MKL library not found: ${lib_file}") + endif () + endforeach () + endif () +endif () + +#==================================================================== +# Boost Settings +#==================================================================== +set(Boost_USE_STATIC_RUNTIME OFF CACHE BOOL "") +add_definitions(-DBOOST_ALL_NO_LIB) + +#==================================================================== +# Test DLLs +#==================================================================== +set(ECLIPSA_TEST_DLLS + "${CMAKE_BINARY_DIR}/_deps/zeromq-build/bin/$/libzmq-v143-mt$<$:-gd>-4_3_6.dll" + "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/$/libcryptoMD.dll" + "${CMAKE_SOURCE_DIR}/third_party/gpac/lib/Windows/$/libsslMD.dll" + CACHE STRING "" +) + +#==================================================================== +# Delay-load Libraries +#==================================================================== +set(ECLIPSA_DELAYLOAD_LIBS + vendored_gpac + vendored_iamf_tools + vendored_opensvc + libzmq + vendored_gpac_crypto + vendored_gpac_ssl + CACHE STRING "" +) + diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 15191937..b00df961 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -10,59 +10,51 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# ------------------------------- -# Core module setup -# ------------------------------- - +#==================================================================== +# Core module setup +#==================================================================== juce_add_modules( - components - data_repository - data_structures - logger - processors - substream_rdr) - -# ------------------------------- -# Optional test targets -# ------------------------------- + components + data_repository + data_structures + logger + processors + substream_rdr) -if(CI_TEST OR INTERNAL_TEST) +#==================================================================== +# Optional test targets +#==================================================================== +if (CI_TEST OR INTERNAL_TEST) add_subdirectory(processors/tests) add_subdirectory(data_repository/tests) add_subdirectory(logger/tests) add_subdirectory(data_structures/tests) - add_subdirectory(substream_rdr/tests) -endif() - -# ------------------------------- -# Platform-specific processor defs -# ------------------------------- + add_subdirectory(substream_rdr/tests) +endif () +#==================================================================== # DAW-specific build flags -if(ECLIPSA_LOGIC_PRO_BUILD) +#==================================================================== +if (ECLIPSA_LOGIC_PRO_BUILD) target_compile_definitions(processors INTERFACE ECLIPSA_LOGIC_PRO_BUILD=1) -endif() - -# ------------------------------- -# Icon resources -# ------------------------------- +endif () +#==================================================================== +# Icon resources +#==================================================================== add_subdirectory(components/icons) target_link_libraries(components INTERFACE binary_data) - # Link components against Eigen (for AmbisonicsVisualizer) target_link_libraries(components INTERFACE Eigen) -# ------------------------------- -# Common include directories -# ------------------------------- - +#==================================================================== +# Common include directories +#==================================================================== target_include_directories(data_structures INTERFACE "${BOOST_LIBRARY_INCLUDES}/include" "${zeromq_SOURCE_DIR}/include" "${cppzmq_SOURCE_DIR}" ) - target_include_directories(substream_rdr INTERFACE "${spatialaudio_SOURCE_DIR}/include" "${spatialaudio_SOURCE_DIR}" @@ -75,11 +67,9 @@ target_include_directories(substream_rdr INTERFACE "${CMAKE_SOURCE_DIR}/third_party/libiamf/code/include" ) -# ------------------------------- -# IAMF and Proto Integration -# ------------------------------- - -# Unified cross-platform IAMF linkage (no Bazel paths) +#==================================================================== +# IAMF and Proto Integration +#==================================================================== target_link_libraries(data_structures INTERFACE iamftools substream_rdr) # Make sure our regenerated proto headers come first @@ -87,18 +77,15 @@ target_include_directories(data_structures INTERFACE "${CMAKE_SOURCE_DIR}/third_party/iamftools/iamf/cli/proto" ) -# ------------------------------- -# Substream and Processor Linking -# ------------------------------- - -# Both Windows and macOS now link full audio stack (OBR + SAF) +#==================================================================== +# Substream and Processor Linking +#==================================================================== target_link_libraries(substream_rdr INTERFACE libspatialaudio obr libear data_structures ) - target_link_libraries(processors INTERFACE gpac libear @@ -110,40 +97,36 @@ target_link_libraries(processors INTERFACE saf_example_ambi_dec lufs_meter ) - target_include_directories(substream_rdr INTERFACE ${OBR_INCLUDE_DIRS}) target_include_directories(processors INTERFACE ${OBR_INCLUDE_DIRS}) -# ------------------------------- -# Components and Logging -# ------------------------------- - +#==================================================================== +# Components and Logging +#==================================================================== target_link_libraries(components INTERFACE binary_data libear substream_rdr processors data_structures data_repository) - -if(WIN32) - message(STATUS "Linking logger against Boost via CMake targets") - -# find_package(Boost 1.70.0 REQUIRED COMPONENTS log log_setup thread filesystem) - - target_link_libraries(logger INTERFACE - Boost::log - Boost::log_setup - Boost::filesystem - Boost::thread - Boost::system - juce::juce_core - ) - -# target_include_directories(logger INTERFACE ${Boost_INCLUDE_DIRS}) -else() - target_link_libraries(logger INTERFACE - Boost::log - Boost::log_setup - Boost::thread - Boost::filesystem - juce::juce_core - ) -endif() +target_link_libraries(logger INTERFACE + Boost::log + Boost::log_setup + Boost::filesystem + Boost::thread + juce::juce_core +) get_target_property(SUBSTREAM_INCLUDES substream_rdr INTERFACE_INCLUDE_DIRECTORIES) message(STATUS "substream_rdr include paths: ${SUBSTREAM_INCLUDES}") + +#==================================================================== +# Unified plugin dependency target +#==================================================================== +add_library(eclipsa_common INTERFACE) +target_link_libraries(eclipsa_common INTERFACE + substream_rdr + processors + components + logger + data_repository + data_structures + juce::juce_recommended_config_flags + juce::juce_recommended_lto_flags + juce::juce_recommended_warning_flags +) diff --git a/rendererplugin/CMakeLists.txt b/rendererplugin/CMakeLists.txt index 7a4671a7..67533f0a 100644 --- a/rendererplugin/CMakeLists.txt +++ b/rendererplugin/CMakeLists.txt @@ -12,14 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +#==================================================================== # Set plugin code and name based on build type -if(ECLIPSA_LOGIC_PRO_BUILD) +#==================================================================== +if (ECLIPSA_LOGIC_PRO_BUILD) set(RENDERER_PLUGIN_CODE "Ercl") set(RENDERER_PRODUCT_NAME "Eclipsa Audio Renderer for Logic Pro") -else() +else () set(RENDERER_PLUGIN_CODE "Ecrd") set(RENDERER_PRODUCT_NAME "Eclipsa Audio Renderer") -endif() +endif () juce_add_plugin(RendererPlugin PLUGIN_MANUFACTURER_CODE ${ECLIPSA_MANUFACTURER_CODE} @@ -31,7 +33,7 @@ juce_add_plugin(RendererPlugin IS_MIDI_EFFECT FALSE EDITOR_WANTS_KEYBOARD_FOCUS FALSE COPY_PLUGIN_AFTER_BUILD ${JUCE_COPY_PLUGIN_AFTER_BUILD} - FORMATS ${PLUGIN_FORMATS} + FORMATS ${ECLIPSA_PLUGIN_FORMATS} PRODUCT_NAME ${RENDERER_PRODUCT_NAME} AAX_CATEGORY "AAX_ePlugInCategory_SWGenerators") @@ -51,125 +53,58 @@ target_sources(RendererPlugin src/screens/mix_tabs/PresentationEditorViewPort.cpp src/screens/MixPresentationTagScreen.cpp) +eclipsa_plugin_defaults(RendererPlugin) + target_compile_definitions(RendererPlugin PUBLIC - JUCE_WEB_BROWSER=0 - JUCE_USE_CURL=0 - JUCE_VST3_CAN_REPLACE_VST2=0 - JUCE_SILENCE_XCODE_15_LINKER_WARNING - JUCE_ENABLE_LIVE_CONSTANT_EDITOR=1 JucePlugin_IsSynth=1 JucePlugin_Category="Synth") -# Add DAW-specific build flags when enabled -if(ECLIPSA_LOGIC_PRO_BUILD) +if (ECLIPSA_LOGIC_PRO_BUILD) target_compile_definitions(RendererPlugin PRIVATE ECLIPSA_LOGIC_PRO_BUILD=1) -endif() - -# Platform-specific settings -if(APPLE) - target_link_options(RendererPlugin - PUBLIC - "-Wl" - "-ld_classic") -elseif(WIN32) - # MSVC flags for math constants - target_compile_definitions(RendererPlugin PRIVATE _USE_MATH_DEFINES) -endif() - -target_include_directories(RendererPlugin PUBLIC "${BOOST_LIBRARY_INCLUDES}/include") - +endif () +#==================================================================== +# Link libraries +#==================================================================== target_link_libraries(RendererPlugin PRIVATE + eclipsa_common binary_data - substream_rdr - processors - components - logger - data_repository - data_structures - juce::juce_recommended_config_flags - juce::juce_recommended_lto_flags - juce::juce_recommended_warning_flags libzmq) -if(WIN32) - target_link_libraries(RendererPlugin PRIVATE delayimp) -endif() - -# Platform-specific Boost linking -if(WIN32) - # Windows: Boost headers only (lockfree is header-only) - target_include_directories(RendererPlugin PRIVATE ${Boost_INCLUDE_DIRS}) -else() - # macOS: Modern CMake target - target_link_libraries(RendererPlugin PRIVATE Boost::lockfree) -endif() - -# Windows-specific: Link ZLIB -if(WIN32) - find_package(ZLIB REQUIRED) - if(ZLIB_FOUND) - message(STATUS "Linking RendererPlugin against ZLIB: ${ZLIB_LIBRARIES}") - target_link_libraries(RendererPlugin PRIVATE ZLIB::ZLIB) - if(TARGET RendererPlugin_VST3) - target_link_libraries(RendererPlugin_VST3 PRIVATE ZLIB::ZLIB) - endif() - else() - message(FATAL_ERROR "ZLIB not found for RendererPlugin") - endif() -endif() - -if(CI_TEST OR INTERNAL_TEST) +#==================================================================== +#Testing +#==================================================================== +if (CI_TEST OR INTERNAL_TEST) target_link_libraries(RendererPlugin PRIVATE juce::juce_cryptography) add_subdirectory(test) -endif() +endif () +#==================================================================== # Copy resources for each plugin format -if(BUILD_AAX AND TARGET RendererPlugin_AAX) - message(STATUS "AAX build detected. Setting up renderer plugin path and copying resources.") - set(RENDERER_AAX_PATH "${CMAKE_BINARY_DIR}/rendererplugin/RendererPlugin_artefacts/$/AAX/Eclipsa Audio Renderer.aaxplugin") - copy_resources(RendererPlugin_AAX "${RENDERER_AAX_PATH}") - - # For builds on Windows, set up delay loading for DLLs - if(WIN32) - foreach(dll IN LISTS DELAYLOAD_DLLS) - target_link_options(RendererPlugin_AAX PRIVATE /DELAYLOAD:${dll}) - endforeach() - endif() -endif() - -if(BUILD_VST3 AND TARGET RendererPlugin_VST3) - message(STATUS "VST3 build detected. Setting up renderer plugin path and copying resources.") - set(RENDERER_VST3_PATH "${CMAKE_BINARY_DIR}/rendererplugin/RendererPlugin_artefacts/$/VST3/Eclipsa Audio Renderer.vst3") - copy_resources(RendererPlugin_VST3 "${RENDERER_VST3_PATH}") - - # For builds on Windows, set up delay loading for DLLs - if(WIN32) - foreach(dll IN LISTS DELAYLOAD_DLLS) - target_link_options(RendererPlugin_VST3 PRIVATE /DELAYLOAD:${dll}) - endforeach() - endif() -endif() - -if(CMAKE_BUILD_TYPE STREQUAL "Release" AND APPLE) - message(STATUS "MacOS release build detected. Copying Renderer Plugin Resources for AU Plugins.") - if(ECLIPSA_LOGIC_PRO_BUILD) - set(RDR_PLUGIN_PATH "${CMAKE_BINARY_DIR}/rendererplugin/RendererPlugin_artefacts/Release/AU/Eclipsa Audio Renderer for Logic Pro.component") - else() - set(RDR_PLUGIN_PATH "${CMAKE_BINARY_DIR}/rendererplugin/RendererPlugin_artefacts/Release/AU/Eclipsa Audio Renderer.component") - endif() - copy_resources(RendererPlugin ${RDR_PLUGIN_PATH}) -endif() - -if(TARGET RendererPlugin_Standalone) - message(STATUS "Standalone build detected. Setting up renderer plugin path and copying resources.") - set(RENDERER_STANDALONE_PATH "${CMAKE_BINARY_DIR}/rendererplugin/RendererPlugin_artefacts/$/Standalone") - copy_resources(RendererPlugin_Standalone "${RENDERER_STANDALONE_PATH}") -endif() - -if(NOT BUILD_AAX AND NOT BUILD_VST3 AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") - message(STATUS "No supported plugin formats detected. Skipping resource setup and resource copy for Renderer Plugin.") -endif() \ No newline at end of file +#==================================================================== + +set(_ARTEFACTS_BASE "${CMAKE_BINARY_DIR}/rendererplugin/RendererPlugin_artefacts") +set(_PLUGIN_NAME "Eclipsa Audio Renderer") + +if (TARGET RendererPlugin_AAX) + copy_resources(RendererPlugin_AAX "${_ARTEFACTS_BASE}/$/AAX/${_PLUGIN_NAME}.aaxplugin") +endif () + +if (TARGET RendererPlugin_VST3) + copy_resources(RendererPlugin_VST3 "${_ARTEFACTS_BASE}/$/VST3/${_PLUGIN_NAME}.vst3") +endif () + +if (TARGET RendererPlugin_Standalone) + copy_resources(RendererPlugin_Standalone "${_ARTEFACTS_BASE}/$/Standalone") +endif () + +if (TARGET RendererPlugin_AU) + if (ECLIPSA_LOGIC_PRO_BUILD) + copy_resources(RendererPlugin_AU "${_ARTEFACTS_BASE}/$/AU/${_PLUGIN_NAME} for Logic Pro.component") + else () + copy_resources(RendererPlugin_AU "${_ARTEFACTS_BASE}/$/AU/${_PLUGIN_NAME}.component") + endif () +endif () diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 6c8e7802..70b8fdf3 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -11,19 +11,21 @@ include(FetchContent) -# After FetchContent_MakeAvailable(protobuf) -set(Protobuf_INCLUDE_DIRS "${protobuf_SOURCE_DIR}/src" CACHE PATH "" FORCE) -set(Protobuf_LIBRARIES "${protobuf_BINARY_DIR}/libprotobuf.lib" CACHE STRING "" FORCE) -set(Protobuf_PROTOC_EXECUTABLE "${protobuf_BINARY_DIR}/protoc" CACHE FILEPATH "" FORCE) -set(Protobuf_DIR "${protobuf_BINARY_DIR}/cmake" CACHE PATH "" FORCE) - # Force static linking for all third-party dependencies set(BUILD_SHARED_LIBS OFF) + +#==================================================================== +# Prebuilt Libraries +#==================================================================== +include("${CMAKE_SOURCE_DIR}/cmake/prebuiltLibs/${ECLIPSA_PLATFORM}.cmake") + +#==================================================================== +# Add Dependencies +#==================================================================== #JUCE for plugin development. add_subdirectory(JUCE) #IAMF for IAMF file export. add_subdirectory(iamftools) - # lib open binaural renderer for panning via ambisonics and binaural rendering. add_subdirectory(obr) # Libear for loudness rendering. @@ -34,124 +36,58 @@ add_subdirectory(libear) include("${CMAKE_SOURCE_DIR}/cmake/zeromq.cmake") #LibIAMF for audio file import. add_subdirectory(libiamf) - -#Ensure IAMF library is found and named correctly -if (WIN32) - # MSVC builds iamf.lib (no 'lib' prefix) - set(IAMF_LIB_NAME iamf) - set(IAMF_LIB_DIR "${CMAKE_BINARY_DIR}/_deps/libiamf-build/$") -else() - # UNIX builds libiamf.a - set(IAMF_LIB_NAME libiamf) - set(IAMF_LIB_DIR "${CMAKE_BINARY_DIR}/_deps/libiamf-build") -endif() - -# Make sure all subprojects can find it -link_directories(${IAMF_LIB_DIR}) - -# Export variables globally so modules can use ${IAMF_LIB_NAME} -set(IAMF_LIB_NAME ${IAMF_LIB_NAME} CACHE STRING "IAMF library name") -set(IAMF_LIB_DIR ${IAMF_LIB_DIR} CACHE STRING "IAMF library directory") - -#Override some of the SAF variables -#Unit tests for SAF have been tested and they pass, confirming the SAF library is working as expected. -# Manually set the SAF_PERFORMANCE_LIB variables for each platform -set(SAF_BUILD_TESTS 0 CACHE BOOL "" FORCE) -set(SAF_BUILD_EXAMPLES 1 CACHE BOOL "" FORCE) -set(saf_example_list ambi_dec CACHE STRING "" FORCE) - -# Default performance library (fallback) -set(SAF_PERFORMANCE_LIB "SAF_USE_OPEN_BLAS_AND_LAPACKE") - -if(APPLE) - message(STATUS "SAF: Using Apple Accelerate") - set(SAF_PERFORMANCE_LIB "SAF_USE_APPLE_ACCELERATE") - -elseif(WIN32) - # Use system Intel MKL directly - message(STATUS "SAF: Attempting to use system Intel MKL") - - # Allow user to specify MKL root, or use environment variable - set(MKL_ROOT "$ENV{MKLROOT}" CACHE PATH "Path to Intel MKL root directory") - - if(NOT MKL_ROOT OR NOT EXISTS "${MKL_ROOT}") - message(WARNING "SAF: Intel MKL not found. MKLROOT is not set or invalid: '${MKL_ROOT}'") - message(WARNING " Set MKL_ROOT variable or source the Intel oneAPI setvars script") - message(WARNING " Falling back to OpenBLAS/LAPACKE") - set(SAF_PERFORMANCE_LIB "SAF_USE_OPENBLAS_AND_LAPACKE") - else() - message(STATUS "SAF: Found Intel MKL at: ${MKL_ROOT}") - set(SAF_PERFORMANCE_LIB "SAF_USE_INTEL_MKL_LP64") - - # Construct paths relative to MKL_ROOT - set(INTEL_MKL_HEADER_PATH "${MKL_ROOT}/include" CACHE STRING "" FORCE) - - set(INTEL_MKL_LIB - "${MKL_ROOT}/lib/mkl_intel_lp64.lib" - "${MKL_ROOT}/lib/mkl_sequential.lib" - "${MKL_ROOT}/lib/mkl_core.lib" - CACHE STRING "" FORCE) - - # Validate that critical files exist - if(NOT EXISTS "${INTEL_MKL_HEADER_PATH}/mkl.h") - message(FATAL_ERROR "SAF: MKL header not found at ${INTEL_MKL_HEADER_PATH}/mkl.h") - endif() - - foreach(lib_file ${INTEL_MKL_LIB}) - if(NOT EXISTS "${lib_file}") - message(FATAL_ERROR "SAF: MKL library not found: ${lib_file}") - endif() - endforeach() - endif() -else() - message(SEND_ERROR "SAF: Using OpenBLAS/LAPACKE (default)") -endif() - -# Reduce optimization level for SAF to avoid compiler crash -if(WIN32) - set(CMAKE_C_FLAGS_RELEASE "/O1 /MD /DNDEBUG" CACHE STRING "" FORCE) -endif() - -# Build SAF from source on all platforms -message(STATUS "SAF: Building from source with ${SAF_PERFORMANCE_LIB}") -add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/Spatial_Audio_Framework) - # gpac for AV muxing add_subdirectory(gpac) # lib spatialaudio for panning include("${CMAKE_SOURCE_DIR}/cmake/libspatialaudio.cmake") # LUFSMeter add_subdirectory(LUFSMeter) +#==================================================================== +# IAMF library directory +#==================================================================== +set(IAMF_LIB_DIR ${ECLIPSA_IAMF_LIB_DIR}) + +# Make sure all subprojects can find it +link_directories(${IAMF_LIB_DIR}) +set(IAMF_LIB_DIR ${IAMF_LIB_DIR} CACHE STRING "IAMF library directory") # IAMF decoder set(IAMF_DEC_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/third_party/libiamf/code/include") -if(EXISTS ${IAMF_DEC_INCLUDE_DIR}) +if (EXISTS ${IAMF_DEC_INCLUDE_DIR}) include_directories(${IAMF_DEC_INCLUDE_DIR}) -else() +else () message(FATAL_ERROR "IAMF decoder include directory not found: ${IAMF_DEC_INCLUDE_DIR}") -endif() +endif () + +#==================================================================== +#Spatial Audio Framework +#==================================================================== +set(SAF_BUILD_TESTS 0 CACHE BOOL "" FORCE) +set(SAF_BUILD_EXAMPLES 1 CACHE BOOL "" FORCE) +set(saf_example_list ambi_dec CACHE STRING "" FORCE) -# SAF includes (optional) +# Manually set the SAF_PERFORMANCE_LIB variables for each platform +message(STATUS "SAF: Building from source with ${SAF_PERFORMANCE_LIB}") +add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/Spatial_Audio_Framework) + +# SAF includes set(SAF_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/third_party/Spatial_Audio_Framework/examples/include") -if(EXISTS ${SAF_INCLUDE_DIR}) +if (EXISTS ${SAF_INCLUDE_DIR}) include_directories(${SAF_INCLUDE_DIR}) -else() +else () message(WARNING "SAF include directory not found: ${SAF_INCLUDE_DIR}") -endif() - -# Windows flags -if(WIN32) - add_compile_definitions(_USE_MATH_DEFINES) -endif() +endif () -#Force all projects to use locally fetched Protobuf +#==================================================================== +# Protobuf +#==================================================================== if (DEFINED protobuf_SOURCE_DIR AND DEFINED protobuf_BINARY_DIR) message(STATUS "Overriding Protobuf include/lib paths with fetched version") set(Protobuf_INCLUDE_DIRS "${protobuf_SOURCE_DIR}/src" CACHE PATH "" FORCE) - set(Protobuf_LIBRARIES "${protobuf_BINARY_DIR}/libprotobuf.lib" CACHE STRING "" FORCE) + set(Protobuf_LIBRARIES "${protobuf_BINARY_DIR}/libprotobuf${ECLIPSA_STATIC_LIB_SUFFIX}" CACHE STRING "" FORCE) set(Protobuf_PROTOC_EXECUTABLE "${protobuf_BINARY_DIR}/protoc" CACHE FILEPATH "" FORCE) set(Protobuf_DIR "${protobuf_BINARY_DIR}/cmake" CACHE PATH "" FORCE) -else() - message(WARNING "protobuf_SOURCE_DIR not defined yet ΓÇö ensure FetchContent_MakeAvailable(protobuf) ran") -endif() +else () + message(WARNING "protobuf_SOURCE_DIR not defined yet — ensure FetchContent_MakeAvailable(protobuf) ran") +endif () diff --git a/third_party/gpac/CMakeLists.txt b/third_party/gpac/CMakeLists.txt index 963a7142..319f91b4 100644 --- a/third_party/gpac/CMakeLists.txt +++ b/third_party/gpac/CMakeLists.txt @@ -1,63 +1,3 @@ add_library(gpac INTERFACE) -target_include_directories(gpac INTERFACE "include/") - -if(WIN32) - # Platform-specific setup for Windows - set(GPAC_PLATFORM "Windows") - - # Set paths for each configuration - set(GPAC_DEBUG_DLL "${CMAKE_CURRENT_LIST_DIR}/lib/${GPAC_PLATFORM}/Debug/libgpac.dll") - set(GPAC_DEBUG_LIB "${CMAKE_CURRENT_LIST_DIR}/lib/${GPAC_PLATFORM}/Debug/libgpac.lib") - set(GPAC_RELEASE_DLL "${CMAKE_CURRENT_LIST_DIR}/lib/${GPAC_PLATFORM}/Release/libgpac.dll") - set(GPAC_RELEASE_LIB "${CMAKE_CURRENT_LIST_DIR}/lib/${GPAC_PLATFORM}/Release/libgpac.lib") - - # Validate that the libraries exist - if(NOT EXISTS "${GPAC_DEBUG_DLL}") - message(FATAL_ERROR "GPAC Debug DLL not found at: ${GPAC_DEBUG_DLL}") - endif() - if(NOT EXISTS "${GPAC_DEBUG_LIB}") - message(FATAL_ERROR "GPAC Debug LIB not found at: ${GPAC_DEBUG_LIB}") - endif() - if(NOT EXISTS "${GPAC_RELEASE_DLL}") - message(FATAL_ERROR "GPAC Release DLL not found at: ${GPAC_RELEASE_DLL}") - endif() - if(NOT EXISTS "${GPAC_RELEASE_LIB}") - message(FATAL_ERROR "GPAC Release LIB not found at: ${GPAC_RELEASE_LIB}") - endif() - - message(STATUS "GPAC Debug DLL: ${GPAC_DEBUG_DLL}") - message(STATUS "GPAC Release DLL: ${GPAC_RELEASE_DLL}") - - # Windows: dynamic library (.dll + .lib) - add_library(gpac_archive SHARED IMPORTED GLOBAL) - - set_target_properties(gpac_archive PROPERTIES - IMPORTED_LOCATION "${GPAC_RELEASE_DLL}" - IMPORTED_LOCATION_DEBUG "${GPAC_DEBUG_DLL}" - IMPORTED_LOCATION_RELEASE "${GPAC_RELEASE_DLL}" - IMPORTED_IMPLIB "${GPAC_RELEASE_LIB}" - IMPORTED_IMPLIB_DEBUG "${GPAC_DEBUG_LIB}" - IMPORTED_IMPLIB_RELEASE "${GPAC_RELEASE_LIB}" - LINKER_LANGUAGE CXX - ) - - # Copy DLL to build directory (configuration-aware) - add_custom_target(copy_gpac_dll ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "$,${GPAC_DEBUG_DLL},${GPAC_RELEASE_DLL}>" - "${CMAKE_BINARY_DIR}/$/libgpac.dll" - COMMENT "Copying GPAC runtime DLL to build directory" - ) - - target_link_libraries(gpac INTERFACE gpac_archive ws2_32 shlwapi winmm) - -else() - add_library(gpac_shared SHARED IMPORTED) - set_target_properties(gpac_shared PROPERTIES - IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/lib/libgpac.dylib" - IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libgpac.dylib" - IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libgpac.dylib" - IMPORTED_LOCATION_RELWITHDEBINFO "${CMAKE_CURRENT_LIST_DIR}/lib/libgpac.dylib" - LINKER_LANGUAGE CXX) - target_link_libraries(gpac INTERFACE gpac_shared) -endif() +target_include_directories(gpac INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include/") +target_link_libraries(gpac INTERFACE gpac_impl) \ No newline at end of file diff --git a/third_party/iamftools/CMakeLists.txt b/third_party/iamftools/CMakeLists.txt index 51923b65..1f3cadd1 100644 --- a/third_party/iamftools/CMakeLists.txt +++ b/third_party/iamftools/CMakeLists.txt @@ -1,8 +1,14 @@ # Copyright 2025 Google LLC +# # Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy at: +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# # http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. add_subdirectory(iamf/cli/proto) @@ -15,7 +21,6 @@ set(HEADER_FILE "${CMAKE_CURRENT_LIST_DIR}/iamf/include/iamf_tools/commit_hash.h set(TEMPLATE_FILE "${CMAKE_CURRENT_LIST_DIR}/iamf/include/iamf_tools/commit_hash.h.in") configure_file(${TEMPLATE_FILE} ${HEADER_FILE} @ONLY) -# -------------------- IAMF TOOLS -------------------- add_library(iamftools INTERFACE) target_compile_options(iamftools INTERFACE "-w") target_include_directories(iamftools INTERFACE @@ -23,64 +28,4 @@ target_include_directories(iamftools INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/iamf/include/iamf_tools" ) -# Cross-platform dynamic library setup -add_library(iamftools_dylib SHARED IMPORTED) - -if(WIN32) - # Platform-specific setup for Windows - set(IAMF_PLATFORM "Windows") - - # Set paths for each configuration - set(IAMF_TOOLS_DEBUG_DLL "${CMAKE_CURRENT_LIST_DIR}/lib/${IAMF_PLATFORM}/Debug/iamf_tools.dll") - set(IAMF_TOOLS_DEBUG_LIB "${CMAKE_CURRENT_LIST_DIR}/lib/${IAMF_PLATFORM}/Debug/iamf_tools.if.lib") - set(IAMF_TOOLS_RELEASE_DLL "${CMAKE_CURRENT_LIST_DIR}/lib/${IAMF_PLATFORM}/Release/iamf_tools.dll") - set(IAMF_TOOLS_RELEASE_LIB "${CMAKE_CURRENT_LIST_DIR}/lib/${IAMF_PLATFORM}/Release/iamf_tools.if.lib") - - # Validate that the libraries exist - if(NOT EXISTS "${IAMF_TOOLS_DEBUG_DLL}") - message(FATAL_ERROR "IAMF Tools Debug DLL not found at: ${IAMF_TOOLS_DEBUG_DLL}") - endif() - if(NOT EXISTS "${IAMF_TOOLS_DEBUG_LIB}") - message(FATAL_ERROR "IAMF Tools Debug LIB not found at: ${IAMF_TOOLS_DEBUG_LIB}") - endif() - if(NOT EXISTS "${IAMF_TOOLS_RELEASE_DLL}") - message(FATAL_ERROR "IAMF Tools Release DLL not found at: ${IAMF_TOOLS_RELEASE_DLL}") - endif() - if(NOT EXISTS "${IAMF_TOOLS_RELEASE_LIB}") - message(FATAL_ERROR "IAMF Tools Release LIB not found at: ${IAMF_TOOLS_RELEASE_LIB}") - endif() - - message(STATUS "IAMF Tools Debug DLL: ${IAMF_TOOLS_DEBUG_DLL}") - message(STATUS "IAMF Tools Release DLL: ${IAMF_TOOLS_RELEASE_DLL}") - - set_target_properties(iamftools_dylib PROPERTIES - IMPORTED_LOCATION "${IAMF_TOOLS_RELEASE_DLL}" - IMPORTED_LOCATION_DEBUG "${IAMF_TOOLS_DEBUG_DLL}" - IMPORTED_LOCATION_RELEASE "${IAMF_TOOLS_RELEASE_DLL}" - IMPORTED_IMPLIB "${IAMF_TOOLS_RELEASE_LIB}" - IMPORTED_IMPLIB_DEBUG "${IAMF_TOOLS_DEBUG_LIB}" - IMPORTED_IMPLIB_RELEASE "${IAMF_TOOLS_RELEASE_LIB}" - LINKER_LANGUAGE CXX - ) - - # Copy DLL to build directory (configuration-aware using generator expressions) - add_custom_target(copy_iamftools_dll ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "$,${IAMF_TOOLS_DEBUG_DLL},${IAMF_TOOLS_RELEASE_DLL}>" - "${CMAKE_BINARY_DIR}/$/iamf_tools.dll" - COMMENT "Copying IAMF Tools DLL to build directory" - ) - -else() - # macOS: dylib - set_target_properties(iamftools_dylib PROPERTIES - IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/lib/libiamf_tools.dylib" - IMPORTED_SONAME "libiamf_tools.dylib" - LINKER_LANGUAGE CXX - ) -endif() - -target_link_libraries(iamftools INTERFACE - iamftools_dylib - proto-objects -) +target_link_libraries(iamftools INTERFACE iamftools_impl proto-objects) \ No newline at end of file diff --git a/third_party/iamftools/scripts/update.sh b/third_party/iamftools/scripts/update.sh index 715c8b47..94348366 100755 --- a/third_party/iamftools/scripts/update.sh +++ b/third_party/iamftools/scripts/update.sh @@ -68,7 +68,7 @@ cp bazel-bin/iamf/include/iamf_tools/libiamf_tools.dylib "$DEST_LIB_DIR/" echo "Copying and updating proto files..." # Create proto directory if it doesn't exist mkdir -p "$DEST_PROTO_DIR" -# Save CMakeLists.txt if it exists +# Save macos.cmake if it exists if [ -f "$DEST_PROTO_DIR/CMakeLists.txt" ]; then CMAKELISTS_BACKUP=$(mktemp) cp "$DEST_PROTO_DIR/CMakeLists.txt" "$CMAKELISTS_BACKUP" @@ -83,7 +83,7 @@ for file in *.proto; do done # Copy the modified proto files to the final destination cp *.proto "$DEST_PROTO_DIR/" -# Restore CMakeLists.txt if it was backed up +# Restore macos.cmake if it was backed up if [ -f "$CMAKELISTS_BACKUP" ]; then cp "$CMAKELISTS_BACKUP" "$DEST_PROTO_DIR/CMakeLists.txt" rm "$CMAKELISTS_BACKUP" diff --git a/third_party/libear/CMakeLists.txt b/third_party/libear/CMakeLists.txt index 1a0e2081..bddb81af 100644 --- a/third_party/libear/CMakeLists.txt +++ b/third_party/libear/CMakeLists.txt @@ -1,39 +1,11 @@ add_library(libear INTERFACE) target_include_directories(libear INTERFACE "include/") -target_compile_options(libear INTERFACE "-w") # Silence is golden - -#Cross-platform setup -if(WIN32) - set(LIBEAR_DEBUG_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/Windows/Debug/libear.lib") - set(LIBEAR_RELEASE_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/Windows/Release/libear.lib") -else() - set(LIBEAR_DEBUG_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/libear.a") - set(LIBEAR_RELEASE_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/libear.a") -endif() - -# Check that the file actually exists -if(NOT EXISTS "${LIBEAR_DEBUG_PATH}") - message(FATAL_ERROR "libear Debug library not found at: ${LIBEAR_DEBUG_PATH}") -endif() - -if(NOT EXISTS "${LIBEAR_RELEASE_PATH}") - message(FATAL_ERROR "libear Release library not found at: ${LIBEAR_RELEASE_PATH}") -endif() - -# Import prebuilt static library -add_library(libear_archive STATIC IMPORTED) -set_target_properties(libear_archive PROPERTIES - IMPORTED_LOCATION "${LIBEAR_RELEASE_PATH}" - IMPORTED_LOCATION_DEBUG "${LIBEAR_DEBUG_PATH}" - IMPORTED_LOCATION_RELEASE "${LIBEAR_RELEASE_PATH}" - IMPORTED_LOCATION_RELWITHDEBINFO "${LIBEAR_RELEASE_PATH}" - IMPORTED_LOCATION_MINSIZEREL "${LIBEAR_RELEASE_PATH}" -) - -target_link_libraries(libear - INTERFACE - libear_archive - Boost::optional - Boost::variant - Boost::math - Boost::algorithm) \ No newline at end of file +target_compile_options(libear INTERFACE "-w") + +target_link_libraries(libear INTERFACE + libear_impl + Boost::optional + Boost::variant + Boost::math + Boost::algorithm +) \ No newline at end of file diff --git a/third_party/libiamf/CMakeLists.txt b/third_party/libiamf/CMakeLists.txt index ae2df931..48e93a6a 100644 --- a/third_party/libiamf/CMakeLists.txt +++ b/third_party/libiamf/CMakeLists.txt @@ -1,11 +1,11 @@ -# Copyright 2024 Google LLC -# +# Copyright 2025 Google LLC +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,108 +25,76 @@ set(CODEC_CAP ON CACHE BOOL "Codec capability check" FORCE) set(MULTICHANNEL_BINAURALIZER OFF CACHE BOOL "Enable multichannel binaural rendering" FORCE) set(HOA_BINAURALIZER OFF CACHE BOOL "Enable HOA binaural rendering" FORCE) -# Fetch but don't build yet - we need to patch first FetchContent_GetProperties(libiamf) -if(NOT libiamf_POPULATED) - FetchContent_Populate(libiamf) - - # --- PATCH: Fix libiamf's CMakeLists.txt to remove GCC-only flags and m library on Windows - if(WIN32) - file(READ "${libiamf_SOURCE_DIR}/code/CMakeLists.txt" LIBIAMF_CMAKE_CONTENT) - string(REPLACE "-O3" "" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") - string(REPLACE "-Werror=unused-variable" "" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") - string(REGEX REPLACE "target_link_libraries\\([^)]*[ \t\n]+m[ \t\n)]+[^)]*\\)" "" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") - string(REPLACE " m)" ")" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") - string(REPLACE " m " " " LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") - string(REPLACE "option(BUILD_SHARED_LIBS \"Build shared library\" ON)" "option(BUILD_SHARED_LIBS \"Build shared library\" OFF)" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") - file(WRITE "${libiamf_SOURCE_DIR}/code/CMakeLists.txt" "${LIBIAMF_CMAKE_CONTENT}") - message(STATUS "Patched libiamf CMakeLists.txt to remove GCC-only flags and m library") - endif() - - # --- macOS vendor handling - if(APPLE) - set(VENDOR_LIB_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/macos") - file(REMOVE - "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/libopus.a" - "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/libfdk-aac.a" - "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/libFLAC.a" - ) - file(COPY - "${VENDOR_LIB_PATH}/libopus.a" - "${VENDOR_LIB_PATH}/libFLAC.a" - "${VENDOR_LIB_PATH}/libfdk-aac.a" - "${VENDOR_LIB_PATH}/libogg.a" - DESTINATION "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/" - ) - link_directories("${VENDOR_LIB_PATH}") - endif() - - # --- Windows vendor handling - if(WIN32) - message(STATUS "Using Windows codec libraries for IAMF") - - set(VENDOR_LIB_PATH_DEBUG "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/Windows/Debug") - set(VENDOR_LIB_PATH_RELEASE "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/Windows/Release") - - # Copy Debug libraries if they exist - if(EXISTS "${VENDOR_LIB_PATH_DEBUG}/fdk-aac.lib") - file(COPY - "${VENDOR_LIB_PATH_DEBUG}/fdk-aac.lib" - "${VENDOR_LIB_PATH_DEBUG}/FLAC.lib" - "${VENDOR_LIB_PATH_DEBUG}/opus.lib" - "${VENDOR_LIB_PATH_DEBUG}/ogg.lib" - DESTINATION "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/" - ) - endif() - - # Copy Release libraries if they exist - if(EXISTS "${VENDOR_LIB_PATH_RELEASE}/fdk-aac.lib") - file(COPY - "${VENDOR_LIB_PATH_RELEASE}/fdk-aac.lib" - "${VENDOR_LIB_PATH_RELEASE}/FLAC.lib" - "${VENDOR_LIB_PATH_RELEASE}/opus.lib" - "${VENDOR_LIB_PATH_RELEASE}/ogg.lib" - DESTINATION "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/" - ) - endif() - endif() - - - # --- Protobuf / Abseil injection (for Windows builds) - if(WIN32) - message(STATUS "Using Protobuf and Abseil targets from FetchContent") - endif() - - # --- NOW build libiamf (after patching) - add_subdirectory(${libiamf_SOURCE_DIR}/code ${libiamf_BINARY_DIR}) - - # --- PATCH: Remove Linux-only 'm' linkage (no libm on Windows) - if (WIN32 AND TARGET iamf) - message(STATUS "Patching libiamf: removing Linux-only 'm' linkage") - get_target_property(_iamf_libs iamf INTERFACE_LINK_LIBRARIES) - if (_iamf_libs) - list(REMOVE_ITEM _iamf_libs m) - set_target_properties(iamf PROPERTIES INTERFACE_LINK_LIBRARIES "${_iamf_libs}") - endif() - endif() - - # --- Windows codec linking (after target exists) - if(WIN32 AND TARGET iamf) - target_link_libraries(iamf - "${VENDOR_LIB_PATH}/fdk-aac.lib" - "${VENDOR_LIB_PATH}/FLAC.lib" - "${VENDOR_LIB_PATH}/opus.lib" - "${VENDOR_LIB_PATH}/ogg.lib" - ) - endif() -endif() - -# --- Extra linking for ogg -if(TARGET iamf) - target_link_libraries(iamf ogg) -endif() - -# --- Include dirs (for iamfdec_utils) +if (NOT libiamf_POPULATED) + FetchContent_Populate(libiamf) + #==================================================================== + # Platform-specific configuration + #==================================================================== + if (APPLE) + set(LIBIAMF_CODEC_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/macos") + file(REMOVE + "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/libopus.a" + "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/libfdk-aac.a" + "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/libFLAC.a" + ) + file(COPY + "${LIBIAMF_CODEC_PATH}/libopus.a" + "${LIBIAMF_CODEC_PATH}/libFLAC.a" + "${LIBIAMF_CODEC_PATH}/libfdk-aac.a" + "${LIBIAMF_CODEC_PATH}/libogg.a" + DESTINATION "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/" + ) + link_directories("${LIBIAMF_CODEC_PATH}") + + elseif (WIN32) + # Patch CMakeLists.txt to remove GCC-only flags + file(READ "${libiamf_SOURCE_DIR}/code/CMakeLists.txt" LIBIAMF_CMAKE_CONTENT) + string(REPLACE "-O3" "" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") + string(REPLACE "-Werror=unused-variable" "" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") + string(REGEX REPLACE "target_link_libraries\\([^)]*[ \t\n]+m[ \t\n)]+[^)]*\\)" "" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") + string(REPLACE " m)" ")" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") + string(REPLACE " m " " " LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") + string(REPLACE "option(BUILD_SHARED_LIBS \"Build shared library\" ON)" "option(BUILD_SHARED_LIBS \"Build shared library\" OFF)" LIBIAMF_CMAKE_CONTENT "${LIBIAMF_CMAKE_CONTENT}") + file(WRITE "${libiamf_SOURCE_DIR}/code/CMakeLists.txt" "${LIBIAMF_CMAKE_CONTENT}") + message(STATUS "Patched libiamf CMakeLists.txt for Windows") + + set(LIBIAMF_CODEC_PATH "${CMAKE_SOURCE_DIR}/third_party/libiamf/lib/Windows/Release") + file(COPY + "${LIBIAMF_CODEC_PATH}/fdk-aac.lib" + "${LIBIAMF_CODEC_PATH}/FLAC.lib" + "${LIBIAMF_CODEC_PATH}/opus.lib" + "${LIBIAMF_CODEC_PATH}/ogg.lib" + DESTINATION "${libiamf_SOURCE_DIR}/code/dep_codecs/lib/" + ) + endif () + + # Build libiamf + add_subdirectory(${libiamf_SOURCE_DIR}/code ${libiamf_BINARY_DIR}) + + # Windows: remove 'm' linkage and add codec libs + if (WIN32 AND TARGET iamf) + get_target_property(_iamf_libs iamf INTERFACE_LINK_LIBRARIES) + if (_iamf_libs) + list(REMOVE_ITEM _iamf_libs m) + set_target_properties(iamf PROPERTIES INTERFACE_LINK_LIBRARIES "${_iamf_libs}") + endif () + target_link_libraries(iamf + "${LIBIAMF_CODEC_PATH}/fdk-aac.lib" + "${LIBIAMF_CODEC_PATH}/FLAC.lib" + "${LIBIAMF_CODEC_PATH}/opus.lib" + "${LIBIAMF_CODEC_PATH}/ogg.lib" + ) + endif () +endif () + +# Extra linking for ogg (Mac/Linux only) +# Windows is already handled explicitly above with full paths +if (TARGET iamf AND NOT WIN32) + target_link_libraries(iamf ogg) +endif () + +# Include dirs set(LIBIAMF_INCLUDE_DIRS ${libiamf_SOURCE_DIR}/code/include ${libiamf_SOURCE_DIR}/code/src/common @@ -143,30 +111,24 @@ set(LIBIAMF_INCLUDE_DIRS CACHE INTERNAL "LIBIAMF include directories" ) -# --- Build iamfdec_utils (no main) -if(EXISTS "${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src") - set(IAMFDEC_UTIL_SOURCES - ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/dmemory.c - ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/iamf_header.c - ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/mp4demux.c - ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/mp4iamfpar.c - ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/vlogging_iamfmp4_sr.c - ) +# Build iamfdec_utils +if (EXISTS "${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src") + set(IAMFDEC_UTIL_SOURCES + ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/dmemory.c + ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/iamf_header.c + ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/mp4demux.c + ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/mp4iamfpar.c + ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/src/vlogging_iamfmp4_sr.c + ) - if(IAMFDEC_UTIL_SOURCES) add_library(iamfdec_utils STATIC ${IAMFDEC_UTIL_SOURCES}) target_include_directories(iamfdec_utils PUBLIC ${libiamf_SOURCE_DIR}/code/test/tools/iamfdec/include $ ) target_include_directories(iamfdec_utils PRIVATE ${LIBIAMF_INCLUDE_DIRS}) - if(TARGET iamf) - target_link_libraries(iamfdec_utils PUBLIC iamf) - else() - message(WARNING "Core 'iamf' target not found for linking iamfdec_utils.") - endif() + target_link_libraries(iamfdec_utils PUBLIC iamf) message(STATUS "Created iamfdec_utils library (without main).") - endif() -endif() +endif () message(STATUS "LIBIAMF source directory: ${libiamf_SOURCE_DIR}") \ No newline at end of file diff --git a/third_party/obr/CMakeLists.txt b/third_party/obr/CMakeLists.txt index 08dc5c0e..7053d719 100644 --- a/third_party/obr/CMakeLists.txt +++ b/third_party/obr/CMakeLists.txt @@ -19,34 +19,10 @@ target_include_directories(obr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/obr/renderer ${CMAKE_CURRENT_SOURCE_DIR}/obr/ambisonic_encoder ${CMAKE_BINARY_DIR}/_deps/pffft-src - ) -# Platform-specific static linking -if (WIN32) - target_link_libraries(obr INTERFACE - $<$:${CMAKE_CURRENT_SOURCE_DIR}/lib/Windows/Debug/obr.lib> - $<$:${CMAKE_CURRENT_SOURCE_DIR}/lib/Windows/Release/obr.lib> - $<$:${CMAKE_CURRENT_SOURCE_DIR}/lib/Windows/Debug/pffft.lib> - $<$:${CMAKE_CURRENT_SOURCE_DIR}/lib/Windows/Release/pffft.lib> - Eigen - ) -else() - add_library(obr_dylib SHARED IMPORTED) - set_target_properties(obr_dylib PROPERTIES - IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/lib/obr.dylib" - IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/obr.dylib" - IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/obr.dylib" - IMPORTED_LOCATION_RELWITHDEBINFO "${CMAKE_CURRENT_LIST_DIR}/lib/obr.dylib" - IMPORTED_SONAME "obr.dylib" - LINKER_LANGUAGE CXX) - - target_link_libraries(obr - INTERFACE - obr_dylib - Eigen - pffft) -endif() +# Platform-specific impl defined in cmake/prebuiltLibs/*.cmake +target_link_libraries(obr INTERFACE obr_impl Eigen pffft) # Make include dirs available to parent set(OBR_INCLUDE_DIRS @@ -54,6 +30,5 @@ set(OBR_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/obr ${CMAKE_CURRENT_SOURCE_DIR}/obr/renderer ${CMAKE_CURRENT_SOURCE_DIR}/obr/ambisonic_encoder - ) -set(OBR_INCLUDE_DIRS "${OBR_INCLUDE_DIRS}" PARENT_SCOPE) +set(OBR_INCLUDE_DIRS "${OBR_INCLUDE_DIRS}" PARENT_SCOPE) \ No newline at end of file