mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
NaCl compiling option
This commit is contained in:
parent
3f85bdca15
commit
f77fe65d54
|
@ -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)
|
||||
add_subdirectory(other)
|
||||
|
|
17
cmake/FindNaCl.cmake
Normal file
17
cmake/FindNaCl.cmake
Normal file
|
@ -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)
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user