summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-22 04:09:45 -0700
committerirungentoo <irungentoo@gmail.com>2013-07-22 04:09:45 -0700
commit11891e2475a123ad911647e380d2c547db70de09 (patch)
tree73ebc7ec31fb707cdd75df18323f3d98337afe61
parentb7393890eb8fd3505c2f71a37f4756f71f948890 (diff)
parent2ab2ebe5a5f47b53a026118f144adf932aad1f11 (diff)
Merge pull request #84 from nurupo/master
Improved build system
-rw-r--r--.travis.yml9
-rw-r--r--CMakeLists.txt27
-rw-r--r--INSTALL.md20
-rw-r--r--core/CMakeLists.txt15
-rw-r--r--other/CMakeLists.txt4
-rw-r--r--testing/CMakeLists.txt12
-rw-r--r--testing/DHT_test.c2
7 files changed, 58 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml
index 9f62c84c..0a294bf1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,16 +8,15 @@ before_script:
8 - cd libsodium 8 - cd libsodium
9 - git checkout tags/0.4.2 9 - git checkout tags/0.4.2
10 - ./autogen.sh 10 - ./autogen.sh
11 - ./configure && make -j3 check 11 - ./configure && make check -j3
12 - sudo make install 12 - sudo make install
13 - sudo ldconfig 13 - sudo ldconfig
14 - cd .. 14 - cd ..
15 15
16script: 16script:
17 - cmake CMakeLists.txt 17 - mkdir build && cd build
18 - make DHT_bootstrap -j3 18 - cmake ..
19 - make Messenger_test -j3 19 - make -j3
20 - make nTox -j3
21 20
22notifications: 21notifications:
23 email: false 22 email: false
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 505983f2..c16ce6fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,6 @@
1cmake_minimum_required(VERSION 2.6.0) 1cmake_minimum_required(VERSION 2.6.0)
2 2
3#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
3if(NOT WIN32) 4if(NOT WIN32)
4 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) 5 if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
5 message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====") 6 message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====")
@@ -7,31 +8,21 @@ if(NOT WIN32)
7 endif() 8 endif()
8endif() 9endif()
9 10
10if(WIN32)
11 include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
12endif()
13
14set(core_sources
15 core/DHT.c
16 core/network.c
17 core/Lossless_UDP.c
18 core/net_crypto.c
19 core/Messenger.c)
20
21add_library(core ${core_sources})
22
23macro(linkCoreLibraries exe_name) 11macro(linkCoreLibraries exe_name)
12 add_dependencies(${exe_name} core)
24 if(WIN32) 13 if(WIN32)
25 target_link_libraries(${exe_name} core 14 include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
26 ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a 15 target_link_libraries(${exe_name} core
16 ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a
27 ws2_32) 17 ws2_32)
28 else() 18 else()
29 target_link_libraries(${exe_name} core 19 target_link_libraries(${exe_name} core
30 sodium) 20 sodium)
31 endif() 21 endif()
32endmacro() 22endmacro()
33 23
34cmake_policy(SET CMP0011 NEW) 24cmake_policy(SET CMP0011 NEW)
35 25
36ADD_SUBDIRECTORY(testing) 26add_subdirectory(core)
37ADD_SUBDIRECTORY(other) \ No newline at end of file 27add_subdirectory(testing)
28add_subdirectory(other) \ No newline at end of file
diff --git a/INSTALL.md b/INSTALL.md
index 97bef179..bc027c0b 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -15,10 +15,11 @@ sudo ldconfig
15 15
16Then clone this repo and run: 16Then clone this repo and run:
17```bash 17```bash
18cmake CMakeLists.txt 18mkdir build && cd build
19cmake ..
19``` 20```
20 21
21Then you can build any of the [`/testing`](/testing) and [`/other`](/other) by running: 22Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
22```bash 23```bash
23make name_of_c_file 24make name_of_c_file
24``` 25```
@@ -27,6 +28,11 @@ For example, to build [`Messenger_test.c`](/others/Messenger_test.c) you would r
27make Messenger_test 28make Messenger_test
28``` 29```
29 30
31Or you could just build everything that is supported on your platform by running:
32```bash
33make
34```
35
30###OSX: 36###OSX:
31 37
32Much the same as above, remember to install the latest XCode and the developer tools (Preferences -> Downloads -> Command Line Tools). 38Much the same as above, remember to install the latest XCode and the developer tools (Preferences -> Downloads -> Command Line Tools).
@@ -56,10 +62,11 @@ After that you should get precompiled packages of libsodium from [here](https://
56 62
57Navigate in `cmd` to this repo and run: 63Navigate in `cmd` to this repo and run:
58```cmd 64```cmd
59cmake -G "MinGW Makefiles" CMakeLists.txt 65mkdir build && cd build
66cmake -G "MinGW Makefiles" ..
60``` 67```
61 68
62Then you can build any of the [`/testing`](/testing) and [`/other`](/other) by running: 69Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
63```cmd 70```cmd
64mingw32-make name_of_c_file 71mingw32-make name_of_c_file
65``` 72```
@@ -67,3 +74,8 @@ For example, to build [`Messenger_test.c`](/others/Messenger_test.c) you would r
67```cmd 74```cmd
68mingw32-make Messenger_test 75mingw32-make Messenger_test
69``` 76```
77
78Or you could just build everything that is supported on your platform by running:
79```bash
80mingw32-make
81```
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
new file mode 100644
index 00000000..51f30e17
--- /dev/null
+++ b/core/CMakeLists.txt
@@ -0,0 +1,15 @@
1cmake_minimum_required(VERSION 2.6.0)
2project(core C)
3
4if(WIN32)
5 include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
6endif()
7
8set(core_sources
9 DHT.c
10 network.c
11 Lossless_UDP.c
12 net_crypto.c
13 Messenger.c)
14
15add_library(core ${core_sources})
diff --git a/other/CMakeLists.txt b/other/CMakeLists.txt
index 22dc8e25..e59e6e66 100644
--- a/other/CMakeLists.txt
+++ b/other/CMakeLists.txt
@@ -1 +1,5 @@
1cmake_minimum_required(VERSION 2.6.0)
2
3cmake_policy(SET CMP0011 NEW)
4
1include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake) 5include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake)
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt
index bb599b86..12efc2f4 100644
--- a/testing/CMakeLists.txt
+++ b/testing/CMakeLists.txt
@@ -1,7 +1,13 @@
1include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_cryptosendfiletest.cmake) 1cmake_minimum_required(VERSION 2.6.0)
2include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_sendfiletest.cmake) 2
3cmake_policy(SET CMP0011 NEW)
4
5#include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_cryptosendfiletest.cmake)
6#include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_sendfiletest.cmake)
3include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake) 7include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake)
4include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) 8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake)
5include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) 9include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake)
6include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) 10include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake)
7include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) \ No newline at end of file 11if(NOT WIN32)
12 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake)
13endif()
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 5f85e934..5895fa55 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -1,7 +1,7 @@
1/* DHT test 1/* DHT test
2 * A file with a main that runs our DHT for testing. 2 * A file with a main that runs our DHT for testing.
3 * 3 *
4 * Compile with: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/* DHT_test.c 4 * Compile with: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/ DHT_test.c
5 * 5 *
6 * Command line arguments are the ip, port and public key of a node. 6 * Command line arguments are the ip, port and public key of a node.
7 * EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 7 * EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA