diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-22 04:09:45 -0700 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-22 04:09:45 -0700 |
commit | 11891e2475a123ad911647e380d2c547db70de09 (patch) | |
tree | 73ebc7ec31fb707cdd75df18323f3d98337afe61 | |
parent | b7393890eb8fd3505c2f71a37f4756f71f948890 (diff) | |
parent | 2ab2ebe5a5f47b53a026118f144adf932aad1f11 (diff) |
Merge pull request #84 from nurupo/master
Improved build system
-rw-r--r-- | .travis.yml | 9 | ||||
-rw-r--r-- | CMakeLists.txt | 27 | ||||
-rw-r--r-- | INSTALL.md | 20 | ||||
-rw-r--r-- | core/CMakeLists.txt | 15 | ||||
-rw-r--r-- | other/CMakeLists.txt | 4 | ||||
-rw-r--r-- | testing/CMakeLists.txt | 12 | ||||
-rw-r--r-- | testing/DHT_test.c | 2 |
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 | ||
16 | script: | 16 | script: |
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 | ||
22 | notifications: | 21 | notifications: |
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 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | 1 | cmake_minimum_required(VERSION 2.6.0) |
2 | 2 | ||
3 | #MinGW prints more warnings for -Wall than gcc does, thus causing build to fail | ||
3 | if(NOT WIN32) | 4 | if(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() |
8 | endif() | 9 | endif() |
9 | 10 | ||
10 | if(WIN32) | ||
11 | include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) | ||
12 | endif() | ||
13 | |||
14 | set(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 | |||
21 | add_library(core ${core_sources}) | ||
22 | |||
23 | macro(linkCoreLibraries exe_name) | 11 | macro(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() |
32 | endmacro() | 22 | endmacro() |
33 | 23 | ||
34 | cmake_policy(SET CMP0011 NEW) | 24 | cmake_policy(SET CMP0011 NEW) |
35 | 25 | ||
36 | ADD_SUBDIRECTORY(testing) | 26 | add_subdirectory(core) |
37 | ADD_SUBDIRECTORY(other) \ No newline at end of file | 27 | add_subdirectory(testing) |
28 | add_subdirectory(other) \ No newline at end of file | ||
@@ -15,10 +15,11 @@ sudo ldconfig | |||
15 | 15 | ||
16 | Then clone this repo and run: | 16 | Then clone this repo and run: |
17 | ```bash | 17 | ```bash |
18 | cmake CMakeLists.txt | 18 | mkdir build && cd build |
19 | cmake .. | ||
19 | ``` | 20 | ``` |
20 | 21 | ||
21 | Then you can build any of the [`/testing`](/testing) and [`/other`](/other) by running: | 22 | Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running: |
22 | ```bash | 23 | ```bash |
23 | make name_of_c_file | 24 | make name_of_c_file |
24 | ``` | 25 | ``` |
@@ -27,6 +28,11 @@ For example, to build [`Messenger_test.c`](/others/Messenger_test.c) you would r | |||
27 | make Messenger_test | 28 | make Messenger_test |
28 | ``` | 29 | ``` |
29 | 30 | ||
31 | Or you could just build everything that is supported on your platform by running: | ||
32 | ```bash | ||
33 | make | ||
34 | ``` | ||
35 | |||
30 | ###OSX: | 36 | ###OSX: |
31 | 37 | ||
32 | Much the same as above, remember to install the latest XCode and the developer tools (Preferences -> Downloads -> Command Line Tools). | 38 | Much 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 | ||
57 | Navigate in `cmd` to this repo and run: | 63 | Navigate in `cmd` to this repo and run: |
58 | ```cmd | 64 | ```cmd |
59 | cmake -G "MinGW Makefiles" CMakeLists.txt | 65 | mkdir build && cd build |
66 | cmake -G "MinGW Makefiles" .. | ||
60 | ``` | 67 | ``` |
61 | 68 | ||
62 | Then you can build any of the [`/testing`](/testing) and [`/other`](/other) by running: | 69 | Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running: |
63 | ```cmd | 70 | ```cmd |
64 | mingw32-make name_of_c_file | 71 | mingw32-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 |
68 | mingw32-make Messenger_test | 75 | mingw32-make Messenger_test |
69 | ``` | 76 | ``` |
77 | |||
78 | Or you could just build everything that is supported on your platform by running: | ||
79 | ```bash | ||
80 | mingw32-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 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | ||
2 | project(core C) | ||
3 | |||
4 | if(WIN32) | ||
5 | include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) | ||
6 | endif() | ||
7 | |||
8 | set(core_sources | ||
9 | DHT.c | ||
10 | network.c | ||
11 | Lossless_UDP.c | ||
12 | net_crypto.c | ||
13 | Messenger.c) | ||
14 | |||
15 | add_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 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | ||
2 | |||
3 | cmake_policy(SET CMP0011 NEW) | ||
4 | |||
1 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake) | 5 | include(${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 @@ | |||
1 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_cryptosendfiletest.cmake) | 1 | cmake_minimum_required(VERSION 2.6.0) |
2 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_sendfiletest.cmake) | 2 | |
3 | cmake_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) | ||
3 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake) | 7 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake) |
4 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) | 8 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) |
5 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) | 9 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) |
6 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) | 10 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) |
7 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) \ No newline at end of file | 11 | if(NOT WIN32) |
12 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) | ||
13 | endif() | ||
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 |