summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-08-04 19:49:08 -0700
committerirungentoo <irungentoo@gmail.com>2013-08-04 19:49:08 -0700
commit5e43dc7bd8c790a43c22fd6ab47e9dbef9205186 (patch)
tree0a1b3d5316ed4885157d2f7eb19d58b54eae4153
parentc1e4365d1d39876f5cb088d7850ae6a3b53d9833 (diff)
parentca3380ba2f50a8b793c795d5bbc815179b10375e (diff)
Merge pull request #331 from nurupo/master
cmake improvements
-rwxr-xr-xCMakeLists.txt36
-rw-r--r--INSTALL.md8
-rw-r--r--cmake/FindSODIUM.cmake8
-rw-r--r--core/CMakeLists.txt15
4 files changed, 40 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/INSTALL.md b/INSTALL.md
index 483928b0..8c7147fa 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -60,6 +60,10 @@ cd ProjectTox-Core
60mkdir build && cd build 60mkdir build && cd build
61cmake .. 61cmake ..
62``` 62```
63Advance cmake options:
64 - `-DSHARED_TOXCORE=ON` (default `OFF`) — Build Core as a shared library.
65 - `-DUSE_NACL=ON` (default `OFF`) — Use NaCl library instead of libsodium.
66
63Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only. 67Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only.
64 68
65Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running: 69Then 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:
143mkdir build && cd build 147mkdir build && cd build
144cmake -G "MinGW Makefiles" .. 148cmake -G "MinGW Makefiles" ..
145``` 149```
150Advance cmake options:
151 - `-DSHARED_TOXCORE=ON` (default OFF) — Build Core as a shared library.
152 - `-DSHARED_LIBSODIUM=ON` (default OFF) — Link libsodium as a shared library.
153
146Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only. 154Note that you should call cmake on the root [`CMakeLists.txt`](/CMakeLists.txt) file only.
147 155
148Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running: 156Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
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)