project(email-account-sync)

set(EMAIL_ACCOUNT_SYNC_SRC
    ${CMAKE_CURRENT_SOURCE_DIR}/config_build.sh
    ${CMAKE_CURRENT_SOURCE_DIR}/install.rdf
    ${CMAKE_CURRENT_SOURCE_DIR}/chrome.manifest)

add_custom_target(thunderbird ALL
                  DEPENDS androidaccountmanagerproxy
                  SOURCES ${EMAIL_ACCOUNT_SYNC_SRC})

add_custom_command(TARGET thunderbird POST_BUILD
                   COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/build.sh
                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                   DEPENDS ${EMAIL_ACCOUNT_SYNC_SRC}
                   )

add_subdirectory(proxy)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build.sh.in
               ${CMAKE_CURRENT_BINARY_DIR}/build.sh @ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/androidaccountsync.xpi
        DESTINATION /usr/lib/thunderbird-addons/extensions/
        RENAME androidaccountsync@ubuntu.com.xpi)

