cmake_minimum_required(VERSION 3.10.2)
project(statistics)

# Set proper STL type
set(CMAKE_ANDROID_STL_TYPE c++_shared)

# Configure LP64 mode properly for 64-bit architectures
set(LP64_DEFS)
if(ANDROID_ABI STREQUAL "arm64-v8a" OR ANDROID_ABI STREQUAL "x86_64")
    set(LP64_DEFS -D_LP64=1)
endif()

# Add all needed definitions
add_definitions(${LP64_DEFS} -D__STDC_FORMAT_MACROS)

# Define source files
set(STATISTICS_SOURCES
    ../native/statistics/health_analytics.cpp
)

# Add the library using the collected sources
add_library(statistics SHARED ${STATISTICS_SOURCES})

# Now that the target exists, we can set compile options
if(ANDROID_ABI STREQUAL "arm64-v8a")
    target_compile_options(statistics PRIVATE -D_GLIBCXX_USE_C99=1)
endif()

# Include directories
target_include_directories(statistics PRIVATE ../native/statistics)

# Link libraries
target_link_libraries(statistics android log)

# Set C++ standard
set_target_properties(statistics PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
)