cmake_minimum_required(VERSION 3.15)

project(HikNetSDKPkg CXX)
set(CMAKE_CXX_STANDARD 11)

set(OS ${CMAKE_HOST_SYSTEM_NAME})
set(Arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)

message(STATUS "Target Operating System: ${OS}")
message(STATUS "Target Architecture: ${Arch}")

if(OS STREQUAL "Windows")
    set(CMAKE_DEBUG_POSTFIX "_win_amd64_d")
    set(CMAKE_RELEASE_POSTFIX "_win_amd64")
elseif (Arch STREQUAL "x86_64" OR Arch STREQUAL "amd64")
    set(CMAKE_DEBUG_POSTFIX "_linux_amd64_d")
    set(CMAKE_RELEASE_POSTFIX "_linux_amd64")
elseif (Arch STREQUAL "aarch64" OR Arch STREQUAL "arm64")
    set(CMAKE_DEBUG_POSTFIX "_linux_arm64_d")
    set(CMAKE_RELEASE_POSTFIX "_linux_arm64")
endif ()

add_library(HikNetSDKPkg SHARED
        library.cpp
        src/HIKBallCamera.cpp
        src/HIKBase.cpp
        src/HIKNvr.cpp
        src/FormatTrans.cpp
)

target_compile_definitions(HikNetSDKPkg PRIVATE Export)

if(Arch STREQUAL "x86_64" OR OS STREQUAL "Windows")
    target_include_directories(HikNetSDKPkg PRIVATE "./src/include/Hik/amd64")
elseif (Arch STREQUAL "aarch64")
    target_include_directories(HikNetSDKPkg PRIVATE "./src/include/Hik/arm64")
endif ()

if(OS STREQUAL "Windows")
    target_link_directories(HikNetSDKPkg PRIVATE "./arm64_windows_lib")
    target_link_libraries(HikNetSDKPkg PRIVATE "HCNetSDK.lib")
    target_link_libraries(HikNetSDKPkg PRIVATE "HCCore.lib")
    target_link_libraries(HikNetSDKPkg PRIVATE "GdiPlus.lib")
elseif (Arch STREQUAL "x86_64")
    target_link_directories(HikNetSDKPkg PRIVATE "./amd64_linux_lib")
    target_link_libraries(HikNetSDKPkg "libHCCore.so")
    target_link_libraries(HikNetSDKPkg "libhcnetsdk.so")
    target_link_libraries(HikNetSDKPkg "libhpr.so")
    target_link_libraries(HikNetSDKPkg "libz.so")
elseif (Arch STREQUAL "aarch64")
    target_link_directories(HikNetSDKPkg PRIVATE "./arm64_linux_lib")
    target_link_libraries(HikNetSDKPkg "libAudioRender.so")
    target_link_libraries(HikNetSDKPkg "libcrypto.so")
    target_link_libraries(HikNetSDKPkg "libHCCore.so")
    target_link_libraries(HikNetSDKPkg "libhcnetsdk.so")
    target_link_libraries(HikNetSDKPkg "libhpr.so")
    target_link_libraries(HikNetSDKPkg "libPlayCtrl.so")
    target_link_libraries(HikNetSDKPkg "libssl.so")
    target_link_libraries(HikNetSDKPkg "libSuperRender.so")
    target_link_libraries(HikNetSDKPkg "libz.so")
endif ()