cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)

# KDE Application Version, managed by release script
set(RELEASE_SERVICE_VERSION_MAJOR "23")
set(RELEASE_SERVICE_VERSION_MINOR "08")
set(RELEASE_SERVICE_VERSION_MICRO "3")
set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")

project(kolourpaint VERSION ${RELEASE_SERVICE_VERSION})

set(QT_MIN_VERSION "5.15.2")
set(KF5_MIN_VERSION "5.90.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.84.0")
set(KSANE_MIN_VERSION "21.12.1")

find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

add_definitions(-DTRANSLATION_DOMAIN="kolourpaint")

include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMSetupVersion)
include(FeatureSummary)
if (QT_MAJOR_VERSION STREQUAL "6")
    set(QT_REQUIRED_VERSION "6.4.0")
    set(KF_MIN_VERSION "5.240.0")
    set(KF_MAJOR_VERSION "6")
else()
    set(KF_MAJOR_VERSION "5")
endif()
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
    Core
    Widgets
    PrintSupport
)

find_package(KF${KF_MAJOR_VERSION} ${KF5_MIN_VERSION} REQUIRED COMPONENTS
    DocTools
    I18n
    GuiAddons
    WidgetsAddons
    KIO
    XmlGui
    TextWidgets
    JobWidgets
)

add_definitions(-DQT_USE_QSTRINGBUILDER)

find_package(KF5Sane ${KSANE_MIN_VERSION})

if(KF5Sane_FOUND)
    add_definitions(-DHAVE_KSANE=1)
    set(KSANE_LIBRARIES KF5::Sane)
else(KF5Sane_FOUND)
    add_definitions(-DHAVE_KSANE=0)
endif(KF5Sane_FOUND)

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
)

find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(AIBASE kylin-ai-base)
include_directories(${AIBASE_INCLUDE_DIRS})

pkg_check_modules(Gsetting REQUIRED gsettings-qt)
include_directories(${Gsetting_INCLUDE_DIRS})

pkg_check_modules(Jsoncpp REQUIRED jsoncpp)
include_directories(${Jsoncpp_INCLUDE_DIRS})

pkg_check_modules(JsonGlib REQUIRED json-glib-1.0)
include_directories(${JsonGlib_INCLUDE_DIRS})

## Generate header with version number
ecm_setup_version(${RELEASE_SERVICE_VERSION}
                  VARIABLE_PREFIX KOLOURPAINT
                  VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpVersion.h"
)


add_subdirectory( pics )
add_subdirectory( doc )


########### next target ###############
macro(CREATE_LICENSE _in_FILE _out_FILE)
    FILE(READ ${_in_FILE} _contents)
    FILE(WRITE ${_out_FILE} "static const char * const kpLicenseText =")
    STRING(REGEX REPLACE "\"" "\\\\\"" _contents "${_contents}" )
    STRING(REGEX REPLACE "\n" "\\\\n\"\n\"" _contents "${_contents}" )
    FILE(APPEND ${_out_FILE} "\"${_contents}\"")
    FILE(APPEND ${_out_FILE} ";\n")
endmacro(CREATE_LICENSE)

#macro_additional_clean_files( ${CMAKE_CURRENT_BINARY_DIR}/kolourpaintlicense.h )

create_license(${CMAKE_CURRENT_SOURCE_DIR}/COPYING ${CMAKE_CURRENT_BINARY_DIR}/kolourpaintlicense.h)


# GENERATED BY ./gen_cmake_srcs | fgrep -v /lgpl/

set(kolourpaint_lib1_SRCS
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectBalanceCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectBlurSharpenCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectClearCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectCommandBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectEmbossCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectFlattenCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectGrayscaleCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectHSVCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectInvertCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectReduceColorsCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectToneEnhanceCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/kpDocumentMetaInfoCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformFlipCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformResizeScaleCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformRotateCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformSkewCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommandHistoryBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommandHistory.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommandSize.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/kpMacroCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/kpNamedCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/flow/kpToolFlowCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/kpToolColorPickerCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/kpToolFloodFillCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/polygonal/kpToolPolygonalCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/rectangular/kpToolRectangularCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpAbstractSelectionContentCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolImageSelectionTransparencyCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionCreateCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionDestroyCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionMoveCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionPullFromDocumentCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionResizeScaleCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextBackspaceCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextChangeStyleCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextDeleteCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextEnterCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextGiveContentCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextInsertCommand.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/cursors/kpCursorLightCross.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/cursors/kpCursorProvider.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/effects/kpEffectsDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/kpDocumentMetaInfoDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformPreviewDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformRotateDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformSkewDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/kpColorSimilarityDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/kpDocumentSaveOptionsPreviewDialog.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument_Open.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument_Save.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocumentSaveOptions.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument_Selection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/environments/commands/kpCommandEnvironment.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/environments/dialogs/imagelib/transforms/kpTransformDialogEnvironment.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/environments/document/kpDocumentEnvironment.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/environments/kpEnvironmentBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/environments/tools/kpToolEnvironment.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/environments/tools/selection/kpToolSelectionEnvironment.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/generic/kpSetOverrideCursorSaver.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/generic/kpWidgetMapper.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/generic/widgets/kpResizeSignallingLabel.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/generic/widgets/kpSubWindow.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/blitz.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectBalance.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectBlurSharpen.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectEmboss.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectFlatten.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectGrayscale.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectHSV.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectInvert.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectReduceColors.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectToneEnhance.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpColor_Constants.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpColor.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpDocumentMetaInfo.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpFloodFill.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpPainter.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformAutoCrop.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformCrop.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformCrop_ImageSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformCrop_TextSelection.cpp
)   # kolourpaint_lib1_SRCS

