set(APP_NAME notes_tk)

message(STATUS "Checking dependencies for app: " ${APP_NAME})

list(APPEND client_HEADERS 
    NotesTk.h
    text_editor/TextEditorView.h
    text_editor/TextEditorModel.h
    text_editor/TextEditorController.h
    text_editor/PlainTextDocument.h
    audio_editor/AudioEditorView.h
    image_editor/ImageEditorView.h
    image_editor/ImageViewWidget.h
    canvas/CanvasView.h
    canvas/CanvasController.h
    canvas/CanvasDrawingArea.h
    canvas/CanvasCommandSelectorView.h
    mesh_viewer/MeshViewerView.h
    mesh_viewer/MeshViewerController.h
    mesh_viewer/MeshViewerCanvas.h
    web_client/WebClientView.h)

list(APPEND client_LIB_INCLUDES 
    text_editor/TextEditorView.cpp
    text_editor/TextEditorModel.cpp
    text_editor/TextEditorController.cpp
    text_editor/PlainTextDocument.cpp
    audio_editor/AudioEditorView.cpp
    image_editor/ImageEditorView.cpp
    image_editor/ImageViewWidget.cpp
    mesh_viewer/MeshViewerView.cpp
    mesh_viewer/MeshViewerController.cpp
    mesh_viewer/MeshViewerCanvas.cpp
    canvas/CanvasView.cpp
    canvas/CanvasController.cpp
    canvas/CanvasDrawingArea.cpp
    canvas/CanvasCommandSelectorView.cpp
    web_client/WebClientView.cpp
    NotesTk.cpp)
   
set(DEPENDENCIES_FOUND True)
if(WIN32)
    add_executable(${APP_NAME} WIN32 main-win.cpp ${client_LIB_INCLUDES})
else()
    find_package(X11 QUIET)
    if(X11_FOUND)
        add_executable(${APP_NAME} main.cpp ${client_LIB_INCLUDES} ${client_HEADERS})
    else()
        message(STATUS "X11 not found - skipping")
        set(DEPENDENCIES_FOUND FALSE)
    endif()
endif()


if(DEPENDENCIES_FOUND)
target_include_directories(${APP_NAME} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/text_editor
    ${CMAKE_CURRENT_SOURCE_DIR}/audio_editor
    ${CMAKE_CURRENT_SOURCE_DIR}/image_editor
    ${CMAKE_CURRENT_SOURCE_DIR}/web_client
    ${CMAKE_CURRENT_SOURCE_DIR}/canvas
    ${CMAKE_CURRENT_SOURCE_DIR}/mesh_viewer
                              )
target_link_libraries(${APP_NAME} PUBLIC ui_controls client windows console core network database geometry audio web)
set_property(TARGET ${APP_NAME} PROPERTY FOLDER apps)
endif()

