summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCMakeLists.txt36
-rw-r--r--cmake/FindSODIUM.cmake8
-rw-r--r--core/CMakeLists.txt15
3 files changed, 32 insertions, 27 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f2657fc5..f56cd67a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,14 +2,18 @@ cmake_minimum_required(VERSION 2.6.0)
2 2
3set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 3set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
4 4
5if(UNIX) 5option(SHARED_TOXCORE "Build Core as a shared library")
6 find_package(Curses REQUIRED)
7endif()
8 6
9if(NOT WIN32) 7if(WIN32)
8 option(SHARED_LIBSODIUM "Links libsodium as a shared library")
9else()
10 option(USE_NACL "Use NaCl library instead of libsodium") 10 option(USE_NACL "Use NaCl library instead of libsodium")
11endif() 11endif()
12 12
13if(UNIX)
14 find_package(Curses REQUIRED)
15endif()
16
13if(USE_NACL) 17if(USE_NACL)
14 find_package(NaCl REQUIRED) 18 find_package(NaCl REQUIRED)
15 19
@@ -17,6 +21,12 @@ if(USE_NACL)
17 add_definitions(-DVANILLA_NACL) 21 add_definitions(-DVANILLA_NACL)
18 22
19 set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES}) 23 set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES})
24else()
25 find_package(SODIUM REQUIRED)
26
27 include_directories(${SODIUM_INCLUDE_DIR})
28
29 set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY})
20endif() 30endif()
21 31
22#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail 32#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
@@ -27,23 +37,13 @@ if(NOT WIN32)
27 endif() 37 endif()
28endif() 38endif()
29 39
30if(NOT USE_NACL)
31 find_package(SODIUM REQUIRED)
32 set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY})
33endif()
34
35macro(linkCoreLibraries exe_name) 40macro(linkCoreLibraries exe_name)
36 add_dependencies(${exe_name} toxcore) 41 add_dependencies(${exe_name} toxcore)
37 if(WIN32) 42 target_link_libraries(${exe_name} toxcore
38 include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) 43 ${LINK_CRYPTO_LIBRARY})
39 target_link_libraries(${exe_name} toxcore
40 ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a
41 ws2_32)
42 else()
43 include_directories(${SODIUM_INCLUDE_DIR})
44 target_link_libraries(${exe_name} toxcore
45 ${LINK_CRYPTO_LIBRARY})
46 44
45 if(WIN32)
46 target_link_libraries(${exe_name} ws2_32)
47 endif() 47 endif()
48endmacro() 48endmacro()
49 49
diff --git a/cmake/FindSODIUM.cmake b/cmake/FindSODIUM.cmake
index ff9bc27b..2db0f667 100644
--- a/cmake/FindSODIUM.cmake
+++ b/cmake/FindSODIUM.cmake
@@ -46,10 +46,16 @@ find_path(SODIUM_INCLUDE_DIR
46 ${SODIUM_ROOT_DIR}/include 46 ${SODIUM_ROOT_DIR}/include
47) 47)
48 48
49if(SHARED_LIBSODIUM)
50 set(WIN32_LIBSODIUM_FILENAME libsodium.dll.a)
51else()
52 set(WIN32_LIBSODIUM_FILENAME libsodium.a)
53endif()
54
49find_library(SODIUM_LIBRARY 55find_library(SODIUM_LIBRARY
50 NAMES 56 NAMES
57 ${WIN32_LIBSODIUM_FILENAME}
51 sodium 58 sodium
52 libsodium.a
53 PATHS 59 PATHS
54 ${SODIUM_ROOT_DIR}/lib 60 ${SODIUM_ROOT_DIR}/lib
55) 61)
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index c7016a49..eacb772c 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -1,12 +1,6 @@
1cmake_minimum_required(VERSION 2.6.0) 1cmake_minimum_required(VERSION 2.6.0)
2project(toxcore C) 2project(toxcore C)
3 3
4if(WIN32)
5 include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
6else(WIN32)
7 include_directories(${SODIUM_INCLUDE_DIR})
8endif()
9
10set(core_sources 4set(core_sources
11 DHT.c 5 DHT.c
12 network.c 6 network.c
@@ -16,8 +10,13 @@ set(core_sources
16 LAN_discovery.c 10 LAN_discovery.c
17 Messenger.c) 11 Messenger.c)
18 12
19add_library(toxcore SHARED ${core_sources}) 13if(SHARED_TOXCORE)
20target_link_libraries(toxcore ${SODIUM_LIBRARY}) 14 add_library(toxcore SHARED ${core_sources})
15else()
16 add_library(toxcore ${core_sources})
17endif()
18
19target_link_libraries(toxcore ${LINK_CRYPTO_LIBRARY})
21 20
22if(WIN32) 21if(WIN32)
23 target_link_libraries(toxcore ws2_32) 22 target_link_libraries(toxcore ws2_32)