# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(KmpDemo)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
        ${NATIVERENDER_ROOT_PATH}/include)

add_library(entry SHARED napi_init.cpp)

# 按 ABI 选 libkn.so 路径（当前 abiFilters 仅 x86_64 时只构建模拟器）
if(CMAKE_OHOS_ARCH_ABI STREQUAL "x86_64" OR OHOS_ARCH STREQUAL "x86_64")
    set(LIBKN_ABI_DIR "x86_64")
else()
    set(LIBKN_ABI_DIR "arm64-v8a")
endif()

add_library(kn SHARED IMPORTED)
set_target_properties(kn PROPERTIES
        IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${LIBKN_ABI_DIR}/libkn.so"
)
message(STATUS "Loading libkn.so for ${LIBKN_ABI_DIR} architecture")

target_link_libraries(entry PUBLIC libace_napi.z.so)
target_link_libraries(entry PRIVATE kn)
