cmake_minimum_required(VERSION 3.24)

PROJECT(lidar_camera)

set(CMAKE_SOURCE_DIR "./")


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


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(
#     "/opt/HuarayTech/MVviewer/lib"
#     "/opt/HuarayTech/MVviewer/bin"
# )

aux_source_directory(${CMAKE_SOURCE_DIR}/ SRCLIST)

add_executable(${PROJECT_NAME} ${SRCLIST})
target_link_libraries(${PROJECT_NAME} dl)
target_link_libraries(${PROJECT_NAME} pthread)
target_link_libraries(${PROJECT_NAME} "/lib" ${OpenCV_LIBS})

add_library(CameraDriver MODULE ${SRCLIST})
target_link_libraries(CameraDriver  dl)
target_link_libraries(CameraDriver  pthread)
target_link_libraries(CameraDriver "/lib" ${OpenCV_LIBS})

