summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 13c00795d680377c2409e52ac18a2b6f03080422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
cmake_minimum_required(VERSION 2.8.3)
project(FASTD C)

set(CMAKE_MODULE_PATH ${FASTD_SOURCE_DIR})

find_package(BISON 2.5 REQUIRED)
find_package(FLEX REQUIRED)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
if(NOT CMAKE_USE_PTHREADS_INIT)
  MESSAGE(FATAL_ERROR "No pthread support found.")
endif(NOT CMAKE_USE_PTHREADS_INIT)

find_package(PkgConfig REQUIRED)
pkg_check_modules(UECC REQUIRED libuecc>=2)

find_package(NaCl REQUIRED)


set(WITH_CRYPTO_AES128CTR_NACL TRUE CACHE BOOL "Include the AES128-CTR implementation from the NaCl library")
set(WITH_CRYPTO_AES128CTR_LINUX TRUE CACHE BOOL "Support using the AES128-CTR implementation in the Linux kernel")

set(WITH_CRYPTO_GHASH_BUILTIN TRUE CACHE BOOL "Include the built-in GHASH implementation")
set(WITH_CRYPTO_GHASH_LINUX TRUE CACHE BOOL "Support using the GHASH implementation in the Linux kernel")

set(WITH_METHOD_XSALSA20_POLY1305 TRUE CACHE BOOL "Include xsalsa20-poly1305 method")
set(WITH_METHOD_AES128_GCM TRUE CACHE BOOL "Include aes128-gcm method")

set(MAX_CONFIG_DEPTH 10 CACHE STRING "Maximum config include depth")

if(WITH_CRYPTO_AES128CTR_NACL OR WITH_CRYPTO_AES128CTR_LINUX)
  set(WITH_CRYPTO_AES128CTR TRUE)
endif(WITH_CRYPTO_AES128CTR_NACL OR WITH_CRYPTO_AES128CTR_LINUX)

if(WITH_CRYPTO_GHASH_BUILTIN OR WITH_CRYPTO_GHASH_LINUX)
  set(WITH_CRYPTO_GHASH TRUE)
endif(WITH_CRYPTO_GHASH_BUILTIN OR WITH_CRYPTO_GHASH_LINUX)


# Ensure the value is numeric
math(EXPR MAX_CONFIG_DEPTH_NUM ${MAX_CONFIG_DEPTH})

set(USE_CRYPTO_AES128CTR FALSE)
set(USE_CRYPTO_GHASH FALSE)

if(WITH_METHOD_AES128_GCM)
  set(USE_CRYPTO_AES128CTR TRUE)
  set(USE_CRYPTO_GHASH TRUE)
endif(WITH_METHOD_AES128_GCM)


if(USE_CRYPTO_AES128CTR AND NOT WITH_CRYPTO_AES128CTR)
  MESSAGE(FATAL_ERROR "No AES128-CTR implementation was selected, but a selected method needs it.")
endif(USE_CRYPTO_AES128CTR AND NOT WITH_CRYPTO_AES128CTR)

if(USE_CRYPTO_GHASH AND NOT WITH_CRYPTO_GHASH)
  MESSAGE(FATAL_ERROR "No GHASH implementation was selected, but a selected method needs it.")
endif(USE_CRYPTO_GHASH AND NOT WITH_CRYPTO_GHASH)


configure_file(${FASTD_SOURCE_DIR}/config.h.in ${FASTD_BINARY_DIR}/config.h)

add_subdirectory(src)