summaryrefslogtreecommitdiff
path: root/cmake/helpers/EflMacros.cmake
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-21 10:20:18 -0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-23 18:23:40 +0100
commit8df6ac453d71409f767de147726087b22969c2bf (patch)
tree12c600a7e0c8b7d4b13c95385dfe44b6da59557f /cmake/helpers/EflMacros.cmake
parent308c8c4ef76f185aac577073ad22e827f0b44964 (diff)
EflMacros: automatically provide ON;OFF;STATIC option and defines.
Automatically create one option to enable, disable or make it statically linked into the code, with a define to reflect build type.
Diffstat (limited to 'cmake/helpers/EflMacros.cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index 2042c73a4a..9902a1df54 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -778,11 +778,21 @@ function(EFL_MODULE _modname)
778 set(_modoutdir lib/${EFL_LIB_CURRENT}/modules/${EFL_MODULE_SCOPE}/${_modname}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) 778 set(_modoutdir lib/${EFL_LIB_CURRENT}/modules/${EFL_MODULE_SCOPE}/${_modname}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
779 set(_modbindir ${EFL_MODULES_BINARY_DIR}/${EFL_MODULE_SCOPE}/${_modname}) 779 set(_modbindir ${EFL_MODULES_BINARY_DIR}/${EFL_MODULE_SCOPE}/${_modname})
780 set(_modtarget ${EFL_LIB_CURRENT}-module-${EFL_MODULE_SCOPE}-${_modname}) 780 set(_modtarget ${EFL_LIB_CURRENT}-module-${EFL_MODULE_SCOPE}-${_modname})
781 string(TOUPPER "${EFL_LIB_CURRENT}_MODULE_TYPE_${EFL_MODULE_SCOPE}_${_modname}" _modoptionname)
782 if(NOT ${_modoptionname}_DEFAULT)
783 set(${_modoptionname}_DEFAULT "ON")
784 endif()
785 EFL_OPTION(${_modoptionname} "Build ${EFL_LIB_CURRENT} module ${EFL_MODULE_SCOPE}/${_modname}" ${${_modoptionname}_DEFAULT} CHOICE ON;OFF;STATIC)
781 else() 786 else()
782 set(_modsrcdir ${EFL_MODULES_SOURCE_DIR}/${_modname}) 787 set(_modsrcdir ${EFL_MODULES_SOURCE_DIR}/${_modname})
783 set(_modoutdir lib/${EFL_LIB_CURRENT}/modules/${_modname}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) 788 set(_modoutdir lib/${EFL_LIB_CURRENT}/modules/${_modname}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
784 set(_modbindir ${EFL_MODULES_BINARY_DIR}/${_modname}) 789 set(_modbindir ${EFL_MODULES_BINARY_DIR}/${_modname})
785 set(_modtarget ${EFL_LIB_CURRENT}-module-${_modname}) 790 set(_modtarget ${EFL_LIB_CURRENT}-module-${_modname})
791 string(TOUPPER "${EFL_LIB_CURRENT}_MODULE_TYPE_${_modname}" _modoptionname)
792 if(NOT ${_modoptionname}_DEFAULT)
793 set(${_modoptionname}_DEFAULT "ON")
794 endif()
795 EFL_OPTION(${_modoptionname} "Build ${EFL_LIB_CURRENT} module ${_modname}" ${${_modoptionname}_DEFAULT} CHOICE ON;OFF;STATIC)
786 endif() 796 endif()
787 797
788 set(SOURCES) 798 set(SOURCES)
@@ -791,7 +801,7 @@ function(EFL_MODULE _modname)
791 set(INCLUDE_DIRECTORIES) 801 set(INCLUDE_DIRECTORIES)
792 set(SYSTEM_INCLUDE_DIRECTORIES) 802 set(SYSTEM_INCLUDE_DIRECTORIES)
793 set(DEFINITIONS) 803 set(DEFINITIONS)
794 set(MODULE_TYPE "ON") 804 set(MODULE_TYPE "${${_modoptionname}}")
795 set(INSTALL_DIR ${_modoutdir}) 805 set(INSTALL_DIR ${_modoutdir})
796 806
797 _EFL_INCLUDE_OR_DETECT("Module ${_modtarget}" ${_modsrcdir}) 807 _EFL_INCLUDE_OR_DETECT("Module ${_modtarget}" ${_modsrcdir})
@@ -838,6 +848,7 @@ function(EFL_MODULE _modname)
838 848
839 if("${MODULE_TYPE}" STREQUAL "STATIC") 849 if("${MODULE_TYPE}" STREQUAL "STATIC")
840 target_link_libraries(${EFL_LIB_CURRENT} LINK_PRIVATE ${_modtarget}) 850 target_link_libraries(${EFL_LIB_CURRENT} LINK_PRIVATE ${_modtarget})
851 target_compile_definitions(${EFL_LIB_CURRENT} PRIVATE "-D${_modoptionname}_STATIC=1")
841 target_include_directories(${_modtarget} PRIVATE 852 target_include_directories(${_modtarget} PRIVATE
842 ${EFL_LIB_SOURCE_DIR} 853 ${EFL_LIB_SOURCE_DIR}
843 ${EFL_LIB_BINARY_DIR}) 854 ${EFL_LIB_BINARY_DIR})
@@ -847,6 +858,7 @@ function(EFL_MODULE _modname)
847 LIST_APPEND_GLOBAL(${EFL_LIB_CURRENT}_STATIC_MODULES ${_modtarget}) 858 LIST_APPEND_GLOBAL(${EFL_LIB_CURRENT}_STATIC_MODULES ${_modtarget})
848 else() 859 else()
849 target_link_libraries(${_modtarget} LINK_PRIVATE ${EFL_LIB_CURRENT}) 860 target_link_libraries(${_modtarget} LINK_PRIVATE ${EFL_LIB_CURRENT})
861 target_compile_definitions(${EFL_LIB_CURRENT} PRIVATE "-D${_modoptionname}_DYNAMIC=1")
850 LIST_APPEND_GLOBAL(${EFL_LIB_CURRENT}_MODULES ${_modtarget}) 862 LIST_APPEND_GLOBAL(${EFL_LIB_CURRENT}_MODULES ${_modtarget})
851 if(INSTALL_DIR) 863 if(INSTALL_DIR)
852 install(TARGETS ${_modtarget} LIBRARY DESTINATION "${INSTALL_DIR}") 864 install(TARGETS ${_modtarget} LIBRARY DESTINATION "${INSTALL_DIR}")