cmake_minimum_required(VERSION 3.22)
project(lingmo-calculator VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(GNUInstallDirs)
include(CTest)
option(CALCULATOR_BUILD_UI "Build the SDK application" ON)
add_library(calculator-model STATIC src/calculator.cpp src/programmer.cpp src/graph.cpp)
target_include_directories(calculator-model PUBLIC src)
if(CALCULATOR_BUILD_UI)
    find_package(LingmoSDK REQUIRED)
    add_library(calculator-ui STATIC src/calculatorwindow.cpp src/advancedpages.cpp src/globalmenu.cpp)
    target_link_libraries(calculator-ui PUBLIC calculator-model Lingmo::SDK)
    add_executable(lingmo-calculator src/main.cpp)
    target_link_libraries(lingmo-calculator PRIVATE calculator-ui)
    install(TARGETS lingmo-calculator RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
    lingmo_add_translations(lingmo-calculator SOURCES src DESKTOP_FILES lingmo-calculator.desktop)
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lingmo-calculator.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
endif()
if(BUILD_TESTING)
    add_subdirectory(tests)
endif()
