set(GLMAIL_SOURCES
  mime/parser.cpp
  providers/mock_provider.cpp
  providers/imap_client.cpp
  providers/imap_provider.cpp
  network/credential_store.cpp
  storage/sqlite_database.cpp
  storage/mail_store.cpp
  sync/sync_manager.cpp
  models/ui_models.cpp
  ui/account_sidebar.cpp
  ui/thread_list.cpp
  ui/conversation_view.cpp
  ui/settings_panel.cpp
  ui/compose_window.cpp
  ui/mail_window.cpp
  src/mail_app.cpp
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLMAIL_CURL REQUIRED IMPORTED_TARGET libcurl)
pkg_check_modules(GLMAIL_SECRET REQUIRED IMPORTED_TARGET libsecret-1)
add_library(glmail_support STATIC ${GLMAIL_SOURCES})
target_include_directories(glmail_support PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(glmail_support PUBLIC gldoze_engine PkgConfig::GLMAIL_CURL PkgConfig::GLMAIL_SECRET)
if(BUILD_TESTING)
  add_executable(glmail_architecture_test tests/architecture_test.cpp)
  target_link_libraries(glmail_architecture_test PRIVATE glmail_support)
  add_test(NAME glmail_architecture COMMAND glmail_architecture_test)
  add_executable(glmail_imap_core_test tests/imap_core_test.cpp)
  target_link_libraries(glmail_imap_core_test PRIVATE glmail_support)
  add_test(NAME glmail_imap_core COMMAND glmail_imap_core_test)
  add_executable(glmail_mime_parser_test tests/mime_parser_test.cpp)
  target_link_libraries(glmail_mime_parser_test PRIVATE glmail_support)
  add_test(NAME glmail_mime_parser COMMAND glmail_mime_parser_test)
  add_executable(glmail_received_date_test tests/received_date_test.cpp)
  target_link_libraries(glmail_received_date_test PRIVATE glmail_support)
  add_test(NAME glmail_received_date COMMAND glmail_received_date_test)
endif()
