summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-27 12:38:52 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-27 12:52:14 -0200
commit525d1e062975f732c54e40074d15500cdcaa4cb4 (patch)
treeb074fd0fef65f756ebbe2d5993313cbafcb882bc /cmake
parent28960d78513f95204a75e86af817efb3a343e6b0 (diff)
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
Diffstat (limited to 'cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake120
1 files changed, 120 insertions, 0 deletions
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index 33811ba17b..a23c1e7091 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -783,6 +783,126 @@ define_property(TARGET PROPERTY EFL_EO_PUBLIC
783 BRIEF_DOCS "EFL's .eo/.eot files associated with this target and installed" 783 BRIEF_DOCS "EFL's .eo/.eot files associated with this target and installed"
784 FULL_DOCS "The list of all .eo or .eot files this target uses and installs") 784 FULL_DOCS "The list of all .eo or .eot files this target uses and installs")
785 785
786# EFL_SUPPORT_LIB(Name)
787#
788# adds a support library as src/static_libs/${Name}, this will
789# generate a static library that can be later referred by other
790# targets using support-${Name}
791#
792# This is simiar to EFL_LIB(), however defaults to STATIC libraries
793# and if set to SHARED will install to
794# lib/efl/support/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
795# and it shouldn't set any PUBLIC_HEADERS or PKG_CONFIG_REQUIRES.
796function(EFL_SUPPORT_LIB _target)
797 set(EFL_LIB_CURRENT ${_target})
798 set(EFL_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/static_libs/${_target})
799 set(EFL_LIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/static_libs/${_target})
800
801 set(DESCRIPTION)
802 set(PKG_CONFIG_REQUIRES)
803 set(PKG_CONFIG_REQUIRES_PRIVATE)
804 set(INCLUDE_DIRECTORIES)
805 set(SYSTEM_INCLUDE_DIRECTORIES)
806 set(OUTPUT_NAME)
807 set(SOURCES)
808 set(PUBLIC_HEADERS)
809 set(VERSION)
810 set(SOVERSION)
811 set(LIBRARY_TYPE STATIC)
812 set(OBJECT_DEPENDS)
813 set(DEPENDENCIES)
814 set(LIBRARIES)
815 set(PUBLIC_LIBRARIES)
816 set(DEFINITIONS)
817 set(COMPILE_FLAGS)
818 set(LINK_FLAGS)
819
820 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config/${_target}.cmake OPTIONAL)
821 include(${EFL_LIB_SOURCE_DIR}/CMakeLists.txt)
822
823 if(NOT SOURCES)
824 message(WARNING "${EFL_LIB_SOURCE_DIR}/CMakeLists.txt defines no SOURCES")
825 return()
826 endif()
827 if(PUBLIC_HEADERS)
828 message(WARNING "${EFL_LIB_SOURCE_DIR}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.")
829 endif()
830 if(PKG_CONFIG_REQUIRES)
831 message(WARNING "${EFL_LIB_SOURCE_DIR}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead")
832 endif()
833
834 EFL_FILES_TO_ABSOLUTE(_sources ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
835 ${SOURCES})
836 EFL_FILES_TO_ABSOLUTE(_obj_deps ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
837 ${OBJECT_DEPENDS})
838
839 EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}")
840
841 set(__link_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_LDFLAGS} ${LINK_FLAGS})
842 set(__compile_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_CFLAGS} ${COMPILE_FLAGS})
843
844 set(_link_flags)
845 foreach(_l ${__link_flags})
846 set(_link_flags "${_link_flags} ${_l}")
847 endforeach()
848
849 set(_compile_flags)
850 foreach(_c ${__compile_flags})
851 set(_compile_flags "${_compile_flags} ${_c}")
852 endforeach()
853
854 add_library(support-${_target} ${LIBRARY_TYPE} ${_sources} ${_headers})
855 set_target_properties(support-${_target} PROPERTIES
856 OBJECT_DEPENDS "${_obj_deps}"
857 LINK_FLAGS "${_link_flags}"
858 COMPILE_FLAGS "${_compile_flags}")
859
860 if(DEPENDENCIES)
861 add_dependencies(support-${_target} ${DEPENDENCIES})
862 endif()
863
864 if(LIBRARIES)
865 target_link_libraries(support-${_target} LINK_PRIVATE ${LIBRARIES})
866 endif()
867 if(PUBLIC_LIBRARIES)
868 target_link_libraries(support-${_target} PUBLIC ${PUBLIC_LIBRARIES})
869 endif()
870
871 target_include_directories(support-${_target} PUBLIC
872 ${INCLUDE_DIRECTORIES}
873 ${EFL_LIB_SOURCE_DIR}
874 ${EFL_LIB_BINARY_DIR}
875 )
876 if(SYSTEM_INCLUDE_DIRECTORIES)
877 target_include_directories(support-${_target} SYSTEM PUBLIC ${SYSTEM_INCLUDE_DIRECTORIES})
878 endif()
879
880 if(DEFINITIONS)
881 target_compile_definitions(support-${_target} PRIVATE ${DEFINITIONS})
882 endif()
883
884 if(OUTPUT_NAME)
885 set_target_properties(support-${_target} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
886 endif()
887
888 if(VERSION AND SOVERSION)
889 set_target_properties(support-${_target} PROPERTIES
890 VERSION ${VERSION}
891 SOVERSION ${SOVERSION})
892 endif()
893
894 if(LIBRARY_TYPE STREQUAL "SHARED")
895 install(TARGETS support-${_target}
896 RUNTIME DESTINATION lib/efl/support/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
897 LIBRARY DESTINATION lib/efl/support/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
898 else()
899 set_target_properties(support-${_target} PROPERTIES
900 POSITION_INDEPENDENT_CODE TRUE)
901 endif()
902
903 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/post/${_target}.cmake OPTIONAL)
904endfunction()
905
786# EFL_LIB(Name) 906# EFL_LIB(Name)
787# 907#
788# adds a library ${Name} automatically setting object/target 908# adds a library ${Name} automatically setting object/target