summaryrefslogtreecommitdiff
path: root/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
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')
-rw-r--r--cmake/config/common.cmake8
-rw-r--r--cmake/config/emile.cmake10
-rw-r--r--cmake/helpers/EflMacros.cmake102
3 files changed, 120 insertions, 0 deletions
diff --git a/cmake/config/common.cmake b/cmake/config/common.cmake
index 8a9ab4743e..d5e088d10d 100644
--- a/cmake/config/common.cmake
+++ b/cmake/config/common.cmake
@@ -8,6 +8,9 @@ find_package(Threads REQUIRED)
8pkg_check_modules(CHECK check) 8pkg_check_modules(CHECK check)
9pkg_check_modules(LIBSYSTEMD libsystemd) 9pkg_check_modules(LIBSYSTEMD libsystemd)
10pkg_check_modules(VALGRIND valgrind) 10pkg_check_modules(VALGRIND valgrind)
11pkg_check_modules(OPENSSL openssl>=1.0)
12pkg_check_modules(GNUTLS gnutls>=2.12.16)
13pkg_check_modules(LIBJPEG libjpeg REQUIRED)
11 14
12set(SUGGEST_VALGRIND OFF) 15set(SUGGEST_VALGRIND OFF)
13if("${BUILD_PROFILE}" STREQUAL "dev") 16if("${BUILD_PROFILE}" STREQUAL "dev")
@@ -23,6 +26,8 @@ if(NOT EFL_EO_API_SUPPORT)
23 EFL_OPTION_SET_MESSAGE(EFL_EO_API_SUPPORT "Risky!") 26 EFL_OPTION_SET_MESSAGE(EFL_EO_API_SUPPORT "Risky!")
24endif() 27endif()
25 28
29EFL_OPTION_BACKEND(WITH_CRYPTO "Choose crypto backend" OPENSSL GNUTLS)
30
26EFL_OPTION(ENABLE_SYSTEMD "Enable systemd support" "${LIBSYSTEMD_FOUND}" DEPENDS "LIBSYSTEMD_FOUND" OFF) 31EFL_OPTION(ENABLE_SYSTEMD "Enable systemd support" "${LIBSYSTEMD_FOUND}" DEPENDS "LIBSYSTEMD_FOUND" OFF)
27EFL_OPTION(ENABLE_VALGRIND "Enable valgrind support" "${SUGGEST_VALGRIND}" DEPENDS "VALGRIND_FOUND" OFF) 32EFL_OPTION(ENABLE_VALGRIND "Enable valgrind support" "${SUGGEST_VALGRIND}" DEPENDS "VALGRIND_FOUND" OFF)
28 33
@@ -33,6 +38,7 @@ HEADER_CHECK(asm/hwcap.h)
33HEADER_CHECK(dirent.h) 38HEADER_CHECK(dirent.h)
34HEADER_CHECK(execinfo.h) 39HEADER_CHECK(execinfo.h)
35HEADER_CHECK(mcheck.h) 40HEADER_CHECK(mcheck.h)
41HEADER_CHECK(netinet/in.h)
36HEADER_CHECK(stdlib.h) 42HEADER_CHECK(stdlib.h)
37HEADER_CHECK(sys/auxv.h) 43HEADER_CHECK(sys/auxv.h)
38HEADER_CHECK(sys/mman.h) 44HEADER_CHECK(sys/mman.h)
@@ -79,6 +85,8 @@ if(CMAKE_THREAD_LIBS_INIT)
79endif() 85endif()
80CHECK_APPEND_DEFINE(EFL_HAVE_THREADS "${EFL_HAVE_THREADS}") 86CHECK_APPEND_DEFINE(EFL_HAVE_THREADS "${EFL_HAVE_THREADS}")
81 87
88CHECK_APPEND_DEFINE(HAVE_CIPHER ${WITH_CRYPTO_ENABLED})
89CHECK_APPEND_DEFINE(HAVE_SIGNATURE ${WITH_CRYPTO_ENABLED})
82CHECK_APPEND_DEFINE(HAVE_SYSTEMD ${ENABLE_SYSTEMD}) 90CHECK_APPEND_DEFINE(HAVE_SYSTEMD ${ENABLE_SYSTEMD})
83 91
84CHECK_APPEND_DEFINE(MODULE_ARCH "\"v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}\"") 92CHECK_APPEND_DEFINE(MODULE_ARCH "\"v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}\"")
diff --git a/cmake/config/emile.cmake b/cmake/config/emile.cmake
new file mode 100644
index 0000000000..e8c7359cbb
--- /dev/null
+++ b/cmake/config/emile.cmake
@@ -0,0 +1,10 @@
1pkg_check_modules(LZ4 liblz4)
2
3set(_choices "internal")
4set(_defval "internal")
5if(LZ4_FOUND)
6 set(_choices system internal)
7 set(_defval system)
8endif()
9
10EFL_OPTION(WITH_LZ4 "Choose if system or internal liblz4 should be used" ${_defval} CHOICE ${_choices})
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()