diff options
author | xzfcpw <xzfcpw@gmail.com> | 2013-07-30 21:00:55 +0700 |
---|---|---|
committer | xzfcpw <xzfcpw@gmail.com> | 2013-07-31 15:42:05 +0700 |
commit | f77fe65d5435290368bb2ccad6d5aa6cc5fbc234 (patch) | |
tree | 2f5156b08ab3eda20c8d5f7610f1bf2066bc3ec3 | |
parent | 3f85bdca15d2f0258413039978b6552965385335 (diff) |
NaCl compiling option
-rw-r--r-- | CMakeLists.txt | 21 | ||||
-rw-r--r-- | cmake/FindNaCl.cmake | 17 | ||||
-rw-r--r-- | core/network.h | 6 |
3 files changed, 37 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c16ce6fe..4db6985d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -1,5 +1,22 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | 1 | cmake_minimum_required(VERSION 2.6.0) |
2 | 2 | ||
3 | list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") | ||
4 | |||
5 | if(NOT WIN32) | ||
6 | option(USE_NACL "Use NaCl library instead of libsodium") | ||
7 | endif() | ||
8 | |||
9 | if(NOT USE_NACL) | ||
10 | set(LINK_CRYPTO_LIBRARY "sodium") | ||
11 | else() | ||
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}) | ||
18 | endif() | ||
19 | |||
3 | #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 |
4 | if(NOT WIN32) | 21 | if(NOT WIN32) |
5 | 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")) |
@@ -17,7 +34,7 @@ macro(linkCoreLibraries exe_name) | |||
17 | ws2_32) | 34 | ws2_32) |
18 | else() | 35 | else() |
19 | target_link_libraries(${exe_name} core | 36 | target_link_libraries(${exe_name} core |
20 | sodium) | 37 | ${LINK_CRYPTO_LIBRARY}) |
21 | endif() | 38 | endif() |
22 | endmacro() | 39 | endmacro() |
23 | 40 | ||
@@ -25,4 +42,4 @@ cmake_policy(SET CMP0011 NEW) | |||
25 | 42 | ||
26 | add_subdirectory(core) | 43 | add_subdirectory(core) |
27 | add_subdirectory(testing) | 44 | add_subdirectory(testing) |
28 | add_subdirectory(other) \ No newline at end of file | 45 | add_subdirectory(other) |
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 @@ | |||
1 | find_path(NACL_INCLUDE_DIR crypto_box.h | ||
2 | $ENV{NACL_INCLUDE_DIR} /usr/include/nacl/ | ||
3 | DOC "Directory which contain NaCl headers") | ||
4 | |||
5 | find_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 | |||
9 | if(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") | ||
14 | endif() | ||
15 | |||
16 | include(FindPackageHandleStandardArgs) | ||
17 | find_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 |