From 261f365e55d4711372f7053667aa368788eabea1 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Mon, 29 Jul 2013 20:47:12 -0400 Subject: Fixed function signature --- core/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/network.h') diff --git a/core/network.h b/core/network.h index aaaaa409..8af4b32f 100644 --- a/core/network.h +++ b/core/network.h @@ -125,7 +125,7 @@ void shutdown_networking(); address should represent IPv4, IPv6 or a hostname on success returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i on failure returns -1 */ -int resolve_addr(char *address); +int resolve_addr(const char *address); #ifdef __cplusplus } -- cgit v1.2.3 From f77fe65d5435290368bb2ccad6d5aa6cc5fbc234 Mon Sep 17 00:00:00 2001 From: xzfcpw Date: Tue, 30 Jul 2013 21:00:55 +0700 Subject: NaCl compiling option --- CMakeLists.txt | 21 +++++++++++++++++++-- cmake/FindNaCl.cmake | 17 +++++++++++++++++ core/network.h | 6 +----- 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 cmake/FindNaCl.cmake (limited to 'core/network.h') diff --git a/CMakeLists.txt b/CMakeLists.txt index c16ce6fe..4db6985d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,22 @@ cmake_minimum_required(VERSION 2.6.0) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + +if(NOT WIN32) + option(USE_NACL "Use NaCl library instead of libsodium") +endif() + +if(NOT USE_NACL) + set(LINK_CRYPTO_LIBRARY "sodium") +else() + find_package(NaCl REQUIRED) + + include_directories(${NACL_INCLUDE_DIR}) + add_definitions(-DVANILLA_NACL) + + set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES}) +endif() + #MinGW prints more warnings for -Wall than gcc does, thus causing build to fail if(NOT WIN32) if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) @@ -17,7 +34,7 @@ macro(linkCoreLibraries exe_name) ws2_32) else() target_link_libraries(${exe_name} core - sodium) + ${LINK_CRYPTO_LIBRARY}) endif() endmacro() @@ -25,4 +42,4 @@ cmake_policy(SET CMP0011 NEW) add_subdirectory(core) add_subdirectory(testing) -add_subdirectory(other) \ No newline at end of file +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 @@ +find_path(NACL_INCLUDE_DIR crypto_box.h + $ENV{NACL_INCLUDE_DIR} /usr/include/nacl/ + DOC "Directory which contain NaCl headers") + +find_path(NACL_LIBRARY_DIR libnacl.a + $ENV{NACL_LIBRARY_DIR} /usr/lib/nacl + DOC "Directory which contain libnacl.a, cpucycles.o, and randombytes.o") + +if(NACL_LIBRARY_DIR) + set(NACL_LIBRARIES + "${NACL_LIBRARY_DIR}/cpucycles.o" + "${NACL_LIBRARY_DIR}/libnacl.a" + "${NACL_LIBRARY_DIR}/randombytes.o") +endif() + +include(FindPackageHandleStandardArgs) +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 @@ /* we use libsodium by default */ #include #else - -/* TODO: Including stuff like this is bad. This needs fixing. - We keep support for the original NaCl for now. */ -#include "../nacl/build/Linux/include/amd64/crypto_box.h" - +#include #endif #ifdef __cplusplus -- cgit v1.2.3