cmake_minimum_required(VERSION 3.10)
project(verify_sdk VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 选项
option(USE_OPENSSL "Enable OpenSSL for AES encryption" ON)
option(BUILD_TESTS "Build test executable" ON)

# 查找依赖
find_package(CURL REQUIRED)
find_package(nlohmann_json 3.0.0 REQUIRED)

if(USE_OPENSSL)
    find_package(OpenSSL REQUIRED)
    add_compile_definitions(USE_OPENSSL)
endif()

# 库头文件
set(HEADERS
    verify_client.hpp
)

# 库源文件
set(SOURCES
    verify_client.cpp
)

# 创建静态库
add_library(verify_sdk STATIC ${HEADERS} ${SOURCES})

target_include_directories(verify_sdk PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(verify_sdk PUBLIC
    CURL::libcurl
    nlohmann_json::nlohmann_json
)

if(USE_OPENSSL)
    target_link_libraries(verify_sdk PUBLIC OpenSSL::SSL OpenSSL::Crypto)
endif()

# 测试可执行文件
if(BUILD_TESTS)
    add_executable(verify_test test_main.cpp)
    target_link_libraries(verify_test PRIVATE verify_sdk)
endif()

# 安装
install(FILES ${HEADERS} DESTINATION include/verify)
install(TARGETS verify_sdk ARCHIVE DESTINATION lib)

# 输出信息
message(STATUS "")
message(STATUS "Verify SDK Configuration:")
message(STATUS "  Version: ${PROJECT_VERSION}")
message(STATUS "  OpenSSL: ${USE_OPENSSL}")
message(STATUS "  Build tests: ${BUILD_TESTS}")
message(STATUS "")
