diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2013-08-04 21:38:12 -0400 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2013-08-04 22:25:07 -0400 |
commit | 03a2bac3190b7044e8cbd66339c6f9d76bfc48ef (patch) | |
tree | 760d03540479da34072f4036a64ed3250734a9e4 | |
parent | f03dc44e97e993024e42b3a0915de6401d9cecb0 (diff) |
Improved cmake
-rwxr-xr-x | CMakeLists.txt | 36 | ||||
-rw-r--r-- | cmake/FindSODIUM.cmake | 8 | ||||
-rw-r--r-- | core/CMakeLists.txt | 15 |
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 | ||
3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | 3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
4 | 4 | ||
5 | if(UNIX) | 5 | option(SHARED_TOXCORE "Build Core as a shared library") |
6 | find_package(Curses REQUIRED) | ||
7 | endif() | ||
8 | 6 | ||
9 | if(NOT WIN32) | 7 | if(WIN32) |
8 | option(SHARED_LIBSODIUM "Links libsodium as a shared library") | ||
9 | else() | ||
10 | option(USE_NACL "Use NaCl library instead of libsodium") | 10 | option(USE_NACL "Use NaCl library instead of libsodium") |
11 | endif() | 11 | endif() |
12 | 12 | ||
13 | if(UNIX) | ||
14 | find_package(Curses REQUIRED) | ||
15 | endif() | ||
16 | |||
13 | if(USE_NACL) | 17 | if(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}) |
24 | else() | ||
25 | find_package(SODIUM REQUIRED) | ||
26 | |||
27 | include_directories(${SODIUM_INCLUDE_DIR}) | ||
28 | |||
29 | set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY}) | ||
20 | endif() | 30 | endif() |
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() |
28 | endif() | 38 | endif() |
29 | 39 | ||
30 | if(NOT USE_NACL) | ||
31 | find_package(SODIUM REQUIRED) | ||
32 | set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARY}) | ||
33 | endif() | ||
34 | |||
35 | macro(linkCoreLibraries exe_name) | 40 | macro(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() |
48 | endmacro() | 48 | endmacro() |
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 | ||
49 | if(SHARED_LIBSODIUM) | ||
50 | set(WIN32_LIBSODIUM_FILENAME libsodium.dll.a) | ||
51 | else() | ||
52 | set(WIN32_LIBSODIUM_FILENAME libsodium.a) | ||
53 | endif() | ||
54 | |||
49 | find_library(SODIUM_LIBRARY | 55 | find_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 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | 1 | cmake_minimum_required(VERSION 2.6.0) |
2 | project(toxcore C) | 2 | project(toxcore C) |
3 | 3 | ||
4 | if(WIN32) | ||
5 | include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) | ||
6 | else(WIN32) | ||
7 | include_directories(${SODIUM_INCLUDE_DIR}) | ||
8 | endif() | ||
9 | |||
10 | set(core_sources | 4 | set(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 | ||
19 | add_library(toxcore SHARED ${core_sources}) | 13 | if(SHARED_TOXCORE) |
20 | target_link_libraries(toxcore ${SODIUM_LIBRARY}) | 14 | add_library(toxcore SHARED ${core_sources}) |
15 | else() | ||
16 | add_library(toxcore ${core_sources}) | ||
17 | endif() | ||
18 | |||
19 | target_link_libraries(toxcore ${LINK_CRYPTO_LIBRARY}) | ||
21 | 20 | ||
22 | if(WIN32) | 21 | if(WIN32) |
23 | target_link_libraries(toxcore ws2_32) | 22 | target_link_libraries(toxcore ws2_32) |