From 1e22bc3d6775f808072b6cbd8c14040c1e1a48d1 Mon Sep 17 00:00:00 2001 From: Avi Levin Date: Sun, 1 Nov 2015 11:38:51 +0200 Subject: [PATCH] Init files structures --- CMakeLists.txt | 20 +++ cmake/Modules/FindFfi.cmake | 40 ++++++ src/CMakeLists.txt | 20 +++ src/bin/CMakeLists.txt | 34 +++++ src/bin/clouseau_client.c | 227 ++++++++++++++++++++++++++++++++ src/bin/gui | 116 ++++++++++++++++ src/bin/gui.c | 89 +++++++++++++ src/bin/gui.h | 22 ++++ src/cmake/Modules/FindFfi.cmake | 40 ++++++ 9 files changed, 608 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/Modules/FindFfi.cmake create mode 100644 src/CMakeLists.txt create mode 100644 src/bin/CMakeLists.txt create mode 100644 src/bin/clouseau_client.c create mode 100644 src/bin/gui create mode 100644 src/bin/gui.c create mode 100644 src/bin/gui.h create mode 100644 src/cmake/Modules/FindFfi.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..85ef268 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8.1) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + +project(CLOUSEAU) + +#set(EA_GEN_COMMON_DEFINITIONS -DEFL_EO_API_SUPPORT -DEFL_BETA_API_SUPPORT) +#add_definitions(${EA_GEN_COMMON_DEFINITIONS}) + +find_package(Efl REQUIRED) +find_package(Ffi REQUIRED) +find_package(Eina REQUIRED) +find_package(Eet REQUIRED) +find_package(Eolian REQUIRED) +find_package(Eo REQUIRED) +find_package(Elementary REQUIRED) +find_package(Ecore REQUIRED) +find_package(Evas REQUIRED) + +add_subdirectory(src/bin) diff --git a/cmake/Modules/FindFfi.cmake b/cmake/Modules/FindFfi.cmake new file mode 100644 index 0000000..c9224d1 --- /dev/null +++ b/cmake/Modules/FindFfi.cmake @@ -0,0 +1,40 @@ +# - Try to find ffi +# Once done this will define +# FFI_FOUND - System has ffi +# FFI_INCLUDE_DIRS - The ffi include directories +# FFI_LIBRARIES - The libraries needed to use ffi +# FFI_LDFLAGS_OTHER - Other LDFLAGS needed te use ffi. +# FFI_DEFINITIONS - Compiler switches required for using ffi + +find_package(PkgConfig) +if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1") + # "QUIET" was introduced in 2.8.2 + set(_QUIET QUIET) +endif () +pkg_check_modules(PC_LIBFFI ${_QUIET} libffi) +#set(FFI_DEFINITIONS ${PC_LIBFFI_CFLAGS_OTHER}) +#set(FFI_LDFLAGS_OTHER ${PC_LIBFFI_LDFLAGS_OTHER}) + +# before verison 2.8.11 variable CMAKE_LIBRARY_ARCHITECTURE wasn't automatically added to search path +if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.11") + set(FIND_PATH_HINTS ${PC_LIBFFI_INCLUDEDIR}/${CMAKE_LIBRARY_ARCHITECTURE}) +endif () + +find_path(FFI_INCLUDE_DIR ffi.h + HINTS ${PC_LIBFFI_INCLUDEDIR} ${PC_LIBFFI_INCLUDE_DIRS} + ${FIND_PATH_HINTS} + ) + +find_library(FFI_LIBRARY NAMES ffi libffi + HINTS ${PC_LIBFFI_LIBDIR} ${PC_LIBFFI_LIBRARY_DIRS}) + +set(FFI_INCLUDE_DIRS ${FFI_INCLUDE_DIR}) +set(FFI_LIBRARIES ${FFI_LIBRARY}) + +#include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(ffi DEFAULT_MSG + FFI_LIBRARY) + +mark_as_advanced(FFI_INCLUDE_DIRS FFI_LIBRARY) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..85ef268 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8.1) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + +project(CLOUSEAU) + +#set(EA_GEN_COMMON_DEFINITIONS -DEFL_EO_API_SUPPORT -DEFL_BETA_API_SUPPORT) +#add_definitions(${EA_GEN_COMMON_DEFINITIONS}) + +find_package(Efl REQUIRED) +find_package(Ffi REQUIRED) +find_package(Eina REQUIRED) +find_package(Eet REQUIRED) +find_package(Eolian REQUIRED) +find_package(Eo REQUIRED) +find_package(Elementary REQUIRED) +find_package(Ecore REQUIRED) +find_package(Evas REQUIRED) + +add_subdirectory(src/bin) diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt new file mode 100644 index 0000000..ba5f346 --- /dev/null +++ b/src/bin/CMakeLists.txt @@ -0,0 +1,34 @@ +set(CMAKE_BUILD_TYPE Debug) + +LIST(APPEND SOURCES clouseau_client.c gui.c) + + +add_definitions(${CLI_COMMON_DEFINITIONS} -DEFL_BETA_API_SUPPORT) +add_definitions(${CLI_COMMON_DEFINITIONS}) + +include_directories( + ${ELEMENTARY_INCLUDE_DIRS} + ${EINA_INCLUDE_DIRS} + ${EET_INCLUDE_DIRS} + ${EO_INCLUDE_DIRS} + ${EOLIAN_INCLUDE_DIRS} + ${ECORE_INCLUDE_DIRS} + ${EVAS_INCLUDE_DIRS} + ) + +set(EOLIAN_INCLUDE_FLAG -I \"${EOLIAN_EO_DIR}/eo-1\" -I${CMAKE_CURRENT_SOURCE_DIR}) + +add_executable(clouseau_client ${SOURCES}) + +target_link_libraries(clouseau_client + pthread + ${EFL_LIBRARIES} + ${ELEMENTARY_LIBRARIES} + ${EINA_LIBRARIES} + ${EET_LIBRARIES} + ${EO_LIBRARIES} + ${EOLIAN_LIBRARIES} + ${ECORE_LIBRARIES} + ${EVAS_LIBRARIES} + ) + diff --git a/src/bin/clouseau_client.c b/src/bin/clouseau_client.c new file mode 100644 index 0000000..86f50d6 --- /dev/null +++ b/src/bin/clouseau_client.c @@ -0,0 +1,227 @@ +#ifndef EFL_BETA_API_SUPPORT +#define EFL_BETA_API_SUPPORT +#endif +#ifndef EFL_EO_API_SUPPORT +#define EFL_EO_API_SUPPORT +#endif +#ifndef ELM_INTERNAL_API_ARGESFSDFEFC +#define ELM_INTERNAL_API_ARGESFSDFEFC +#endif +#include +#include +#include "gui.h" + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +#define EXTRACT(_buf, pval, sz) \ +{ \ + memcpy(pval, _buf, sz); \ + _buf += sz; \ +} + +static uint32_t _cl_stat_reg_opcode = EINA_DEBUG_OPCODE_INVALID; +static uint32_t _cid_from_pid_opcode = EINA_DEBUG_OPCODE_INVALID; +static uint32_t _poll_on_opcode = EINA_DEBUG_OPCODE_INVALID; +static uint32_t _poll_off_opcode = EINA_DEBUG_OPCODE_INVALID; +static uint32_t _evlog_on_opcode = EINA_DEBUG_OPCODE_INVALID; +static uint32_t _evlog_off_opcode = EINA_DEBUG_OPCODE_INVALID; +static uint32_t _eo_list_opcode = EINA_DEBUG_OPCODE_INVALID; +static Gui_Widgets *pub_widgets = NULL; + +typedef struct +{ + uint32_t *opcode; /* address to the opcode */ + void *buffer; + int size; +} _pending_request; + +static Eina_List *_pending = NULL; +static Eina_Debug_Session *_session = NULL; + +static uint32_t _cid = 0; + +static int my_argc = 0; +static char **my_argv = NULL; + +static void +_consume() +{ + if (!_pending) + { + return; + } + _pending_request *req = eina_list_data_get(_pending); + _pending = eina_list_remove(_pending, req); + + Eina_Debug_Client *cl = eina_debug_client_new(_session, _cid); + eina_debug_session_send(cl, *(req->opcode), req->buffer, req->size); + eina_debug_client_free(cl); + + free(req->buffer); + free(req); +} + +static void +_pending_add(uint32_t *opcode, void *buffer, int size) +{ + _pending_request *req = malloc(sizeof(*req)); + req->opcode = opcode; + req->buffer = buffer; + req->size = size; + _pending = eina_list_append(_pending, req); +} + +static Eina_Bool +_cid_get_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size EINA_UNUSED) +{ + _cid = *(uint32_t *)buffer; + _consume(); + return EINA_TRUE; +} + +static Eina_Bool +_clients_info_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size) +{ + char *buf = buffer; + while(size) + { + int cid, pid, len; + EXTRACT(buf, &cid, sizeof(uint32_t)); + EXTRACT(buf, &pid, sizeof(uint32_t)); + if(pid != getpid()) + { + printf("CID: %d - PID: %d - Name: %s\n", cid, pid, buf); + char option[100]; + snprintf(option, 90, "CID: %d - PID: %d - Name: %s", cid, pid, buf); + printf("%s\n", option); + elm_hoversel_item_add(pub_widgets->elm_win1->elm_hoversel1, option, "home", ELM_ICON_STANDARD, NULL, + (const void *)(long)cid); + } + len = strlen(buf) + 1; + buf += len; + size -= (2 * sizeof(uint32_t) + len); + } + _consume(); + return EINA_TRUE; +} + +static Eina_Bool +_clients_info_deleted_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size) +{ + char *buf = buffer; + if(size >= (int)sizeof(uint32_t)) + { + int cid; + EXTRACT(buf, &cid, sizeof(uint32_t)); + printf("CID: %d deleted\n", cid); + + const Eina_List *items = elm_hoversel_items_get(pub_widgets->elm_win1->elm_hoversel1); + const Eina_List *l; + Elm_Object_Item *hoversel_it; + + EINA_LIST_FOREACH(items, l, hoversel_it) + if((int)(long)elm_object_item_data_get(hoversel_it) == cid) + { + elm_object_item_del(hoversel_it); + break; + } + } + _consume(); + return EINA_TRUE; +} + +static Eina_Bool +_objects_list_cb(Eina_Debug_Client *src EINA_UNUSED, void *buffer, int size) +{ + Eina_List *objs = eo_debug_list_response_decode(buffer, size), *itr; + Obj_Info *info; + EINA_LIST_FOREACH(objs, itr, info) + { + printf("%p: %s\n", info->ptr, info->kl_name); + } + return EINA_TRUE; +} + +static void +_args_handle(Eina_Bool flag) +{ + int i; + if(!flag) return; + Eina_Debug_Client *cl = eina_debug_client_new(_session, 0); + eina_debug_session_send(cl, _cl_stat_reg_opcode, NULL, 0); + + for (i = 1; i < my_argc;) + { + if (i < my_argc - 1) + { + const char *op_str = my_argv[i++]; + uint32_t pid = atoi(my_argv[i++]); + char *buf = NULL; + eina_debug_session_send(cl, _cid_from_pid_opcode, &pid, sizeof(uint32_t)); + printf("got %s %d\n", op_str, pid); + if ((!strcmp(op_str, "pon")) && (i < (my_argc - 2))) + { + uint32_t freq = atoi(my_argv[i++]); + buf = malloc(sizeof(uint32_t)); + memcpy(buf, &freq, sizeof(uint32_t)); + _pending_add(&_poll_on_opcode, buf, sizeof(uint32_t)); + } + else if (!strcmp(op_str, "poff")) + _pending_add(&_poll_off_opcode, NULL, 0); + else if (!strcmp(op_str, "evlogon")) + _pending_add(&_evlog_on_opcode, NULL, 0); + else if (!strcmp(op_str, "evlogoff")) + _pending_add(&_evlog_off_opcode, NULL, 0); + else if (!strcmp(op_str, "eo_list")) + _pending_add(&_eo_list_opcode, NULL, 0); + } + } + eina_debug_client_free(cl); +} + +static const Eina_Debug_Opcode ops[] = +{ + {"daemon/client_status_register", &_cl_stat_reg_opcode, _clients_info_cb}, + {"daemon/client_added", NULL, _clients_info_cb}, + {"daemon/client_deleted", NULL, _clients_info_deleted_cb}, + {"daemon/cid_from_pid", &_cid_from_pid_opcode, &_cid_get_cb}, + {"poll/on", &_poll_on_opcode, NULL}, + {"poll/off", &_poll_off_opcode, NULL}, + {"evlog/on", &_evlog_on_opcode, NULL}, + {"evlog/off", &_evlog_off_opcode, NULL}, + {"Eo/list", &_eo_list_opcode, &_objects_list_cb}, + {NULL, NULL, NULL} +}; + +EAPI_MAIN int +elm_main(int argc, char **argv) +{ + elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); + pub_widgets = gui_gui_get(); + + evas_object_show(pub_widgets->elm_win1->elm_win1); + + eina_init(); + + _session = eina_debug_session_new(); + if (!eina_debug_local_connect(_session)) + { + fprintf(stderr, "ERROR: Cannot connect to debug daemon.\n"); + goto error; + } + my_argc = argc; + my_argv = argv; + + eina_debug_opcodes_register(_session, ops, _args_handle); + + elm_run(); + +error: + eina_debug_session_free(_session); + eina_shutdown(); + + return 0; +} +ELM_MAIN() diff --git a/src/bin/gui b/src/bin/gui new file mode 100644 index 0000000..f7e6c5c --- /dev/null +++ b/src/bin/gui @@ -0,0 +1,116 @@ +{ + "JSON_Version":"1", + "Settings": + { + "project":"gui", + "start_points":["elm_win1"] + }, + "Widgets": + { + "elm_win1": + { + "Desc": + { + "parent":null, + "class":"Elm.Win", + "public":true + }, + "Properties": + { + "Elm.Win.type":["ELM_WIN_BASIC"], + "Elm.Widget.part_text":[null, "Window"], + "Efl.Gfx.Base.visible":[true], + "Elm.Win.autodel":[true], + "Efl.Gfx.Base.size":[478, 484] + }, + "Contains":["elm_bg1"] + }, + "elm_bg1": + { + "Desc": + { + "parent":"elm_win1", + "class":"Elm.Bg" + }, + "Properties": + { + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.position":[0, 0] + }, + "Contains": + { + "elm_box1":[null] + } + }, + "elm_box1": + { + "Desc": + { + "parent":"elm_bg1", + "class":"Elm.Box", + "public":true + }, + "Properties": + { + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[643, 598], + "Efl.Gfx.Base.position":[-7, -2], + "Elm.Box.padding":[0, 0], + "Elm.Box.align":[0, 0] + }, + "Contains":["elm_hoversel1", "elm_panes1"] + }, + "elm_hoversel1": + { + "Desc": + { + "parent":"elm_box1", + "class":"Elm.Hoversel", + "public":true + }, + "Properties": + { + "Elm.Widget.part_text":[null, "Hoversel"], + "Efl.Gfx.Base.visible":[true], + "Efl.Gfx.Base.size":[1174, 643], + "Efl.Gfx.Base.position":[-8, -2], + "Elm.Hoversel.horizontal":[false], + "Elm.Hoversel.auto_update":[true] + } + }, + "elm_panes1": + { + "Desc": + { + "parent":"elm_box1", + "class":"Elm.Panes" + }, + "Properties": + { + "Elm.Panes.content_right_size":[0.60], + "Efl.Gfx.Base.size":[75, 75], + "Efl.Gfx.Base.visible":[true], + "Evas.Object.size_hint_weight":[1, 1], + "Evas.Object.size_hint_align":[-1, -1] + }, + "Contains": + { + "elm_genlist1":["left"], + "__dummy":["right"] + } + }, + "elm_genlist1": + { + "Desc": + { + "parent":"elm_panes1", + "class":"Elm.Genlist", + "public":true + }, + "Properties": + { + "Efl.Gfx.Base.visible":[true] + } + } + } + } \ No newline at end of file diff --git a/src/bin/gui.c b/src/bin/gui.c new file mode 100644 index 0000000..096b59f --- /dev/null +++ b/src/bin/gui.c @@ -0,0 +1,89 @@ +#ifndef EFL_BETA_API_SUPPORT +#define EFL_BETA_API_SUPPORT +#endif +#ifndef EFL_EO_API_SUPPORT +#define EFL_EO_API_SUPPORT +#endif +#ifndef ELM_INTERNAL_API_ARGESFSDFEFC +#define ELM_INTERNAL_API_ARGESFSDFEFC +#endif +#include +#include "elm_widget_container.h" +#include "elm_interface_scrollable.h" +#include "elm_interface_fileselector.h" +#include "gui.h" + +static Gui_Widgets g_pub_widgets; + +static Eina_Bool +_pubs_free_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) +{ + free(data); + return EINA_TRUE; +} + +Gui_Elm_Win1_Widgets * +gui_elm_win1_create(Eo *__main_parent) +{ + Gui_Elm_Win1_Widgets *pub_widgets = calloc(1, sizeof(*pub_widgets)); + + Eo *elm_win1; + Eo *elm_bg1; + Eo *elm_box1; + Eo *elm_hoversel1; + Eo *elm_panes1; + Eo *elm_genlist1; + + + elm_win1 = eo_add(ELM_WIN_CLASS, __main_parent, elm_obj_win_type_set(ELM_WIN_BASIC)); + pub_widgets->elm_win1 = elm_win1; + eo_do(elm_win1, elm_obj_widget_part_text_set(NULL, "Window")); + eo_do(elm_win1, elm_obj_win_autodel_set(EINA_TRUE)); + eo_do(elm_win1, efl_gfx_size_set(478, 484)); + elm_bg1 = eo_add(ELM_BG_CLASS, elm_win1); + eo_do(elm_bg1, efl_gfx_visible_set(EINA_TRUE)); + eo_do(elm_bg1, efl_gfx_position_set(0, 0)); + eo_do(elm_win1, elm_obj_win_resize_object_add(elm_bg1)); + elm_box1 = eo_add(ELM_BOX_CLASS, elm_bg1); + pub_widgets->elm_box1 = elm_box1; + eo_do(elm_box1, efl_gfx_visible_set(EINA_TRUE)); + eo_do(elm_box1, efl_gfx_size_set(643, 598)); + eo_do(elm_box1, efl_gfx_position_set(-7, -2)); + eo_do(elm_box1, elm_obj_box_padding_set(0, 0)); + eo_do(elm_box1, elm_obj_box_align_set(0.000000, 0.000000)); + eo_do(elm_bg1, elm_obj_container_content_set(NULL, elm_box1)); + elm_hoversel1 = eo_add(ELM_HOVERSEL_CLASS, elm_box1); + pub_widgets->elm_hoversel1 = elm_hoversel1; + eo_do(elm_hoversel1, elm_obj_widget_part_text_set(NULL, "Hoversel")); + eo_do(elm_hoversel1, efl_gfx_visible_set(EINA_TRUE)); + eo_do(elm_hoversel1, efl_gfx_size_set(1174, 643)); + eo_do(elm_hoversel1, efl_gfx_position_set(-8, -2)); + eo_do(elm_hoversel1, elm_obj_hoversel_horizontal_set(EINA_FALSE)); + eo_do(elm_hoversel1, elm_obj_hoversel_auto_update_set(EINA_TRUE)); + elm_panes1 = eo_add(ELM_PANES_CLASS, elm_box1); + eo_do(elm_panes1, elm_obj_panes_content_right_size_set(0.600000)); + eo_do(elm_panes1, efl_gfx_size_set(75, 75)); + eo_do(elm_panes1, efl_gfx_visible_set(EINA_TRUE)); + eo_do(elm_panes1, evas_obj_size_hint_weight_set(1.000000, 1.000000)); + eo_do(elm_panes1, evas_obj_size_hint_align_set(-1.000000, -1.000000)); + eo_do(elm_box1, elm_obj_box_pack_end(elm_hoversel1)); + eo_do(elm_box1, elm_obj_box_pack_end(elm_panes1)); + elm_genlist1 = eo_add(ELM_GENLIST_CLASS, elm_panes1); + pub_widgets->elm_genlist1 = elm_genlist1; + eo_do(elm_genlist1, efl_gfx_visible_set(EINA_TRUE)); + eo_do(elm_win1, efl_gfx_visible_set(EINA_TRUE)); + eo_do(elm_win1, eo_event_callback_add(EO_BASE_EVENT_DEL, _pubs_free_cb, pub_widgets)); + + return pub_widgets; +} + +Gui_Widgets *gui_gui_get() +{ + static Eina_Bool initialized = EINA_FALSE; + if (!initialized) + { + g_pub_widgets.elm_win1 = gui_elm_win1_create(NULL); + initialized = EINA_TRUE; + } + return &g_pub_widgets; +} \ No newline at end of file diff --git a/src/bin/gui.h b/src/bin/gui.h new file mode 100644 index 0000000..798ebb1 --- /dev/null +++ b/src/bin/gui.h @@ -0,0 +1,22 @@ +#ifndef _gui_h_ +#define _gui_h_ +#include +#include + +typedef struct +{ + Eo *elm_win1; + Eo *elm_box1; + Eo *elm_hoversel1; + Eo *elm_genlist1; +} Gui_Elm_Win1_Widgets; + + +typedef struct { + Gui_Elm_Win1_Widgets *elm_win1; +} Gui_Widgets; + +Gui_Elm_Win1_Widgets *gui_elm_win1_create(Eo *parent); + +Gui_Widgets *gui_gui_get(); +#endif diff --git a/src/cmake/Modules/FindFfi.cmake b/src/cmake/Modules/FindFfi.cmake new file mode 100644 index 0000000..c9224d1 --- /dev/null +++ b/src/cmake/Modules/FindFfi.cmake @@ -0,0 +1,40 @@ +# - Try to find ffi +# Once done this will define +# FFI_FOUND - System has ffi +# FFI_INCLUDE_DIRS - The ffi include directories +# FFI_LIBRARIES - The libraries needed to use ffi +# FFI_LDFLAGS_OTHER - Other LDFLAGS needed te use ffi. +# FFI_DEFINITIONS - Compiler switches required for using ffi + +find_package(PkgConfig) +if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1") + # "QUIET" was introduced in 2.8.2 + set(_QUIET QUIET) +endif () +pkg_check_modules(PC_LIBFFI ${_QUIET} libffi) +#set(FFI_DEFINITIONS ${PC_LIBFFI_CFLAGS_OTHER}) +#set(FFI_LDFLAGS_OTHER ${PC_LIBFFI_LDFLAGS_OTHER}) + +# before verison 2.8.11 variable CMAKE_LIBRARY_ARCHITECTURE wasn't automatically added to search path +if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.11") + set(FIND_PATH_HINTS ${PC_LIBFFI_INCLUDEDIR}/${CMAKE_LIBRARY_ARCHITECTURE}) +endif () + +find_path(FFI_INCLUDE_DIR ffi.h + HINTS ${PC_LIBFFI_INCLUDEDIR} ${PC_LIBFFI_INCLUDE_DIRS} + ${FIND_PATH_HINTS} + ) + +find_library(FFI_LIBRARY NAMES ffi libffi + HINTS ${PC_LIBFFI_LIBDIR} ${PC_LIBFFI_LIBRARY_DIRS}) + +set(FFI_INCLUDE_DIRS ${FFI_INCLUDE_DIR}) +set(FFI_LIBRARIES ${FFI_LIBRARY}) + +#include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(ffi DEFAULT_MSG + FFI_LIBRARY) + +mark_as_advanced(FFI_INCLUDE_DIRS FFI_LIBRARY)