summaryrefslogtreecommitdiff
path: root/cmake/helpers/EflMacros.cmake
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-23 18:13:03 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-23 18:23:40 +0100
commit71d6fcc0c459d5fe9335174d0942e8f33a603295 (patch)
treed7fce58a1c8ba9d22d0e06c97a1c7d18777fe029 /cmake/helpers/EflMacros.cmake
parent34074fd0e729760edaa4fad5aad943cf1b791aad (diff)
build: add eo files generation to the macros
this will generate eo.h eo.c rules for SOURCES and public eo files. This also installes the eo.h files from the public eo files into the include directory, and installes the eo files into the correct location
Diffstat (limited to 'cmake/helpers/EflMacros.cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake74
1 files changed, 71 insertions, 3 deletions
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index 9902a1df54..13e2493aa9 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -385,7 +385,7 @@ endfunction()
385# - INCLUDE_DIRECTORIES: results in target_include_directories 385# - INCLUDE_DIRECTORIES: results in target_include_directories
386# - SYSTEM_INCLUDE_DIRECTORIES: results in target_include_directories(SYSTEM) 386# - SYSTEM_INCLUDE_DIRECTORIES: results in target_include_directories(SYSTEM)
387# - OUTPUT_NAME 387# - OUTPUT_NAME
388# - SOURCES 388# - SOURCES source files that are needed, eo files can also be added here to be build
389# - PUBLIC_HEADERS 389# - PUBLIC_HEADERS
390# - VERSION (defaults to project version) 390# - VERSION (defaults to project version)
391# - SOVERSION (defaults to project major version) 391# - SOVERSION (defaults to project major version)
@@ -395,6 +395,7 @@ endfunction()
395# - LIBRARIES: results in target_link_libraries(LINK_PRIVATE) 395# - LIBRARIES: results in target_link_libraries(LINK_PRIVATE)
396# - PUBLIC_LIBRARIES: results in target_link_libraries(LINK_PUBLIC) 396# - PUBLIC_LIBRARIES: results in target_link_libraries(LINK_PUBLIC)
397# - DEFINITIONS: target_compile_definitions() 397# - DEFINITIONS: target_compile_definitions()
398# - PUBLIC_EO_FILES: the eo files will be used to build that lib, and will be installed to the filesystem
398# 399#
399# Defines the following variables that can be used within the included files: 400# Defines the following variables that can be used within the included files:
400# - EFL_LIB_CURRENT to ${Name} 401# - EFL_LIB_CURRENT to ${Name}
@@ -469,15 +470,26 @@ function(EFL_LIB _target)
469 message(FATAL_ERROR "Shared libraries must install public headers!") 470 message(FATAL_ERROR "Shared libraries must install public headers!")
470 endif() 471 endif()
471 472
473 #merge public eo files into sources
474 set(SOURCES ${SOURCES} ${PUBLIC_EO_FILES})
475
472 EFL_FILES_TO_ABSOLUTE(_headers ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR} 476 EFL_FILES_TO_ABSOLUTE(_headers ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
473 ${PUBLIC_HEADERS}) 477 ${PUBLIC_HEADERS})
474 EFL_FILES_TO_ABSOLUTE(_sources ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR} 478 EFL_FILES_TO_ABSOLUTE(_sources ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
475 ${SOURCES}) 479 ${SOURCES})
476 EFL_FILES_TO_ABSOLUTE(_obj_deps ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR} 480 EFL_FILES_TO_ABSOLUTE(_obj_deps ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
477 ${OBJECT_DEPENDS}) 481 ${OBJECT_DEPENDS})
482 EFL_FILES_TO_ABSOLUTE(_public_eo_files ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
483 ${PUBLIC_EO_FILES})
484
485 foreach(public_eo_file ${_public_eo_files})
486 get_filename_component(filename ${public_eo_file} NAME)
487 list(APPEND _headers ${EFL_LIB_BINARY_DIR}/${filename}.h)
488 endforeach()
478 489
479 EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}") 490 EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}")
480 491
492
481 add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers}) 493 add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers})
482 set_target_properties(${_target} PROPERTIES 494 set_target_properties(${_target} PROPERTIES
483 FRAMEWORK TRUE 495 FRAMEWORK TRUE
@@ -519,6 +531,8 @@ function(EFL_LIB _target)
519 SOVERSION ${SOVERSION}) 531 SOVERSION ${SOVERSION})
520 endif() 532 endif()
521 533
534 EFL_CREATE_EO_RULES(${_target} ${EFL_LIB_BINARY_DIR})
535
522 EFL_PKG_CONFIG_LIB_WRITE() 536 EFL_PKG_CONFIG_LIB_WRITE()
523 537
524 install(TARGETS ${_target} 538 install(TARGETS ${_target}
@@ -526,7 +540,9 @@ function(EFL_LIB _target)
526 RUNTIME DESTINATION bin 540 RUNTIME DESTINATION bin
527 ARCHIVE DESTINATION lib 541 ARCHIVE DESTINATION lib
528 LIBRARY DESTINATION lib) 542 LIBRARY DESTINATION lib)
529 543 install(FILES
544 ${_public_eo_files} DESTINATION share/eolian/include/${_target}-${PROJECT_VERSION_MAJOR}
545 )
530 # do not leak those into binaries, modules or tests 546 # do not leak those into binaries, modules or tests
531 unset(_sources) 547 unset(_sources)
532 unset(_headers) 548 unset(_headers)
@@ -879,4 +895,56 @@ macro(EFL_PROJECT version)
879 project(efl VERSION ${version}.${GIT_VERSION}) 895 project(efl VERSION ${version}.${GIT_VERSION})
880 endif ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") 896 endif ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
881 message("VERSION ${PROJECT_VERSION}") 897 message("VERSION ${PROJECT_VERSION}")
882endmacro() \ No newline at end of file 898endmacro()
899
900# Will use the source of the given target to create rules for creating
901# the .eo.c and .eo.h files. The INCLUDE_DIRECTORIES of the target will be used
902function(EFL_CREATE_EO_RULES target generation_dir)
903 get_target_property(build_files ${target} SOURCES)
904 get_target_property(_link_libraries ${target} LINK_LIBRARIES)
905 #build a list of targets we use to scan for all files
906 list(APPEND _include_targets ${target})
907 foreach(lib ${_link_libraries})
908 if (TARGET ${lib})
909 list(APPEND _include_targets ${lib})
910 endif()
911 endforeach()
912
913 #build a list of include directories
914 foreach(link_target ${_include_targets})
915 list(APPEND include_cmd -I${CMAKE_SOURCE_DIR}/src/lib/${link_target})
916 endforeach()
917
918 foreach(file ${build_files})
919 get_filename_component(ext ${file} EXT)
920 get_filename_component(filename ${file} NAME)
921
922 if (${ext} MATCHES "^\\.eo$")
923 set(build_files ${EFL_LIB_BINARY_DIR}/${filename}.c ${EFL_LIB_BINARY_DIR}/${filename}.h)
924 set(create_rule ON)
925 elseif (${ext} MATCHES "^\\.eot$")
926 set(build_files ${EFL_LIB_BINARY_DIR}/${filename}.h)
927 set(create_rule ON)
928 endif()
929
930 #add the custom rule
931 if (create_rule)
932 message("CREATE CUSTOM COMMAND FOR ${build_files}")
933 add_custom_command(
934 OUTPUT ${build_files}
935 COMMAND ${CMAKE_COMMAND} -E env "EFL_RUN_IN_TREE=1" ${EOLIAN_BIN} ${include_cmd} -o c:${EFL_LIB_BINARY_DIR}/${filename}.c -o h:${EFL_LIB_BINARY_DIR}/${filename}.h ${file}
936 DEPENDS ${file}
937 )
938 unset(create_rule)
939 list(APPEND eo_gen_files ${build_files})
940 endif()
941 endforeach()
942 if(eo_gen_files)
943 file(MAKE_DIRECTORY ${EFL_LIB_BINARY_DIR})
944 add_custom_target(${target}-eo
945 DEPENDS ${eo_gen_files}
946 )
947 add_dependencies(${target} ${target}-eo)
948 add_dependencies(${target} eolian-bin)
949 endif()
950endfunction()