if(WIN32)
    set(MIG_CAMERA_SOURCE camera.cpp)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(MIG_CAMERA_SOURCE camera_linux.cpp)
else()
    message(FATAL_ERROR "The native capture/estimator adapter supports Windows and Linux")
endif()
add_library(mig-native STATIC pose.cpp ${MIG_CAMERA_SOURCE} observations.cpp runtime.cpp)
add_library(MIG::native ALIAS mig-native)
set_target_properties(mig-native PROPERTIES EXPORT_NAME native)
target_include_directories(mig-native PUBLIC
    "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/mig/native>")
if(MIG_INSTALL)
    install(FILES pose.hpp camera.hpp runtime.hpp DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/mig/native")
endif()
target_include_directories(mig-native PRIVATE "${MIG_NATIVE_DEPS}/include")
target_link_libraries(mig-native PUBLIC mig-core)
if(WIN32)
    target_link_libraries(mig-native PUBLIC mfplat mfreadwrite mfuuid mf ole32)
else()
    target_link_libraries(mig-native PRIVATE ${CMAKE_DL_LIBS})
endif()
if(WIN32)
    target_compile_definitions(mig-native PUBLIC UNICODE _UNICODE NOMINMAX WIN32_LEAN_AND_MEAN)
endif()
if(MIG_BUILD_HANDS)
    target_link_libraries(mig-native PUBLIC mig-hands)
    target_compile_definitions(mig-native PUBLIC MIG_NATIVE_HANDS)
    if(NOT EXISTS "${MIG_NATIVE_DEPS}/include/mediapipe/tasks/c/vision/hand_landmarker/hand_landmarker.h"
          OR NOT EXISTS "${MIG_NATIVE_DEPS}/models/hand_landmarker.task")
        message(FATAL_ERROR "Hand tracking artifacts missing: rerun the platform's bootstrap-native script or set MIG_BUILD_HANDS=OFF")
    endif()
endif()
