INCLUDE(WebKitEfl)

LIST(APPEND WebKit_LINK_FLAGS
    ${ECORE_X_LDFLAGS}
    ${EDJE_LDFLAGS}
    ${EFLDEPS_LDFLAGS}
    ${EVAS_LDFLAGS}
)

LIST(APPEND WebKit_INCLUDE_DIRECTORIES
    "${WEBKIT_DIR}/efl/ewk"
    "${WEBKIT_DIR}/efl/WebCoreSupport"
    ${Cairo_INCLUDE_DIRS}
    ${ECORE_X_INCLUDE_DIRS}
    ${EDJE_INCLUDE_DIRS}
    ${EFLDEPS_INCLUDE_DIRS}
    ${EVAS_INCLUDE_DIRS}
    ${Gdk_INCLUDE_DIRS}
    ${Glib_INCLUDE_DIRS}
    ${LIBSOUP24_INCLUDE_DIRS}
    ${LIBXML2_INCLUDE_DIRS}
    ${LIBXSLT_INCLUDE_DIRS}
    ${SQLITE_INCLUDE_DIRS}
)

LIST(APPEND WebKit_SOURCES
    efl/WebCoreSupport/ChromeClientEfl.cpp
    efl/WebCoreSupport/ContextMenuClientEfl.cpp
    efl/WebCoreSupport/DragClientEfl.cpp
    efl/WebCoreSupport/EditorClientEfl.cpp
    efl/WebCoreSupport/FrameLoaderClientEfl.cpp
    efl/WebCoreSupport/InspectorClientEfl.cpp

    efl/ewk/ewk_contextmenu.cpp
    efl/ewk/ewk_cookies.cpp
    efl/ewk/ewk_frame.cpp
    efl/ewk/ewk_history.cpp
    efl/ewk/ewk_main.cpp
    efl/ewk/ewk_settings.cpp
    efl/ewk/ewk_util.cpp
    efl/ewk/ewk_view.cpp
    efl/ewk/ewk_view_single.c
    efl/ewk/ewk_window_features.cpp
)

LIST(APPEND WebKit_LIBRARIES
    ${Cairo_LIBRARIES}
    ${ECORE_X_LIBRARIES}
    ${EFLDEPS_LIBRARIES}
    ${Freetype_LIBRARIES}
    ${Gdk_LIBRARIES}
    ${Glib_LIBRARIES}
    ${Gtk_LIBRARIES}
    ${LIBSOUP24_LIBRARIES}
    ${LIBXML2_LIBRARIES}
    ${Pango_LIBRARIES}
    ${SQLITE_LIBRARIES}
)

FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/WebKit/efl/DefaultTheme)
GENERATE_EDJ(
    ${WEBKIT_DIR}/efl/DefaultTheme/default.edc
    ${CMAKE_BINARY_DIR}/WebKit/efl/DefaultTheme/default.edj
    "-id;${WEBKIT_DIR}/efl/DefaultTheme"
)

SET(EWebLauncher_SOURCES
    efl/DefaultTheme/default.edj
    efl/EWebLauncher/main.c
)

SET(EWebLauncher_LIBRARIES
    ${JavaScriptCore_LIBRARY_NAME}
    ${WebCore_LIBRARY_NAME}
    ${WebKit_LIBRARY_NAME}
    ${Cairo_LIBRARIES}
    ${ECORE_X_LIBRARIES}
    ${EDJE_LIBRARIES}
    ${EFLDEPS_LIBRARIES}
    ${EVAS_LIBRARIES}
    ${Gdk_LIBRARIES}
    ${Glib_LIBRARIES}
    ${LIBSOUP24_LIBRARIES}
    ${LIBXML2_LIBRARIES}
    ${LIBXSLT_LIBRARIES}
    ${SQLITE_LIBRARIES}
)

SET(EWebLauncher_LINK_FLAGS
    ${ECORE_X_LDFLAGS}
    ${EDJE_LDFLAGS}
    ${EFLDEPS_LDFLAGS}
    ${EVAS_LDFLAGS}
    ${LIBSOUP24_LDFLAGS}
)

ADD_EXECUTABLE(../Programs/EWebLauncher ${EWebLauncher_SOURCES})
TARGET_LINK_LIBRARIES(../Programs/EWebLauncher ${EWebLauncher_LIBRARIES})
ADD_TARGET_PROPERTIES(../Programs/EWebLauncher LINK_FLAGS "${EWebLauncher_LINK_FLAGS}")

IF (SHARED_CORE)
    SET(LIBS_PRIVATE "-l${WTF_LIBRARY_NAME} -l${JavaScriptCore_LIBRARY_NAME} -l${WebCore_LIBRARY_NAME}")
ELSE ()
    SET(LIBS_PRIVATE "")
ENDIF ()

CONFIGURE_FILE(
    efl/ewebkit.pc.in
    ${CMAKE_BINARY_DIR}/WebKit/efl/ewebkit.pc
    @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/WebKit/efl/ewebkit.pc
    DESTINATION lib/pkgconfig)

UNSET(LIBS_PRIVATE)

FILE(GLOB EWebKit_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/*.h")
LIST(REMOVE_ITEM EWebKit_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_private.h")

INSTALL(FILES ${EWebKit_HEADERS}
        DESTINATION include/EWebKit)
