From 525d1e062975f732c54e40074d15500cdcaa4cb4 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 27 Jan 2017 12:38:52 -0200 Subject: [PATCH] cmake: add EFL_SUPPORT_LIB() and simplify/speedup its usage. generate a static library for src/static_libs and use that as LIBRARIES for the actual library, for those such as rg_etc that are used multiple times will even speed up the final build by compiling only once. Although not used, they can be made into shared libraries that would go inside /usr/lib/efl/support/v-1.19/libname.so --- CMakeLists.txt | 6 ++ cmake/helpers/EflMacros.cmake | 120 +++++++++++++++++++++ src/Makefile_Ector.am | 1 + src/Makefile_Evas.am | 1 + src/lib/ector/CMakeLists.txt | 29 +---- src/lib/eet/CMakeLists.txt | 9 +- src/lib/emile/CMakeLists.txt | 17 +-- src/static_libs/draw/CMakeLists.txt | 17 +++ src/static_libs/draw/draw.h | 3 +- src/static_libs/draw/draw_main.c | 1 - src/static_libs/draw/draw_main_sse2.c | 1 - src/static_libs/freetype/CMakeLists.txt | 5 + src/static_libs/lz4/CMakeLists.txt | 6 ++ src/static_libs/rg_etc/CMakeLists.txt | 10 ++ src/static_libs/triangulator/CMakeLists.txt | 18 ++++ src/static_libs/triangulator/triangulator_simple.h | 6 +- .../triangulator/triangulator_stroker.h | 4 +- 17 files changed, 200 insertions(+), 54 deletions(-) create mode 100644 src/static_libs/draw/CMakeLists.txt create mode 100644 src/static_libs/freetype/CMakeLists.txt create mode 100644 src/static_libs/lz4/CMakeLists.txt create mode 100644 src/static_libs/rg_etc/CMakeLists.txt create mode 100644 src/static_libs/triangulator/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b9cebbe..b3fe86b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,12 @@ include_directories( include(${CMAKE_SOURCE_DIR}/cmake/config/common.cmake) +EFL_SUPPORT_LIB(lz4) +EFL_SUPPORT_LIB(draw) +EFL_SUPPORT_LIB(freetype) +EFL_SUPPORT_LIB(rg_etc) +EFL_SUPPORT_LIB(triangulator) + EFL_LIB(eina) EFL_LIB(eolian) EFL_LIB(eo) diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake index 33811ba..a23c1e7 100644 --- a/cmake/helpers/EflMacros.cmake +++ b/cmake/helpers/EflMacros.cmake @@ -783,6 +783,126 @@ define_property(TARGET PROPERTY EFL_EO_PUBLIC BRIEF_DOCS "EFL's .eo/.eot files associated with this target and installed" FULL_DOCS "The list of all .eo or .eot files this target uses and installs") +# EFL_SUPPORT_LIB(Name) +# +# adds a support library as src/static_libs/${Name}, this will +# generate a static library that can be later referred by other +# targets using support-${Name} +# +# This is simiar to EFL_LIB(), however defaults to STATIC libraries +# and if set to SHARED will install to +# lib/efl/support/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} +# and it shouldn't set any PUBLIC_HEADERS or PKG_CONFIG_REQUIRES. +function(EFL_SUPPORT_LIB _target) + set(EFL_LIB_CURRENT ${_target}) + set(EFL_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/static_libs/${_target}) + set(EFL_LIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/static_libs/${_target}) + + set(DESCRIPTION) + set(PKG_CONFIG_REQUIRES) + set(PKG_CONFIG_REQUIRES_PRIVATE) + set(INCLUDE_DIRECTORIES) + set(SYSTEM_INCLUDE_DIRECTORIES) + set(OUTPUT_NAME) + set(SOURCES) + set(PUBLIC_HEADERS) + set(VERSION) + set(SOVERSION) + set(LIBRARY_TYPE STATIC) + set(OBJECT_DEPENDS) + set(DEPENDENCIES) + set(LIBRARIES) + set(PUBLIC_LIBRARIES) + set(DEFINITIONS) + set(COMPILE_FLAGS) + set(LINK_FLAGS) + + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config/${_target}.cmake OPTIONAL) + include(${EFL_LIB_SOURCE_DIR}/CMakeLists.txt) + + if(NOT SOURCES) + message(WARNING "${EFL_LIB_SOURCE_DIR}/CMakeLists.txt defines no SOURCES") + return() + endif() + if(PUBLIC_HEADERS) + message(WARNING "${EFL_LIB_SOURCE_DIR}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") + endif() + if(PKG_CONFIG_REQUIRES) + message(WARNING "${EFL_LIB_SOURCE_DIR}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead") + endif() + + EFL_FILES_TO_ABSOLUTE(_sources ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR} + ${SOURCES}) + EFL_FILES_TO_ABSOLUTE(_obj_deps ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR} + ${OBJECT_DEPENDS}) + + EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}") + + set(__link_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_LDFLAGS} ${LINK_FLAGS}) + set(__compile_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_CFLAGS} ${COMPILE_FLAGS}) + + set(_link_flags) + foreach(_l ${__link_flags}) + set(_link_flags "${_link_flags} ${_l}") + endforeach() + + set(_compile_flags) + foreach(_c ${__compile_flags}) + set(_compile_flags "${_compile_flags} ${_c}") + endforeach() + + add_library(support-${_target} ${LIBRARY_TYPE} ${_sources} ${_headers}) + set_target_properties(support-${_target} PROPERTIES + OBJECT_DEPENDS "${_obj_deps}" + LINK_FLAGS "${_link_flags}" + COMPILE_FLAGS "${_compile_flags}") + + if(DEPENDENCIES) + add_dependencies(support-${_target} ${DEPENDENCIES}) + endif() + + if(LIBRARIES) + target_link_libraries(support-${_target} LINK_PRIVATE ${LIBRARIES}) + endif() + if(PUBLIC_LIBRARIES) + target_link_libraries(support-${_target} PUBLIC ${PUBLIC_LIBRARIES}) + endif() + + target_include_directories(support-${_target} PUBLIC + ${INCLUDE_DIRECTORIES} + ${EFL_LIB_SOURCE_DIR} + ${EFL_LIB_BINARY_DIR} + ) + if(SYSTEM_INCLUDE_DIRECTORIES) + target_include_directories(support-${_target} SYSTEM PUBLIC ${SYSTEM_INCLUDE_DIRECTORIES}) + endif() + + if(DEFINITIONS) + target_compile_definitions(support-${_target} PRIVATE ${DEFINITIONS}) + endif() + + if(OUTPUT_NAME) + set_target_properties(support-${_target} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) + endif() + + if(VERSION AND SOVERSION) + set_target_properties(support-${_target} PROPERTIES + VERSION ${VERSION} + SOVERSION ${SOVERSION}) + endif() + + if(LIBRARY_TYPE STREQUAL "SHARED") + install(TARGETS support-${_target} + RUNTIME DESTINATION lib/efl/support/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + LIBRARY DESTINATION lib/efl/support/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) + else() + set_target_properties(support-${_target} PROPERTIES + POSITION_INDEPENDENT_CODE TRUE) + endif() + + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/post/${_target}.cmake OPTIONAL) +endfunction() + # EFL_LIB(Name) # # adds a library ${Name} automatically setting object/target diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 19053be..df6e6d2 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -155,6 +155,7 @@ lib/ector/gl/shader/ector_gl_shaders.x: $(ECTOR_GL_SHADERS_GEN) @sh $(srcdir)/lib/ector/gl/shader/gen_shaders.sh lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_builddir)/src/lib \ -I$(top_builddir)/src/lib/ector \ -I$(top_builddir)/src/lib/ector/cairo \ -I$(top_builddir)/src/lib/ector/software \ diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 620f6a0..2f58d5f 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -407,6 +407,7 @@ lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/static_libs/libunibreak \ -I$(top_srcdir)/src/static_libs/draw \ +-I$(top_builddir)/src/lib \ -I$(top_builddir)/src/lib/evas/canvas \ -I$(top_builddir)/src/lib/evas/include \ -I$(top_builddir)/src/modules/evas/engines/software_generic \ diff --git a/src/lib/ector/CMakeLists.txt b/src/lib/ector/CMakeLists.txt index 1339091..71daae7 100644 --- a/src/lib/ector/CMakeLists.txt +++ b/src/lib/ector/CMakeLists.txt @@ -5,6 +5,10 @@ set(LIBRARIES efl emile m + support-draw + support-freetype + support-rg_etc + support-triangulator ) set(PUBLIC_LIBRARIES @@ -99,31 +103,6 @@ set(SOURCES software/ector_software_gradient.c software/ector_software_rasterizer.c software/ector_software_surface.c - - ${CMAKE_SOURCE_DIR}/src/static_libs/draw/draw_main.c - ${CMAKE_SOURCE_DIR}/src/static_libs/draw/draw_main_neon.c - ${CMAKE_SOURCE_DIR}/src/static_libs/draw/draw_main_sse2.c - - ${CMAKE_SOURCE_DIR}/src/static_libs/freetype/sw_ft_math.c - ${CMAKE_SOURCE_DIR}/src/static_libs/freetype/sw_ft_raster.c - ${CMAKE_SOURCE_DIR}/src/static_libs/freetype/sw_ft_stroker.c - - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/etc2_encoder.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc1.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc1.h - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc2.c - - ${CMAKE_SOURCE_DIR}/src/static_libs/triangulator/triangulator_simple.c - ${CMAKE_SOURCE_DIR}/src/static_libs/triangulator/triangulator_simple.h - ${CMAKE_SOURCE_DIR}/src/static_libs/triangulator/triangulator_stroker.c - ${CMAKE_SOURCE_DIR}/src/static_libs/triangulator/triangulator_stroker.h -) - -set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/src/static_libs/draw - ${CMAKE_SOURCE_DIR}/src/static_libs/freetype - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc - ${CMAKE_SOURCE_DIR}/src/static_libs/triangulator ) add_custom_command( diff --git a/src/lib/eet/CMakeLists.txt b/src/lib/eet/CMakeLists.txt index b0aaffd..813f293 100644 --- a/src/lib/eet/CMakeLists.txt +++ b/src/lib/eet/CMakeLists.txt @@ -12,6 +12,7 @@ set(PUBLIC_LIBRARIES set(LIBRARIES m + support-rg_etc ) set(PUBLIC_HEADERS @@ -29,14 +30,6 @@ set(SOURCES eet_node.c Eet_private.h eet_utils.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc1.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc2.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/etc2_encoder.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc1.h -) - -set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc ) if(WITH_CRYPTO STREQUAL "gnutls") diff --git a/src/lib/emile/CMakeLists.txt b/src/lib/emile/CMakeLists.txt index 559f735..d6c3155 100644 --- a/src/lib/emile/CMakeLists.txt +++ b/src/lib/emile/CMakeLists.txt @@ -8,6 +8,7 @@ set(PKG_CONFIG_REQUIRES_PRIVATE set(LIBRARIES eina m + support-rg_etc ) set(PUBLIC_HEADERS @@ -24,14 +25,6 @@ set(SOURCES emile_image.c emile_main.c emile_private.h - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/etc2_encoder.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc1.c - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc1.h - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc/rg_etc2.c -) - -set(INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/src/static_libs/rg_etc ) if(WITH_CRYPTO STREQUAL "gnutls") @@ -47,11 +40,5 @@ endif() if(WITH_LZ4 STREQUAL "system") list(APPEND PKG_CONFIG_REQUIRES_PRIVATE liblz4) else() - list(APPEND SOURCES - ${CMAKE_SOURCE_DIR}/src/static_libs/lz4/lz4.c - ${CMAKE_SOURCE_DIR}/src/static_libs/lz4/lz4.h - ${CMAKE_SOURCE_DIR}/src/static_libs/lz4/lz4hc.c - ${CMAKE_SOURCE_DIR}/src/static_libs/lz4/lz4hc.h - ) - list(APPEND INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src/static_libs/lz4) + list(APPEND LIBRARIES support-lz4) endif() diff --git a/src/static_libs/draw/CMakeLists.txt b/src/static_libs/draw/CMakeLists.txt new file mode 100644 index 0000000..b2ad004 --- /dev/null +++ b/src/static_libs/draw/CMakeLists.txt @@ -0,0 +1,17 @@ +set(LIBRARIES + eina +) + +set(SOURCES + draw_main.c + draw_main_neon.c + draw_main_sse2.c +) + +set(INCLUDE_DIRECTORIES + ${CMAKE_BINARY_DIR}/src/lib +) + +set(DEPENDENCIES + efl-eo +) diff --git a/src/static_libs/draw/draw.h b/src/static_libs/draw/draw.h index b63b73d..9f4089a 100644 --- a/src/static_libs/draw/draw.h +++ b/src/static_libs/draw/draw.h @@ -5,7 +5,8 @@ # include #endif -#include +#include +#include "efl/interfaces/efl_gfx_types.eot.h" /* FIXME: naming convention */ typedef void (*RGBA_Comp_Func) (uint32_t *dest, const uint32_t *src, int length, uint32_t mul_col, uint32_t const_alpha); diff --git a/src/static_libs/draw/draw_main.c b/src/static_libs/draw/draw_main.c index 40b32e9..8577bea 100644 --- a/src/static_libs/draw/draw_main.c +++ b/src/static_libs/draw/draw_main.c @@ -2,7 +2,6 @@ #include "config.h" #endif -#include #include "draw_private.h" int _draw_log_dom = -1; diff --git a/src/static_libs/draw/draw_main_sse2.c b/src/static_libs/draw/draw_main_sse2.c index e8f9340..58ed7a3 100644 --- a/src/static_libs/draw/draw_main_sse2.c +++ b/src/static_libs/draw/draw_main_sse2.c @@ -2,7 +2,6 @@ #include "config.h" #endif -#include #include "draw_private.h" #ifdef BUILD_SSE3 diff --git a/src/static_libs/freetype/CMakeLists.txt b/src/static_libs/freetype/CMakeLists.txt new file mode 100644 index 0000000..5f669df --- /dev/null +++ b/src/static_libs/freetype/CMakeLists.txt @@ -0,0 +1,5 @@ +set(SOURCES + sw_ft_math.c + sw_ft_raster.c + sw_ft_stroker.c +) diff --git a/src/static_libs/lz4/CMakeLists.txt b/src/static_libs/lz4/CMakeLists.txt new file mode 100644 index 0000000..29bdb20 --- /dev/null +++ b/src/static_libs/lz4/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SOURCES + lz4.c + lz4.h + lz4hc.c + lz4hc.h +) diff --git a/src/static_libs/rg_etc/CMakeLists.txt b/src/static_libs/rg_etc/CMakeLists.txt new file mode 100644 index 0000000..2511bc1 --- /dev/null +++ b/src/static_libs/rg_etc/CMakeLists.txt @@ -0,0 +1,10 @@ +set(LIBRARIES + eina +) + +set(SOURCES + etc2_encoder.c + rg_etc1.c + rg_etc1.h + rg_etc2.c +) diff --git a/src/static_libs/triangulator/CMakeLists.txt b/src/static_libs/triangulator/CMakeLists.txt new file mode 100644 index 0000000..7818558 --- /dev/null +++ b/src/static_libs/triangulator/CMakeLists.txt @@ -0,0 +1,18 @@ +set(LIBRARIES + eina +) + +set(SOURCES + triangulator_simple.c + triangulator_simple.h + triangulator_stroker.c + triangulator_stroker.h +) + +set(INCLUDE_DIRECTORIES + ${CMAKE_BINARY_DIR}/src/lib +) + +set(DEPENDENCIES + efl-eo +) diff --git a/src/static_libs/triangulator/triangulator_simple.h b/src/static_libs/triangulator/triangulator_simple.h index e87acc6..e0c41f6 100644 --- a/src/static_libs/triangulator/triangulator_simple.h +++ b/src/static_libs/triangulator/triangulator_simple.h @@ -1,7 +1,9 @@ #ifndef TRIANGULATOR_SIMPLE_H_ #define TRIANGULATOR_SIMPLE_H_ -#include +#include +#include "efl/interfaces/efl_gfx_types.eot.h" +typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; typedef struct _Triangulator_Simple Triangulator_Simple; struct _Triangulator_Simple @@ -40,4 +42,4 @@ void triangulator_simple_free(Triangulator_Simple *st); */ void triangulator_simple_process(Triangulator_Simple *st, const Efl_Gfx_Path_Command *cmds, const double *pts, Eina_Bool convex); -#endif // #endif // TRIANGULATOR_SIMPLE_H_ \ No newline at end of file +#endif // #endif // TRIANGULATOR_SIMPLE_H_ diff --git a/src/static_libs/triangulator/triangulator_stroker.h b/src/static_libs/triangulator/triangulator_stroker.h index 5cc7805..2dee429 100644 --- a/src/static_libs/triangulator/triangulator_stroker.h +++ b/src/static_libs/triangulator/triangulator_stroker.h @@ -1,7 +1,9 @@ #ifndef TRIANGULATOR_STROKER_H_ #define TRIANGULATOR_STROKER_H_ -#include +#include +#include "efl/interfaces/efl_gfx_types.eot.h" +typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; typedef struct _Triangulator_Stroker Triangulator_Stroker; struct _Triangulator_Stroker -- 2.7.4