cmake_minimum_required(VERSION 3.16)
project(Plugins LANGUAGES C CXX)

find_package(Python COMPONENTS Development)
find_package(Qt6 COMPONENTS PrintSupport)
find_package(TCL)

if(WIN32 OR APPLE)
    set(WITH_PORTABLE_DEFAULT ON)
endif()

option(WITH_ALL_PLUGINS "Build all plugins (individual plugins can still be disabled via -DWITH_<plugin>=OFF)" OFF)

if(Qt6PrintSupport_FOUND OR WITH_ALL_PLUGINS)
    set(WITH_Printing_DEFAULT ON)
endif()
if(TCL_FOUND OR WITH_ALL_PLUGINS)
    set(WITH_ScriptingTcl_DEFAULT ON)
endif()
if(Python_Development_FOUND OR WITH_ALL_PLUGINS)
    set(WITH_ScriptingPython_DEFAULT ON)
endif()

option(WITH_CellRendererImage "Build CellRendererImage plugin" ON)
option(WITH_CsvExport "Build CsvExport plugin" ON)
option(WITH_CsvImport "Build CsvImport plugin" ON)
option(WITH_DbAndroid "Build DbAndroid plugin" ON)
option(WITH_DbSQLite3MC "Build DbSQLite3MC plugin" ON)
option(WITH_ErdEditor "Build ErdEditor plugin" ON)
option(WITH_FusionDarkStyle "Build FusionDarkStyle plugin" ON)
option(WITH_HtmlExport "Build HtmlExport plugin" ON)
option(WITH_JsonExport "Build JsonExport plugin" ON)
option(WITH_MultiEditorImage "Build MultiEditorImage plugin" ON)
option(WITH_MultiEditorJson "Build MultiEditorJson plugin" ON)
option(WITH_PdfExport "Build PdfExport plugin" ON)
option(WITH_Printing "Build Printing plugin" ${WITH_Printing_DEFAULT})
option(WITH_PythonSyntaxHighlighter "Build PythonSyntaxHighlighter plugin" ON)
option(WITH_RegExpImport "Build RegExpImport plugin" ON)
option(WITH_ScriptingPython "Build ScriptingPython plugin" ${WITH_ScriptingPython_DEFAULT})
option(WITH_ScriptingTcl "Build ScriptingTcl plugin" ${WITH_ScriptingTcl_DEFAULT})
option(WITH_SqlEnterpriseFormatter "Build SqlEnterpriseFormatter plugin" ON)
option(WITH_SqlExport "Build SqlExport plugin" ON)
option(WITH_SqlFormatterSimple "Build SqlFormatterSimple plugin" ON)
option(WITH_TclSyntaxHighlighter "Build TclSyntaxHighlighter plugin" ON)
option(WITH_TipOfTheDay "Build TipOfTheDay plugin" ON)
option(WITH_XmlExport "Build XmlExport plugin" ON)

option(WITH_PORTABLE "Install plugins within portable bundle" ${WITH_PORTABLE_DEFAULT})
option(WITH_SHARED_RES "Install resources as separate files (distro packaging only)" OFF)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../Letos/cmake")

include(letos_sqlite3)
include(plugins)

if(WITH_CellRendererImage)
    add_subdirectory(CellRendererImage)
endif()
if(WITH_CsvExport)
    add_subdirectory(CsvExport)
endif()
if(WITH_CsvImport)
    add_subdirectory(CsvImport)
endif()
if(WITH_ErdEditor)
    add_subdirectory(ErdEditor)
endif()
if(WITH_FusionDarkStyle)
    add_subdirectory(FusionDarkStyle)
endif()
if(WITH_HtmlExport)
    add_subdirectory(HtmlExport)
endif()
if(WITH_PdfExport)
    add_subdirectory(PdfExport)
endif()
if(WITH_SqlExport)
    add_subdirectory(SqlExport)
endif()
if(WITH_SqlFormatterSimple)
    add_subdirectory(SqlFormatterSimple)
endif()
if(WITH_TclSyntaxHighlighter)
    add_subdirectory(TclSyntaxHighlighter)
endif()
if(WITH_XmlExport)
    add_subdirectory(XmlExport)
endif()
if(WITH_JsonExport)
    add_subdirectory(JsonExport)
endif()
if(WITH_RegExpImport)
    add_subdirectory(RegExpImport)
endif()
if(WITH_Printing)
    add_subdirectory(Printing)
endif()
if(WITH_SqlEnterpriseFormatter)
    add_subdirectory(SqlEnterpriseFormatter)
endif()
if(WITH_ScriptingTcl)
    add_subdirectory(ScriptingTcl)
endif()
if(WITH_ScriptingPython)
    add_subdirectory(ScriptingPython)
endif()
if(WITH_DbAndroid)
    add_subdirectory(DbAndroid)
endif()
if(WITH_DbSQLite3MC)
    add_subdirectory(DbSQLite3MC)
endif()
if(WITH_MultiEditorImage)
    add_subdirectory(MultiEditorImage)
endif()
if(WITH_MultiEditorJson)
    add_subdirectory(MultiEditorJson)
endif()
if(WITH_PythonSyntaxHighlighter)
    add_subdirectory(PythonSyntaxHighlighter)
endif()
if(WITH_TipOfTheDay)
    add_subdirectory(TipOfTheDay)
endif()


# show summary
message(STATUS "---------------------------------------")
message(STATUS "Letos plugins:")
message(STATUS "  CellRendererImage:       ${WITH_CellRendererImage}")
message(STATUS "  CsvExport:               ${WITH_CsvExport}")
message(STATUS "  CsvImport:               ${WITH_CsvImport}")
message(STATUS "  DbAndroid:               ${WITH_DbAndroid}")
message(STATUS "  DbSQLite3MC:             ${WITH_DbSQLite3MC}")
message(STATUS "  ErdEditor:               ${WITH_ErdEditor}")
message(STATUS "  FusionDarkStyle:         ${WITH_FusionDarkStyle}")
message(STATUS "  HtmlExport:              ${WITH_HtmlExport}")
message(STATUS "  JsonExport:              ${WITH_JsonExport}")
message(STATUS "  MultiEditorImage:        ${WITH_MultiEditorImage}")
message(STATUS "  MultiEditorJson:         ${WITH_MultiEditorJson}")
message(STATUS "  PdfExport:               ${WITH_PdfExport}")
message(STATUS "  Printing:                ${WITH_Printing}")
message(STATUS "  RegExpImport:            ${WITH_RegExpImport}")
message(STATUS "  ScriptingPython:         ${WITH_ScriptingPython}")
message(STATUS "  ScriptingTcl:            ${WITH_ScriptingTcl}")
message(STATUS "  SqlEnterpriseFormatter:  ${WITH_SqlEnterpriseFormatter}")
message(STATUS "  SqlExport:               ${WITH_SqlExport}")
message(STATUS "  SqlFormatterSimple:      ${WITH_SqlFormatterSimple}")
message(STATUS "  TclSyntaxHighlighter:    ${WITH_TclSyntaxHighlighter}")
message(STATUS "  TipOfTheDay:             ${WITH_TipOfTheDay}")
message(STATUS "  XmlExport:               ${WITH_XmlExport}")
message(STATUS "---------------------------------------")
