summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-24 17:13:27 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-24 17:13:27 +0100
commit9eac618a73006c9c74f79695d94a4ed305583c39 (patch)
treeabb4f9c747eb951aa6c1e8322914d53db6d145fa
parent9ef4d441ad91ebcbc68bdae309122f128ed69f56 (diff)
downloadfastd-9eac618a73006c9c74f79695d94a4ed305583c39.tar
fastd-9eac618a73006c9c74f79695d94a4ed305583c39.zip
Make build dependencies more configurable
-rw-r--r--cmake/FindCAP.cmake16
-rw-r--r--cmake/FindJSON_C.cmake24
-rw-r--r--cmake/Findlibcap.cmake18
-rw-r--r--cmake/Findlibsodium.cmake24
-rw-r--r--cmake/Findlibuecc.cmake24
-rw-r--r--cmake/deps.cmake67
-rw-r--r--src/CMakeLists.txt9
-rw-r--r--src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt2
-rw-r--r--src/crypto/cipher/aes128_ctr/openssl/CMakeLists.txt2
-rw-r--r--src/crypto/cipher/salsa20/nacl/CMakeLists.txt2
-rw-r--r--src/crypto/cipher/salsa2012/nacl/CMakeLists.txt2
-rw-r--r--src/methods/generic_poly1305/CMakeLists.txt2
-rw-r--r--src/methods/xsalsa20_poly1305/CMakeLists.txt2
-rw-r--r--src/protocols/ec25519_fhmqvc/CMakeLists.txt3
14 files changed, 128 insertions, 69 deletions
diff --git a/cmake/FindCAP.cmake b/cmake/FindCAP.cmake
deleted file mode 100644
index 80afff3..0000000
--- a/cmake/FindCAP.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-FIND_PATH(CAP_INCLUDE_DIR sys/capability.h)
-FIND_LIBRARY(CAP_LIBRARY NAMES cap)
-
-IF (CAP_INCLUDE_DIR AND CAP_LIBRARY)
- SET(CAP_FOUND TRUE)
-ENDIF (CAP_INCLUDE_DIR AND CAP_LIBRARY)
-
-IF (CAP_FOUND)
- IF (NOT CAP_FIND_QUIETLY)
- MESSAGE(STATUS "Found libcap: ${CAP_LIBRARY}; include path: ${CAP_INCLUDE_DIR}")
- ENDIF (NOT CAP_FIND_QUIETLY)
-ELSE (CAP_FOUND)
- IF (CAP_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find libcap")
- ENDIF (CAP_FIND_REQUIRED)
-ENDIF (CAP_FOUND)
diff --git a/cmake/FindJSON_C.cmake b/cmake/FindJSON_C.cmake
new file mode 100644
index 0000000..e31a8b9
--- /dev/null
+++ b/cmake/FindJSON_C.cmake
@@ -0,0 +1,24 @@
+# Defines the following variables:
+# JSON_C_FOUND
+# JSON_C_INCLUDE_DIR
+# JSON_C_LIBRARIES
+# JSON_C_CFLAGS_OTHER
+# JSON_C_LDFLAGS_OTHER
+
+
+if(ANDROID)
+ find_host_package(PkgConfig REQUIRED QUIET)
+else(ANDROID)
+ find_package(PkgConfig REQUIRED QUIET)
+endif(ANDROID)
+
+pkg_check_modules(_JSON_C json-c)
+
+find_path(JSON_C_INCLUDE_DIR NAMES json-c/json.h HINTS ${_JSON_C_INCLUDE_DIRS})
+find_library(JSON_C_LIBRARIES NAMES json-c HINTS ${_JSON_C_LIBRARY_DIRS})
+
+set(JSON_C_CFLAGS_OTHER "${_JSON_C_CFLAGS_OTHER}" CACHE STRING "Additional compiler flags for json-c")
+set(JSON_C_LDFLAGS_OTHER "${_JSON_C_LDFLAGS_OTHER}" CACHE STRING "Additional linker flags for json-c")
+
+find_package_handle_standard_args(JSON_C REQUIRED_VARS JSON_C_LIBRARIES JSON_C_INCLUDE_DIR)
+mark_as_advanced(JSON_C_INCLUDE_DIR JSON_C_LIBRARIES JSON_C_CFLAGS_OTHER JSON_C_LDFLAGS_OTHER)
diff --git a/cmake/Findlibcap.cmake b/cmake/Findlibcap.cmake
new file mode 100644
index 0000000..3a16af1
--- /dev/null
+++ b/cmake/Findlibcap.cmake
@@ -0,0 +1,18 @@
+FIND_PATH(LIBCAP_INCLUDE_DIR sys/capability.h)
+FIND_LIBRARY(LIBCAP_LIBRARY NAMES cap)
+
+IF (LIBCAP_INCLUDE_DIR AND LIBCAP_LIBRARY)
+ SET(LIBCAP_FOUND TRUE)
+ENDIF (LIBCAP_INCLUDE_DIR AND LIBCAP_LIBRARY)
+
+IF (LIBCAP_FOUND)
+ IF (NOT LIBCAP_FIND_QUIETLY)
+ MESSAGE(STATUS "Found libcap: ${LIBCAP_LIBRARY}; include path: ${LIBCAP_INCLUDE_DIR}")
+ ENDIF (NOT LIBCAP_FIND_QUIETLY)
+ELSE (LIBCAP_FOUND)
+ IF (LIBCAP_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find libcap")
+ ENDIF (LIBCAP_FIND_REQUIRED)
+ENDIF (LIBCAP_FOUND)
+
+mark_as_advanced(LIBCAP_INCLUDE_DIR LIBCAP_LIBRARY)
diff --git a/cmake/Findlibsodium.cmake b/cmake/Findlibsodium.cmake
new file mode 100644
index 0000000..a82063a
--- /dev/null
+++ b/cmake/Findlibsodium.cmake
@@ -0,0 +1,24 @@
+# Defines the following variables:
+# LIBSODIUM_FOUND
+# LIBSODIUM_INCLUDE_DIR
+# LIBSODIUM_LIBRARIES
+# LIBSODIUM_CFLAGS_OTHER
+# LIBSODIUM_LDFLAGS_OTHER
+
+
+if(ANDROID)
+ find_host_package(PkgConfig REQUIRED QUIET)
+else(ANDROID)
+ find_package(PkgConfig REQUIRED QUIET)
+endif(ANDROID)
+
+pkg_check_modules(_LIBSODIUM libsodium)
+
+find_path(LIBSODIUM_INCLUDE_DIR NAMES sodium/crypto_stream.h HINTS ${_LIBSODIUM_INCLUDE_DIRS})
+find_library(LIBSODIUM_LIBRARIES NAMES sodium HINTS ${_LIBSODIUM_LIBRARY_DIRS})
+
+set(LIBSODIUM_CFLAGS_OTHER "${_LIBSODIUM_CFLAGS_OTHER}" CACHE STRING "Additional compiler flags for libsodium")
+set(LIBSODIUM_LDFLAGS_OTHER "${_LIBSODIUM_LDFLAGS_OTHER}" CACHE STRING "Additional linker flags for libsodium")
+
+find_package_handle_standard_args(libsodium REQUIRED_VARS LIBSODIUM_LIBRARIES LIBSODIUM_INCLUDE_DIR)
+mark_as_advanced(LIBSODIUM_INCLUDE_DIR LIBSODIUM_LIBRARIES LIBSODIUM_CFLAGS_OTHER LIBSODIUM_LDFLAGS_OTHER)
diff --git a/cmake/Findlibuecc.cmake b/cmake/Findlibuecc.cmake
new file mode 100644
index 0000000..dfee8bc
--- /dev/null
+++ b/cmake/Findlibuecc.cmake
@@ -0,0 +1,24 @@
+# Defines the following variables:
+# LIBUECC_FOUND
+# LIBUECC_INCLUDE_DIR
+# LIBUECC_LIBRARIES
+# LIBUECC_CFLAGS_OTHER
+# LIBUECC_LDFLAGS_OTHER
+
+
+if(ANDROID)
+ find_host_package(PkgConfig REQUIRED QUIET)
+else(ANDROID)
+ find_package(PkgConfig REQUIRED QUIET)
+endif(ANDROID)
+
+pkg_check_modules(_LIBUECC libuecc>=5)
+
+find_path(LIBUECC_INCLUDE_DIR NAMES libuecc/ecc.h HINTS ${_LIBUECC_INCLUDE_DIRS})
+find_library(LIBUECC_LIBRARIES NAMES uecc HINTS ${_LIBUECC_LIBRARY_DIRS})
+
+set(LIBUECC_CFLAGS_OTHER "${_LIBUECC_CFLAGS_OTHER}" CACHE STRING "Additional compiler flags for libuecc")
+set(LIBUECC_LDFLAGS_OTHER "${_LIBUECC_LDFLAGS_OTHER}" CACHE STRING "Additional linker flags for libuecc")
+
+find_package_handle_standard_args(LIBUECC REQUIRED_VARS LIBUECC_LIBRARIES LIBUECC_INCLUDE_DIR)
+mark_as_advanced(LIBUECC_INCLUDE_DIR LIBUECC_LIBRARIES LIBUECC_CFLAGS_OTHER LIBUECC_LDFLAGS_OTHER)
diff --git a/cmake/deps.cmake b/cmake/deps.cmake
index ce3ca1b..38f1b49 100644
--- a/cmake/deps.cmake
+++ b/cmake/deps.cmake
@@ -6,71 +6,56 @@ endif(NOT DARWIN)
if(ANDROID)
find_host_package(BISON 2.5 REQUIRED)
- find_host_package(PkgConfig REQUIRED)
else(ANDROID)
find_package(BISON 2.5 REQUIRED)
- find_package(PkgConfig REQUIRED)
endif(ANDROID)
-pkg_check_modules(UECC REQUIRED libuecc>=5)
+find_package(libuecc REQUIRED)
-
-set(NACL_INCLUDE_DIRS "")
-set(NACL_CFLAGS_OTHER "")
-set(NACL_LIBRARY_DIRS "")
-set(NACL_LIBRARIES "")
-set(NACL_LDFLAGS_OTHER "")
+set(NACL_INCLUDE_DIR)
+set(NACL_CFLAGS_OTHER)
+set(NACL_LIBRARIES)
+set(NACL_LDFLAGS_OTHER)
if(ENABLE_LIBSODIUM)
- pkg_check_modules(SODIUM libsodium)
-
- if(SODIUM_FOUND)
- set(NACL_INCLUDE_DIRS "${SODIUM_INCLUDE_DIRS}")
- foreach(dir "${SODIUM_INCLUDEDIR}" ${SODIUM_INCLUDE_DIRS})
- list(APPEND NACL_INCLUDE_DIRS "${dir}/sodium")
- endforeach(dir)
-
- set(NACL_CFLAGS_OTHER "${SODIUM_CFLAGS_OTHER}")
- set(NACL_LIBRARY_DIRS "${SODIUM_LIBRARY_DIRS}")
- set(NACL_LIBRARIES "${SODIUM_LIBRARIES}")
- set(NACL_LDFLAGS_OTHER "${SODIUM_LDFLAGS_OTHER}")
- endif(SODIUM_FOUND)
+ find_package(libsodium)
+
+ if(LIBSODIUM_FOUND)
+ set(NACL_INCLUDE_DIR "${LIBSODIUM_INCLUDE_DIR}/sodium")
+ set(NACL_LIBRARIES "${LIBSODIUM_LIBRARIES}")
+ set(NACL_CFLAGS_OTHER "${LIBSODIUM_CFLAGS_OTHER}")
+ set(NACL_LDFLAGS_OTHER "${LIBSODIUM_LDFLAGS_OTHER}")
+ endif(LIBSODIUM_FOUND)
else(ENABLE_LIBSODIUM)
find_package(NaCl)
- if(NACL_FOUND)
- set(NACL_INCLUDE_DIRS "${NACL_INCLUDE_DIR}")
- set(NACL_LIBRARIES "${NACL_LIBRARY}")
- endif(NACL_FOUND)
+ set(NACL_LIBRARIES "${NACL_LIBRARY}")
endif(ENABLE_LIBSODIUM)
set_property(GLOBAL PROPERTY NACL_REQUIRED FALSE)
if(ENABLE_OPENSSL)
- pkg_check_modules(OPENSSL_CRYPTO REQUIRED libcrypto)
+ find_package(OpenSSL REQUIRED)
else(ENABLE_OPENSSL)
- set(OPENSSL_CRYPTO_INCLUDE_DIRS "")
- set(OPENSSL_CRYPTO_CFLAGS_OTHER "")
- set(OPENSSL_CRYPTO_LIBRARY_DIRS "")
- set(OPENSSL_CRYPTO_LIBRARIES "")
- set(OPENSSL_CRYPTO_LDFLAGS_OTHER "")
+ set(OPENSSL_INCLUDE_DIR)
+ set(OPENSSL_CRYPTO_LIBRARY)
endif(ENABLE_OPENSSL)
if(WITH_CAPABILITIES)
- find_package(CAP REQUIRED)
+ find_package(libcap REQUIRED)
else(WITH_CAPABILITIES)
- set(CAP_INCLUDE_DIR "")
- set(CAP_LIBRARY "")
+ set(LIBCAP_INCLUDE_DIR)
+ set(LIBCAP_LIBRARY)
endif(WITH_CAPABILITIES)
if(WITH_STATUS_SOCKET)
- pkg_check_modules(JSONC REQUIRED json-c)
+ find_package(JSON_C REQUIRED)
else(WITH_STATUS_SOCKET)
- set(JSONC_INCLUDE_DIRS "")
- set(JSONC_CFLAGS_OTHER "")
- set(JSONC_LIBRARY_DIRS "")
- set(JSONC_LIBRARIES "")
- set(JSONC_LDFLAGS_OTHER "")
+ set(JSON_C_INCLUDE_DIRS)
+ set(JSON_C_CFLAGS_OTHER)
+ set(JSON_C_LIBRARY_DIRS)
+ set(JSON_C_LIBRARIES)
+ set(JSON_C_LDFLAGS_OTHER)
endif(WITH_STATUS_SOCKET)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 09868df..20813ce 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,8 +1,7 @@
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE __APPLE_USE_RFC_3542)
-set(FASTD_CFLAGS "${PTHREAD_CFLAGS} -std=c99 ${UECC_CFLAGS_OTHER} ${NACL_CFLAGS_OTHER} ${OPENSSL_CRYPTO_CFLAGS_OTHER} ${JSONC_CFLAGS_OTHER} ${CFLAGS_LTO} -Wall")
+set(FASTD_CFLAGS "${PTHREAD_CFLAGS} -std=c99 ${LIBUECC_CFLAGS_OTHER} ${LIBNACL_CFLAGS_OTHER} ${JSON_C_CFLAGS_OTHER} ${CFLAGS_LTO} -Wall")
include_directories(${FASTD_SOURCE_DIR} ${FASTD_BINARY_DIR}/src)
-link_directories(${UECC_LIBRARY_DIRS} ${NACL_LIBRARY_DIRS} ${OPENSSL_CRYPTO_LIBRARY_DIRS} ${JSONC_LIBRARY_DIRS})
include(generate_version)
@@ -45,9 +44,9 @@ add_executable(fastd
${BISON_fastd_config_parse_OUTPUTS}
)
set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
-set_property(TARGET fastd PROPERTY LINK_FLAGS "${PTHREAD_LDFLAGS} ${UECC_LDFLAGS_OTHER} ${NACL_LDFLAGS_OTHER} ${OPENSSL_CRYPTO_LDFLAGS_OTHER} ${JSONC_LDFLAGS_OTHER} ${LDFLAGS_LTO}")
-set_property(TARGET fastd APPEND PROPERTY INCLUDE_DIRECTORIES ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS} ${JSONC_INCLUDE_DIRS})
-target_link_libraries(fastd protocols methods ciphers macs ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} ${JSONC_LIBRARIES})
+set_property(TARGET fastd PROPERTY LINK_FLAGS "${PTHREAD_LDFLAGS} ${LIBUECC_LDFLAGS_OTHER} ${NACL_LDFLAGS_OTHER} ${JSON_C_LDFLAGS_OTHER} ${LDFLAGS_LTO}")
+set_property(TARGET fastd APPEND PROPERTY INCLUDE_DIRECTORIES ${LIBCAP_INCLUDE_DIR} ${NACL_INCLUDE_DIR} ${JSON_C_INCLUDE_DIR})
+target_link_libraries(fastd protocols methods ciphers macs ${RT_LIBRARY} ${LIBCAP_LIBRARY} ${LIBUECC_LIBRARIES} ${NACL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${JSON_C_LIBRARIES})
add_dependencies(fastd version)
diff --git a/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt b/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt
index 676aa5d..0740c7d 100644
--- a/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt
+++ b/src/crypto/cipher/aes128_ctr/nacl/CMakeLists.txt
@@ -1,6 +1,6 @@
fastd_cipher_impl(aes128-ctr nacl
cipher_aes128_ctr_nacl.c
)
-fastd_cipher_impl_include_directories(aes128-ctr nacl ${NACL_INCLUDE_DIRS})
+fastd_cipher_impl_include_directories(aes128-ctr nacl ${NACL_INCLUDE_DIR})
fastd_cipher_impl_link_libraries(aes128-ctr nacl ${NACL_LIBRARIES})
fastd_cipher_impl_require(aes128-ctr nacl NACL)
diff --git a/src/crypto/cipher/aes128_ctr/openssl/CMakeLists.txt b/src/crypto/cipher/aes128_ctr/openssl/CMakeLists.txt
index 18389f5..566ac49 100644
--- a/src/crypto/cipher/aes128_ctr/openssl/CMakeLists.txt
+++ b/src/crypto/cipher/aes128_ctr/openssl/CMakeLists.txt
@@ -2,5 +2,5 @@ if(ENABLE_OPENSSL)
fastd_cipher_impl(aes128-ctr openssl
aes128_ctr_openssl.c
)
- fastd_cipher_impl_include_directories(aes128-ctr openssl ${OPENSSL_INCLUDE_DIRS})
+ fastd_cipher_impl_include_directories(aes128-ctr openssl ${OPENSSL_INCLUDE_DIR})
endif(ENABLE_OPENSSL)
diff --git a/src/crypto/cipher/salsa20/nacl/CMakeLists.txt b/src/crypto/cipher/salsa20/nacl/CMakeLists.txt
index d76ff34..2b550c1 100644
--- a/src/crypto/cipher/salsa20/nacl/CMakeLists.txt
+++ b/src/crypto/cipher/salsa20/nacl/CMakeLists.txt
@@ -1,6 +1,6 @@
fastd_cipher_impl(salsa20 nacl
salsa20_nacl.c
)
-fastd_cipher_impl_include_directories(salsa20 nacl ${NACL_INCLUDE_DIRS})
+fastd_cipher_impl_include_directories(salsa20 nacl ${NACL_INCLUDE_DIR})
fastd_cipher_impl_link_libraries(salsa20 nacl ${NACL_LIBRARIES})
fastd_cipher_impl_require(salsa20 nacl NACL)
diff --git a/src/crypto/cipher/salsa2012/nacl/CMakeLists.txt b/src/crypto/cipher/salsa2012/nacl/CMakeLists.txt
index 3d47621..54487e7 100644
--- a/src/crypto/cipher/salsa2012/nacl/CMakeLists.txt
+++ b/src/crypto/cipher/salsa2012/nacl/CMakeLists.txt
@@ -1,6 +1,6 @@
fastd_cipher_impl(salsa2012 nacl
salsa2012_nacl.c
)
-fastd_cipher_impl_include_directories(salsa2012 nacl ${NACL_INCLUDE_DIRS})
+fastd_cipher_impl_include_directories(salsa2012 nacl ${NACL_INCLUDE_DIR})
fastd_cipher_impl_link_libraries(salsa2012 nacl ${NACL_LIBRARIES})
fastd_cipher_impl_require(salsa2012 nacl NACL)
diff --git a/src/methods/generic_poly1305/CMakeLists.txt b/src/methods/generic_poly1305/CMakeLists.txt
index cafa288..18f2382 100644
--- a/src/methods/generic_poly1305/CMakeLists.txt
+++ b/src/methods/generic_poly1305/CMakeLists.txt
@@ -1,6 +1,6 @@
fastd_method(generic-poly1305
generic_poly1305.c
)
-fastd_method_include_directories(generic-poly1305 ${NACL_INCLUDE_DIRS})
+fastd_method_include_directories(generic-poly1305 ${NACL_INCLUDE_DIR})
fastd_method_link_libraries(generic-poly1305 method_common ${NACL_LIBRARIES})
fastd_method_require(generic-poly1305 NACL)
diff --git a/src/methods/xsalsa20_poly1305/CMakeLists.txt b/src/methods/xsalsa20_poly1305/CMakeLists.txt
index 97dee39..7dc2339 100644
--- a/src/methods/xsalsa20_poly1305/CMakeLists.txt
+++ b/src/methods/xsalsa20_poly1305/CMakeLists.txt
@@ -1,6 +1,6 @@
fastd_method(xsalsa20-poly1305
xsalsa20_poly1305.c
)
-fastd_method_include_directories(xsalsa20-poly1305 ${NACL_INCLUDE_DIRS})
+fastd_method_include_directories(xsalsa20-poly1305 ${NACL_INCLUDE_DIR})
fastd_method_link_libraries(xsalsa20-poly1305 method_common ${NACL_LIBRARIES})
fastd_method_require(xsalsa20-poly1305 NACL)
diff --git a/src/protocols/ec25519_fhmqvc/CMakeLists.txt b/src/protocols/ec25519_fhmqvc/CMakeLists.txt
index 9252a08..8e6bed0 100644
--- a/src/protocols/ec25519_fhmqvc/CMakeLists.txt
+++ b/src/protocols/ec25519_fhmqvc/CMakeLists.txt
@@ -1,3 +1,4 @@
+
add_library(protocol_ec25519_fhmqvc OBJECT
ec25519_fhmqvc.c
handshake.c
@@ -5,4 +6,4 @@ add_library(protocol_ec25519_fhmqvc OBJECT
util.c
)
set_property(TARGET protocol_ec25519_fhmqvc PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}")
-set_property(TARGET protocol_ec25519_fhmqvc APPEND PROPERTY INCLUDE_DIRECTORIES ${UECC_INCLUDE_DIRS})
+set_property(TARGET protocol_ec25519_fhmqvc APPEND PROPERTY INCLUDE_DIRECTORIES ${LIBUECC_INCLUDE_DIR})