include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/libkstapp ${CMAKE_SOURCE_DIR}/src/libkst ${CMAKE_SOURCE_DIR}/src/libkstmath ${CMAKE_SOURCE_DIR}/src/extdate ${CMAKE_SOURCE_DIR}/src/widgets ${CMAKE_SOURCE_DIR}/src/plugins/crossspectrum ${CMAKE_SOURCE_DIR}/src/plugins/binnedmap ${CMAKE_CURRENT_SOURCE_DIR} ${KJSEMBED_INCLUDES} ${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} )

if(NOT KST_HAVE_KJSEMBED)
    add_subdirectory(kjsembed)
    link_directories(${CMAKE_CURRENT_SOURCE_DIR}/kjsembed ${CMAKE_SOURCE_DIR}/src/libkstapp ${LINK_DIRECTORIES} ${QT_UI_LIBRARY_DIR})
    SET(KJSEMBED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/kjsembed)
else(NOT KST_HAVE_KJSEMBED)
    SET(JSEXTERN js_extern.cpp)
endif(NOT KST_HAVE_KJSEMBED)

set(LINK_FLAGS "${LINK_FLAGS} -module -avoid-version")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_ASCII_CAST")

########### next target ###############

set(kstextension_js_PART_SRCS
    ${JSEXTERN}
    js.cpp
    jsiface_impl.cpp
    elogthreadsubmit.cpp
    kstbinding.cpp
    bind_object.cpp
    bind_objectcollection.cpp
    bind_vector.cpp
    bind_kst.cpp
    bind_scalar.cpp
    bind_string.cpp
    bind_datasource.cpp
    bind_datavector.cpp
    bind_equation.cpp
    bind_powerspectrum.cpp
    bind_csd.cpp
    bind_curve.cpp
    bind_point.cpp
    bind_window.cpp
    bind_plot.cpp
    bind_axis.cpp
    bind_timeinterpretation.cpp
    bind_collection.cpp
    bind_plotcollection.cpp
    bind_curvecollection.cpp
    bind_windowcollection.cpp
    bind_vectorcollection.cpp
    bind_scalarcollection.cpp
    bind_stringcollection.cpp
    bind_datasourcecollection.cpp
    bind_histogram.cpp
    bind_matrix.cpp
    bind_image.cpp
    bind_datamatrix.cpp
    bind_debug.cpp
    bind_debuglog.cpp
    bind_debuglogentry.cpp
    bind_histogramcollection.cpp
    bind_equationcollection.cpp
    bind_powerspectrumcollection.cpp
    bind_csdcollection.cpp
    bind_matrixcollection.cpp
    bind_dataobject.cpp
    bind_dataobjectcollection.cpp
    bind_colorsequence.cpp
    bind_extension.cpp
    bind_extensioncollection.cpp
    bind_document.cpp
    bind_plugin.cpp
    bind_plugincollection.cpp
    bind_pluginmanager.cpp
    bind_pluginmodule.cpp
    bind_pluginmodulecollection.cpp
    bind_pluginio.cpp
    bind_pluginiocollection.cpp
    bind_viewobject.cpp
    bind_borderedviewobject.cpp
    bind_viewobjectcollection.cpp
    bind_size.cpp
    bind_box.cpp
    bind_label.cpp
    bind_axisticklabel.cpp
    bind_axislabel.cpp
    bind_plotlabel.cpp
    bind_legend.cpp
    bind_ellipse.cpp
    bind_picture.cpp
    bind_arrow.cpp
    bind_line.cpp
    bind_file.cpp
    bind_dir.cpp
    bind_elog.cpp
    bind_group.cpp
    bind_crosspowerspectrum.cpp
    bind_binnedmap.cpp
    bind_vectorview.cpp)

KDE3_ADD_DCOP_SKELS(kstextension_js_PART_SRCS
    jsiface.h
    jsiface_impl.h)

KDE3_AUTOMOC(${kstextension_js_PART_SRCS})

KDE3_ADD_KPART(kstextension_js ${kstextension_js_PART_SRCS})

target_link_libraries(kstextension_js kparts ${READLINE_LIBS} kstapp kjsembed)

install(TARGETS kstextension_js 
        LIBRARY DESTINATION lib/kde3
        ${INSTALL_TARGETS_DEFAULT_ARGS})

########### next target ###############

if(KST_HAVE_READLINE)
    set(kstcmd_SRCS kstcmd.cpp)

    ADD_EXECUTABLE(kstcmd ${kstcmd_SRCS})

    target_link_libraries(kstcmd kdecore DCOP qt-mt ${READLINE_LIBS})

    install(TARGETS kstcmd 
            RUNTIME DESTINATION bin
            ${INSTALL_TARGETS_DEFAULT_ARGS})
else(KST_HAVE_READLINE)
    message(STATUS "========== kstcmd will not be compiled. JavaScript command line will be missing. Install readline and ncurses to add this functionality")
endif(KST_HAVE_READLINE)

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

install(FILES  kstextension_js.rc DESTINATION share/apps/kst)
install(FILES  kstextension_js.desktop DESTINATION share/services/kst)