set(kolourpaint_lib2_SRCS
    ${CMAKE_CURRENT_SOURCE_DIR}/kpLogCategories.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/kolourpaint.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/kpThumbnail.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/kpViewScrollableContainer.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpAbstractImageSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpEllipticalImageSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpFreeFormImageSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpImageSelectionTransparency.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpRectangularImageSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/kpAbstractSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/kpSelectionDrag.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/kpSelectionFactory.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextSelection_Cursor.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextSelection_Paint.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextStyle.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpPreeditText.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/layers/tempImage/kpTempImage.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Colors.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Edit.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_File.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Image.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Settings.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_StatusBar.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Text.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Tools.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_View.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_View_Thumbnail.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_View_Zoom.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/pixmapfx/kpPixmapFX_DrawShapes.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/pixmapfx/kpPixmapFX_GetSetPixmapParts.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/pixmapfx/kpPixmapFX_Transforms.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolBrush.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolColorEraser.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolEraser.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolFlowBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolFlowPixmapBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolPen.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolSpraycan.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolColorPicker.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_Drawing.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolFloodFill.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_KeyboardEvents.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_MouseEvents.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_OtherEvents.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_UserNotifications.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_Utilities.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolZoom.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolCurve.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolLine.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolPolygonalBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolPolygon.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolPolyline.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolEllipse.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolRectangle.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolRectangularBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolRoundedRectangle.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpAbstractImageSelectionTool.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpAbstractImageSelectionTool_Transparency.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpToolEllipticalSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpToolFreeFormSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpToolRectSelection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_Create.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_KeyboardEvents.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_Move.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_ResizeScale.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_Commands.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_Create.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_CursorCalc.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_InputMethodEvents.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_KeyboardEvents.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_KeyboardEvents_HandleArrowKeys.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_KeyboardEvents_HandleTypingKeys.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_Move.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_ResizeScale.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_SelectText.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_TextStyle.cpp
)  # kolourpaint_lib2_SRCS


if(KF5Sane_FOUND)
    set(kolourpaint_lib2_SRCS
        ${kolourpaint_lib2_SRCS}
        ${CMAKE_CURRENT_SOURCE_DIR}/scan/sanedialog.cpp
    )
endif(KF5Sane_FOUND)

set(kolourpaint_app_SRCS
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpThumbnailView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpUnzoomedThumbnailView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpView_Events.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpView_Paint.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpView_Selections.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpZoomedThumbnailView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/kpZoomedView.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/manager/kpViewManager.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/manager/kpViewManager_TextCursor.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/views/manager/kpViewManager_ViewUpdates.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityCubeRenderer.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityFrame.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityHolder.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityToolBarItem.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpNumInput.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectBalanceWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectBlurSharpenWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectEmbossWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectFlattenWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectHSVWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectInvertWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectReduceColorsWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectToneEnhanceWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectWidgetBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpColorCells.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpColorPalette.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpDefaultColorCollection.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpDocumentSaveOptionsWidget.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpDualColorButton.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpPrintDialogPage.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpTransparentColorCell.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/kpColorToolBar.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/kpToolToolBar.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/kpAiDrawingBar.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetBase.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetBrush.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetEraserSize.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetFillStyle.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetLineWidth.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetOpaqueOrTransparent.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetSpraycanSize.cpp
)  # set(kolourpaint_app_SRCS


set(kolourpaint_SRCS
    ${kolourpaint_lib1_SRCS}
    ${kolourpaint_lib2_SRCS}
    ${kolourpaint_app_SRCS}
    kolourpaint.qrc
)

add_subdirectory(lgpl)

#
# Executable
#

ecm_add_app_icon(kolourpaint_SRCS ICONS
    pics/app/16-apps-kolourpaint.png
    pics/app/22-apps-kolourpaint.png
    pics/app/32-apps-kolourpaint.png
    pics/app/48-apps-kolourpaint.png
)

add_executable(kolourpaint ${kolourpaint_SRCS})

target_link_libraries(kolourpaint
    KF${KF_MAJOR_VERSION}::XmlGui
    KF${KF_MAJOR_VERSION}::KIOFileWidgets
    KF${KF_MAJOR_VERSION}::TextWidgets
    Qt${QT_MAJOR_VERSION}::PrintSupport
    Threads::Threads
    ${KSANE_LIBRARIES}
    ${AIBASE_LIBRARIES}
    ${Gsetting_LIBRARIES}
    ${Jsoncpp_LIBRARIES}
    ${JsonGlib_LIBRARIES}
#    ${LIBUKUI_LOG4QT_PATH}
    kolourpaint_lgpl
)

if(KSANE_FOUND)
    target_link_libraries(kolourpaint
        ${KSANE_LIBRARY}
    )
endif(KSANE_FOUND)


install(TARGETS kolourpaint ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})


########### install files ###############

install(PROGRAMS org.kde.kolourpaint.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES org.kde.kolourpaint.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(FILES kolourpaintui.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/kolourpaint)

ki18n_install(po)
kdoctools_install(po)

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
