# ANSIO — IO Box communication DLL (cJSON + mbedtls)
add_library(ANSIO SHARED
    dllmain.cpp
    pch.cpp
    pch.h
    framework.h
    # IOBox sources (embedded)
    IOBox/cJSON.c
    IOBox/cJSON_Utils.c
    IOBox/iobox_api.cpp
    IOBox/iobox_api.h
    IOBox/mbedtls/aes.c
    IOBox/mbedtls/base64.c
    IOBox/mbedtls/sha256.c
)

target_include_directories(ANSIO PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${SHARED_INCLUDE_DIR}
)

target_include_directories(ANSIO PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/IOBox
)

target_link_libraries(ANSIO
    PRIVATE ANSLicensingSystem
    PRIVATE anslicensing
    PRIVATE labview
)

target_compile_definitions(ANSIO PRIVATE UNICODE _UNICODE NOMINMAX ANSIO_EXPORTS _USRDLL)
if(WIN32)
    target_link_libraries(ANSIO PRIVATE ${WIN_COMMON_LIBS})
else()
    target_link_libraries(ANSIO PRIVATE ${UNIX_COMMON_LIBS})
endif()

# C files must skip C++ precompiled headers and compile as C
set_source_files_properties(
    IOBox/cJSON.c IOBox/cJSON_Utils.c
    IOBox/mbedtls/aes.c IOBox/mbedtls/base64.c IOBox/mbedtls/sha256.c
    PROPERTIES SKIP_PRECOMPILE_HEADERS ON LANGUAGE C
)

target_precompile_headers(ANSIO PRIVATE pch.h)
