cmake_minimum_required(VERSION 3.16)

project(
  td_azure_sdk
)

set(AZURE_SDK_LIBRARY_DIR sdk)

file(GLOB AZURE_SDK_SRC
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/credentials/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/cryptography/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/http/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/http/curl/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/io/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/src/tracing/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/identity/azure-identity/src/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/src/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/src/private/*.cpp"
    "${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-common/src/*.cpp"
)

file(GLOB AZURE_SDK_UNIFIED_SRC
    ${AZURE_SDK_SRC}
)

set(AZURE_SDK_INCLUDES
    "${AZURE_SDK_LIBRARY_DIR}/core/azure-core/inc/"
    "${AZURE_SDK_LIBRARY_DIR}/identity/azure-identity/inc/"
    "${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-common/inc/"
    "${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/inc/"
)

add_library(td_azure_sdk STATIC ${AZURE_SDK_UNIFIED_SRC})
target_compile_definitions(td_azure_sdk PRIVATE BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  target_compile_features(td_azure_sdk PRIVATE cxx_std_20)
endif()

target_include_directories(td_azure_sdk
  PUBLIC
    ${AZURE_SDK_INCLUDES}
    ${CURL_INCLUDE}
    ${OPENSSL_INCLUDE}
    ${LIBXML2_INCLUDE}
    ${ZLIB_INCLUDE}
)
target_link_libraries(td_azure_sdk PRIVATE
  ${CURL_LIBS}
  ${OPENSSL_LIBS}
  ${CRYPTO_LIBS}
	${LIBXML2_LIBS}
  ${ZLIB_LIBS}
)

install(TARGETS td_azure_sdk)
install(
  DIRECTORY
    ${AZURE_SDK_LIBRARY_DIR}/core/azure-core/inc/azure
    ${AZURE_SDK_LIBRARY_DIR}/identity/azure-identity/inc/azure
    ${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-common/inc/azure
    ${AZURE_SDK_LIBRARY_DIR}/storage/azure-storage-blobs/inc/azure
  DESTINATION include
)

