mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
commit
5e43dc7bd8
|
@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 2.6.0)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
if(UNIX)
|
option(SHARED_TOXCORE "Build Core as a shared library")
|
||||||
find_package(Curses REQUIRED)
|
|
||||||
|
if(WIN32)
|
||||||
|
option(SHARED_LIBSODIUM "Links libsodium as a shared library")
|
||||||
|
else()
|
||||||
|
option(USE_NACL "Use NaCl library instead of libsodium")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(UNIX)
|
||||||
option(USE_NACL "Use NaCl library instead of libsodium")
|
find_package(Curses REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_NACL)
|
if(USE_NACL)
|
||||||
|
@ -17,6 +21,12 @@ if(USE_NACL)
|
||||||
add_definitions(-DVANILLA_NACL)
|
add_definitions(-DVANILLA_NACL)
|
||||||
|
|
||||||
set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES})
|
set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES})
|
||||||
|
else()
|
||||||
|
find_package(SODIUM REQUIRED)
|
||||||
|
|
||||||
|
include_directories(${SODIUM_INCLUDE_DIR})
|
||||||
|
|
||||||
|
set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
|
#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
|
||||||
|
@ -27,23 +37,13 @@ if(NOT WIN32)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT USE_NACL)
|
|
||||||
find_package(SODIUM REQUIRED)
|
|
||||||
set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
macro(linkCoreLibraries exe_name)
|
macro(linkCoreLibraries exe_name)
|
||||||
add_dependencies(${exe_name} toxcore)
|
add_dependencies(${exe_name} toxcore)
|
||||||
if(WIN32)
|
target_link_libraries(${exe_name} toxcore
|
||||||
include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
|
${LINK_CRYPTO_LIBRARY})
|
||||||
target_link_libraries(${exe_name} toxcore
|
|
||||||
${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a
|
|
||||||
ws2_32)
|
|
||||||
else()
|
|
||||||
include_directories(${SODIUM_INCLUDE_DIR})
|
|
||||||
target_link_libraries(${exe_name} toxcore
|
|
||||||
${LINK_CRYPTO_LIBRARY})
|
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(${exe_name} ws2_32)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@ cd ProjectTox-Core
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
```
|
```
|
||||||
|
Advance cmake options:
|
||||||
|
- `-DSHARED_TOXCORE=ON` (default `OFF`) — Build Core as a shared library.
|
||||||
|
- `-DUSE_NACL=ON` (default `OFF`) — Use NaCl library instead of libsodium.
|
||||||
|
|
||||||
Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only.
|
Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only.
|
||||||
|
|
||||||
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
|
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
|
||||||
|
@ -143,6 +147,10 @@ Navigate in `cmd` to this repo and run:
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake -G "MinGW Makefiles" ..
|
cmake -G "MinGW Makefiles" ..
|
||||||
```
|
```
|
||||||
|
Advance cmake options:
|
||||||
|
- `-DSHARED_TOXCORE=ON` (default OFF) — Build Core as a shared library.
|
||||||
|
- `-DSHARED_LIBSODIUM=ON` (default OFF) — Link libsodium as a shared library.
|
||||||
|
|
||||||
Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only.
|
Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only.
|
||||||
|
|
||||||
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
|
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
|
||||||
|
|
|
@ -46,10 +46,16 @@ find_path(SODIUM_INCLUDE_DIR
|
||||||
${SODIUM_ROOT_DIR}/include
|
${SODIUM_ROOT_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(SHARED_LIBSODIUM)
|
||||||
|
set(WIN32_LIBSODIUM_FILENAME libsodium.dll.a)
|
||||||
|
else()
|
||||||
|
set(WIN32_LIBSODIUM_FILENAME libsodium.a)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_library(SODIUM_LIBRARY
|
find_library(SODIUM_LIBRARY
|
||||||
NAMES
|
NAMES
|
||||||
|
${WIN32_LIBSODIUM_FILENAME}
|
||||||
sodium
|
sodium
|
||||||
libsodium.a
|
|
||||||
PATHS
|
PATHS
|
||||||
${SODIUM_ROOT_DIR}/lib
|
${SODIUM_ROOT_DIR}/lib
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 2.6.0)
|
cmake_minimum_required(VERSION 2.6.0)
|
||||||
project(toxcore C)
|
project(toxcore C)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
|
|
||||||
else(WIN32)
|
|
||||||
include_directories(${SODIUM_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(core_sources
|
set(core_sources
|
||||||
DHT.c
|
DHT.c
|
||||||
network.c
|
network.c
|
||||||
|
@ -16,8 +10,13 @@ set(core_sources
|
||||||
LAN_discovery.c
|
LAN_discovery.c
|
||||||
Messenger.c)
|
Messenger.c)
|
||||||
|
|
||||||
add_library(toxcore SHARED ${core_sources})
|
if(SHARED_TOXCORE)
|
||||||
target_link_libraries(toxcore ${SODIUM_LIBRARY})
|
add_library(toxcore SHARED ${core_sources})
|
||||||
|
else()
|
||||||
|
add_library(toxcore ${core_sources})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(toxcore ${LINK_CRYPTO_LIBRARY})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(toxcore ws2_32)
|
target_link_libraries(toxcore ws2_32)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user