cmake_minimum_required(VERSION 3.5.0)
project(velix_core_sdk)

set(CORE_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..")
set(MPV_LIBRARY "${CORE_ROOT}/build/ohos-arm64/prefix/lib/libmpv.so.2.5.0" CACHE FILEPATH "Core libmpv path")
set(VELIX_CORE_PROFILE_NAME "default-software" CACHE STRING "SDK build profile")
if(NOT EXISTS "${MPV_LIBRARY}")
    message(FATAL_ERROR "Missing ${MPV_LIBRARY}; build Core before packaging the SDK")
endif()

set(PLAYER_ROOT "${CORE_ROOT}/playback_lab/entry/src/main/cpp")
include_directories(
    "${CORE_ROOT}/include"
    "${CORE_ROOT}"
    "${PLAYER_ROOT}"
    "${CORE_ROOT}/build/ohos-arm64/prefix/include"
)

add_library(mpv SHARED IMPORTED GLOBAL)
set_target_properties(mpv PROPERTIES IMPORTED_LOCATION "${MPV_LIBRARY}")

add_library(velix_core_binding SHARED
    product_binding.cpp
    core_build_info.cpp
    "${PLAYER_ROOT}/player.cpp"
    "${PLAYER_ROOT}/render.cpp"
)
target_compile_features(velix_core_binding PRIVATE cxx_std_17)
target_compile_options(velix_core_binding PRIVATE -fvisibility=hidden -Wall -Wextra -Werror=return-type)
target_compile_definitions(velix_core_binding PRIVATE VELIX_CORE_PROFILE_NAME="${VELIX_CORE_PROFILE_NAME}")
target_link_libraries(velix_core_binding PUBLIC
    mpv
    libace_napi.z.so
    libace_ndk.z.so
    libEGL.so
    libGLESv3.so
    libnative_window.so
    libhilog_ndk.z.so
)
