cmake_minimum_required(VERSION 3.16)
project(fcitx5-wetype VERSION 0.1.0 DESCRIPTION "WeType (微信输入法) engine for fcitx5, with account login via wetyped")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Fcitx5Utils 5.1 REQUIRED)
find_package(Fcitx5Core 5.1 REQUIRED)
find_package(LibIMEPinyin REQUIRED)
find_package(LibIMECore REQUIRED)

include(GNUInstallDirs)

add_library(wetype MODULE src/wetypeengine.cpp)
target_link_libraries(wetype
    Fcitx5::Utils Fcitx5::Core
    LibIME::Core LibIME::Pinyin)
set_target_properties(wetype PROPERTIES PREFIX "" INSTALL_RPATH "$ORIGIN")

# 引擎插件（addon）
install(TARGETS wetype DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/fcitx5")
# addon 描述符
configure_file(wetype.addon.conf.in wetype.addon.conf)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/wetype.addon.conf"
        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/fcitx5/addon"
        RENAME wetype.conf)
# 输入法入口（用户也可复制到 ~/.local/share/fcitx5/inputmethod/）
install(FILES wetype.im.conf
        DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/fcitx5/inputmethod"
        RENAME wetype.conf)
