summaryrefslogtreecommitdiff
path: root/cmake/helpers/EflMacros.cmake
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-26 13:13:51 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-26 14:23:24 -0200
commitb67acda0d626bde9235d49b4ca045e083db855a2 (patch)
tree6f0f92c178d1b0460b4f695c34b1f47ee5d55b6c /cmake/helpers/EflMacros.cmake
parent8de264f597ba28dea688dfe318dc2e863cc76f4f (diff)
cmake: add emile and EFL_OPTION_BACKEND()
Add emile and with that EFL_OPTION_BACKEND() to support choosing among different backends for something, in emile's case it's crypto backend (gnutls, openssl or none).
Diffstat (limited to 'cmake/helpers/EflMacros.cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake102
1 files changed, 102 insertions, 0 deletions
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index c081ed1120..b2630a8a07 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -28,6 +28,59 @@ unset(EFL_ALL_LIBS CACHE)
28unset(EFL_ALL_TESTS CACHE) 28unset(EFL_ALL_TESTS CACHE)
29unset(EFL_PKG_CONFIG_MISSING_OPTIONAL CACHE) 29unset(EFL_PKG_CONFIG_MISSING_OPTIONAL CACHE)
30 30
31# EFL_OPTION_BACKEND(Name Help Backend1 ... BackendN
32# [DEPENDS "COND1; COND2; NOT COND3" FAILED_VALUE]
33# [REQUIRED])
34#
35# Wrapper around EFL_OPTION() and EFL_BACKEND_CHOICES()
36# that creates an option 'CHOICE' within possible backends
37# when these are found (${Backend}_FOUND).
38#
39# The REQUIRED keyword will force a valid backend, otherwise 'none' is
40# allowed.
41#
42# If a backend was chose, then ${Name}_CFLAGS and ${Name}_LDFLAGS are
43# set to lists based on ${Backend}_CFLAGS or
44# ${Backend}_INCLUDE_DIR/${Backend}_INCLUDE_DIRS and
45# ${Backend}_LDFLAGS or ${Backend}_LIBRARIES
46function(EFL_OPTION_BACKEND _name _help)
47 cmake_parse_arguments(PARAMS "" "" "DEPENDS" ${ARGN})
48
49 EFL_BACKEND_CHOICES(${_name} ${PARAMS_UNPARSED_ARGUMENTS})
50
51 EFL_OPTION(${_name} "${_help}" "${${_name}_DEFAULT}"
52 CHOICE ${${_name}_CHOICES}
53 DEPENDS ${PARAMS_DEPENDS})
54
55 if(NOT ${_name} STREQUAL "none")
56 string(TOUPPER "${${_name}}" _backend)
57 if(DEFINED ${_backend}_CFLAGS)
58 set(_cflags ${${_backend}_CFLAGS})
59 else()
60 set(_cflags "")
61 foreach(_d ${${_backend}_INCLUDE_DIR} ${${_backend}_INCLUDE_DIRS})
62 list(APPEND _cflags "-I${_d}")
63 endforeach()
64 endif()
65 if(DEFINED ${_backend}_LDFLAGS)
66 set(_ldflags ${${_backend}_LDFLAGS})
67 else()
68 set(_ldflags "")
69 foreach(_d ${${_backend}_LIBRARIES})
70 list(APPEND _ldflags "-l${_d}")
71 endforeach()
72 else()
73 endif()
74 SET_GLOBAL(${_name}_CFLAGS "${_cflags}")
75 SET_GLOBAL(${_name}_LDFLAGS "${_ldflags}")
76 SET_GLOBAL(${_name}_ENABLED ON)
77 else()
78 unset(${_name}_CFLAGS CACHE)
79 unset(${_name}_LDFLAGS CACHE)
80 SET_GLOBAL(${_name}_ENABLED OFF)
81 endif()
82endfunction()
83
31# EFL_OPTION(Name Help Default [STRING|BOOL|FILEPATH|PATH] 84# EFL_OPTION(Name Help Default [STRING|BOOL|FILEPATH|PATH]
32# [CHOICE c1;...;cN] 85# [CHOICE c1;...;cN]
33# [DEPENDS "COND1; COND2; NOT COND3" FAILED_VALUE]) 86# [DEPENDS "COND1; COND2; NOT COND3" FAILED_VALUE])
@@ -441,6 +494,21 @@ function(EFL_PKG_CONFIG_EVAL_TO _var _name)
441 endif() 494 endif()
442 endif() 495 endif()
443 endforeach() 496 endforeach()
497
498 unset(${_var}_CFLAGS CACHE)
499 unset(${_var}_LDFLAGS CACHE)
500 unset(PKG_CONFIG_${_var} CACHE)
501 unset(PKG_CONFIG_${_var}_CFLAGS CACHE)
502 unset(PKG_CONFIG_${_var}_FOUND CACHE)
503 unset(PKG_CONFIG_${_var}_INCLUDE_DIRS CACHE)
504 unset(PKG_CONFIG_${_var}_INCLUDEDIR CACHE)
505 unset(PKG_CONFIG_${_var}_LDFLAGS CACHE)
506 unset(PKG_CONFIG_${_var}_LIBDIR CACHE)
507 unset(PKG_CONFIG_${_var}_LIBRARIES CACHE)
508 unset(PKG_CONFIG_${_var}_LIBRARIES CACHE)
509 unset(PKG_CONFIG_${_var}_LIBRARIES_DIR CACHE)
510 unset(PKG_CONFIG_${_var}_LIBS CACHE)
511 unset(PKG_CONFIG_${_var}_VERSION CACHE)
444 if(NOT _missing) 512 if(NOT _missing)
445 SET_GLOBAL(${_var} "${_found}") 513 SET_GLOBAL(${_var} "${_found}")
446 SET_GLOBAL(${_var}_MISSING "${_missing_optional}") 514 SET_GLOBAL(${_var}_MISSING "${_missing_optional}")
@@ -1380,3 +1448,37 @@ function(EFL_CREATE_EO_RULES target source_dir generation_dir)
1380 endif() 1448 endif()
1381 endif() 1449 endif()
1382endfunction() 1450endfunction()
1451
1452# EFL_BACKEND_CHOICES(Prefix Choice1 .. ChoiceN)
1453#
1454# Helper that will check ${ChoiceN}_FOUND and if so append to
1455# ${_prefix}_CHOICES as well set the first found option (in order!) as
1456# ${_prefix}_DEFAULT and ${_prefix}_FOUND to ON if at least one was
1457# found.
1458function(EFL_BACKEND_CHOICES _prefix)
1459 cmake_parse_arguments(PARAMS "REQUIRED" "" "" ${ARGN})
1460
1461 set(_choices "")
1462 set(_defval "none")
1463 set(_found OFF)
1464 foreach(c ${PARAMS_UNPARSED_ARGUMENTS})
1465 if(${c}_FOUND)
1466 string(TOLOWER "${c}" c_lc)
1467 if(_defval STREQUAL "none")
1468 set(_defval ${c_lc})
1469 endif()
1470 set(_found ON)
1471 list(APPEND _choices ${c_lc})
1472 endif()
1473 endforeach()
1474
1475 if(PARAMS_REQUIRED AND NOT _found)
1476 message(FATAL_ERROR "${_prefix} backend was required (one of ${PARAMS_UNPARSED_ARGUMENTS}) but none was found!")
1477 elseif(NOT PARAMS_REQUIRED)
1478 list(APPEND _choices "none")
1479 endif()
1480
1481 set(${_prefix}_FOUND ${_found} PARENT_SCOPE)
1482 set(${_prefix}_CHOICES ${_choices} PARENT_SCOPE)
1483 set(${_prefix}_DEFAULT ${_defval} PARENT_SCOPE)
1484endfunction()