summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt18
-rw-r--r--cmake/FindNaCl.cmake17
-rw-r--r--core/network.h6
3 files changed, 35 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c18d41d2..9a79b74e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,21 @@ cmake_minimum_required(VERSION 2.6.0)
2 2
3set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 3set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
4 4
5if(NOT WIN32)
6 option(USE_NACL "Use NaCl library instead of libsodium")
7endif()
8
9if(NOT USE_NACL)
10 set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY})
11else()
12 find_package(NaCl REQUIRED)
13
14 include_directories(${NACL_INCLUDE_DIR})
15 add_definitions(-DVANILLA_NACL)
16
17 set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES})
18endif()
19
5#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail 20#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
6if(NOT WIN32) 21if(NOT WIN32)
7 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) 22 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
@@ -21,7 +36,8 @@ macro(linkCoreLibraries exe_name)
21 else() 36 else()
22 include_directories(${SODIUM_INCLUDE_DIR}) 37 include_directories(${SODIUM_INCLUDE_DIR})
23 target_link_libraries(${exe_name} core 38 target_link_libraries(${exe_name} core
24 ${SODIUM_LIBRARY}) 39 ${LINK_CRYPTO_LIBRARY})
40
25 endif() 41 endif()
26endmacro() 42endmacro()
27 43
diff --git a/cmake/FindNaCl.cmake b/cmake/FindNaCl.cmake
new file mode 100644
index 00000000..cdd6248a
--- /dev/null
+++ b/cmake/FindNaCl.cmake
@@ -0,0 +1,17 @@
1find_path(NACL_INCLUDE_DIR crypto_box.h
2 $ENV{NACL_INCLUDE_DIR} /usr/include/nacl/
3 DOC "Directory which contain NaCl headers")
4
5find_path(NACL_LIBRARY_DIR libnacl.a
6 $ENV{NACL_LIBRARY_DIR} /usr/lib/nacl
7 DOC "Directory which contain libnacl.a, cpucycles.o, and randombytes.o")
8
9if(NACL_LIBRARY_DIR)
10 set(NACL_LIBRARIES
11 "${NACL_LIBRARY_DIR}/cpucycles.o"
12 "${NACL_LIBRARY_DIR}/libnacl.a"
13 "${NACL_LIBRARY_DIR}/randombytes.o")
14endif()
15
16include(FindPackageHandleStandardArgs)
17find_package_handle_standard_args(NaCl DEFAULT_MSG NACL_INCLUDE_DIR NACL_LIBRARY_DIR NACL_LIBRARIES)
diff --git a/core/network.h b/core/network.h
index 8af4b32f..3277070c 100644
--- a/core/network.h
+++ b/core/network.h
@@ -56,11 +56,7 @@
56/* we use libsodium by default */ 56/* we use libsodium by default */
57#include <sodium.h> 57#include <sodium.h>
58#else 58#else
59 59#include <crypto_box.h>
60/* TODO: Including stuff like this is bad. This needs fixing.
61 We keep support for the original NaCl for now. */
62#include "../nacl/build/Linux/include/amd64/crypto_box.h"
63
64#endif 60#endif
65 61
66#ifdef __cplusplus 62#ifdef __cplusplus