cmake_minimum_required(VERSION 3.24)

set(CMAKE_SOURCE_DIR "/home/setups/camera_driver")

include(${CMAKE_SOURCE_DIR}/cmake/cmakebase.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/project.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/ss928.cmake)

message(STATUS "========================")
message(STATUS ${CMAKE_SYSTEM_NAME})
message(STATUS ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "========================")


PROJECT(camera_driver)

set(CMAKE_SOURCE_DIR "./")

find_package(OpenCV 4.10)
if(NOT OpenCV_FOUND)
    message(FATAL_ERROR "OpenCV > 4.10  not found.")
endif()
MESSAGE(${OpenCV_VERSION})

# 检测操作系统和架构
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
        set(PLATFORM "linux/x64")
    elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
        set(PLATFORM "linux/aarch64")
    else()
        message(FATAL_ERROR "Unsupported architecture on Linux")
    endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
        set(PLATFORM "windows/x64")
    else()
        message(FATAL_ERROR "Unsupported architecture on Windows")
    endif()
else()
    message(FATAL_ERROR "Unsupported operating system")
endif()

# 输出当前系统和架构
message(STATUS "operating system: ${PLATFORM}")

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY  "${CMAKE_SOURCE_DIR}/output/")

INCLUDE_DIRECTORIES(
    "/include"
    "/usr/include"
)
LINK_DIRECTORIES(
    /usr/lib/aarch64-linux-gnu
    ${CMAKE_SOURCE_DIR}/lib
)

aux_source_directory(${CMAKE_SOURCE_DIR}/ SRCLIST)

add_executable(${PROJECT_NAME} ${SRCLIST})
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath-link,/usr/lib/aarch64-linux-gnu")
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} libdl-2.31.so pthread)

add_library(CameraDriver MODULE ${SRCLIST})
target_link_libraries(CameraDriver ${OpenCV_LIBS})

