file(GLOB_RECURSE sources *.h *.cpp)

set(target_name immvision)
add_library(${target_name} ${sources})
if (IMMVISION_SERIALIZE_JSON)
    target_compile_options(${target_name} PUBLIC -DIMMVISION_SERIALIZE_JSON)
endif()
target_include_directories(${target_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)

# stb_image and stb_image_write: when hello_imgui is available it already provides
# the implementations; in standalone mode, immvision compiles its own.
if(NOT TARGET hello_imgui)
    target_compile_definitions(${target_name} PRIVATE
        IMMVISION_PROVIDE_STB_IMAGE
        IMMVISION_PROVIDE_STB_IMAGE_WRITE)
endif()

target_link_libraries(${target_name} PUBLIC
    imgui
    immvision_gl_loader
    )

# With hello_imgui, an image takes a finger's drags at once on a touch screen (HelloImGui::SetItemTakesTouchDrags)
if(TARGET hello_imgui)
    target_link_libraries(${target_name} PUBLIC hello_imgui)
    target_compile_definitions(${target_name} PRIVATE IMMVISION_WITH_HELLO_IMGUI)
endif()
