Merge pull request #84 from nurupo/master

Improved build system
This commit is contained in:
irungentoo 2013-07-22 04:09:45 -07:00
commit 11891e2475
7 changed files with 58 additions and 31 deletions

View File

@ -8,16 +8,15 @@ before_script:
- cd libsodium
- git checkout tags/0.4.2
- ./autogen.sh
- ./configure && make -j3 check
- ./configure && make check -j3
- sudo make install
- sudo ldconfig
- cd ..
script:
- cmake CMakeLists.txt
- make DHT_bootstrap -j3
- make Messenger_test -j3
- make nTox -j3
- mkdir build && cd build
- cmake ..
- make -j3
notifications:
email: false

View File

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 2.6.0)
#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
if(NOT WIN32)
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====")
@ -7,21 +8,10 @@ if(NOT WIN32)
endif()
endif()
macro(linkCoreLibraries exe_name)
add_dependencies(${exe_name} core)
if(WIN32)
include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
endif()
set(core_sources
core/DHT.c
core/network.c
core/Lossless_UDP.c
core/net_crypto.c
core/Messenger.c)
add_library(core ${core_sources})
macro(linkCoreLibraries exe_name)
if(WIN32)
target_link_libraries(${exe_name} core
${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a
ws2_32)
@ -33,5 +23,6 @@ endmacro()
cmake_policy(SET CMP0011 NEW)
ADD_SUBDIRECTORY(testing)
ADD_SUBDIRECTORY(other)
add_subdirectory(core)
add_subdirectory(testing)
add_subdirectory(other)

View File

@ -15,10 +15,11 @@ sudo ldconfig
Then clone this repo and run:
```bash
cmake CMakeLists.txt
mkdir build && cd build
cmake ..
```
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) by running:
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
```bash
make name_of_c_file
```
@ -27,6 +28,11 @@ For example, to build [`Messenger_test.c`](/others/Messenger_test.c) you would r
make Messenger_test
```
Or you could just build everything that is supported on your platform by running:
```bash
make
```
###OSX:
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://
Navigate in `cmd` to this repo and run:
```cmd
cmake -G "MinGW Makefiles" CMakeLists.txt
mkdir build && cd build
cmake -G "MinGW Makefiles" ..
```
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) by running:
Then you can build any of the [`/testing`](/testing) and [`/other`](/other) that are currently supported on your platform by running:
```cmd
mingw32-make name_of_c_file
```
@ -67,3 +74,8 @@ For example, to build [`Messenger_test.c`](/others/Messenger_test.c) you would r
```cmd
mingw32-make Messenger_test
```
Or you could just build everything that is supported on your platform by running:
```bash
mingw32-make
```

15
core/CMakeLists.txt Normal file
View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.6.0)
project(core C)
if(WIN32)
include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/)
endif()
set(core_sources
DHT.c
network.c
Lossless_UDP.c
net_crypto.c
Messenger.c)
add_library(core ${core_sources})

View File

@ -1 +1,5 @@
cmake_minimum_required(VERSION 2.6.0)
cmake_policy(SET CMP0011 NEW)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake)

View File

@ -1,7 +1,13 @@
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_cryptosendfiletest.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_sendfiletest.cmake)
cmake_minimum_required(VERSION 2.6.0)
cmake_policy(SET CMP0011 NEW)
#include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_cryptosendfiletest.cmake)
#include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_sendfiletest.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake)
if(NOT WIN32)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake)
endif()

View File

@ -1,7 +1,7 @@
/* DHT test
* A file with a main that runs our DHT for testing.
*
* 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
* 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
*
* Command line arguments are the ip, port and public key of a node.
* EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA