Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xzfc/ProjectTox-Core into…
Browse files Browse the repository at this point in the history
… xzfc-master

Conflicts:
	CMakeLists.txt
  • Loading branch information
irungentoo committed Jul 31, 2013
2 parents 7252456 + f77fe65 commit f2f266e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ cmake_minimum_required(VERSION 2.6.0)

set(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_LIBRARY})
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"))
Expand All @@ -21,7 +36,8 @@ macro(linkCoreLibraries exe_name)
else()
include_directories(${SODIUM_INCLUDE_DIR})
target_link_libraries(${exe_name} core
${SODIUM_LIBRARY})
${LINK_CRYPTO_LIBRARY})

endif()
endmacro()

Expand Down
17 changes: 17 additions & 0 deletions cmake/FindNaCl.cmake
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 1 addition & 5 deletions core/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
/* we use libsodium by default */
#include <sodium.h>
#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 <crypto_box.h>
#endif

#ifdef __cplusplus
Expand Down

0 comments on commit f2f266e

Please sign in to comment.