diff --git a/.travis.yml b/.travis.yml index 9f62c84c..0a294bf1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 505983f2..c16ce6fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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,31 +8,21 @@ if(NOT WIN32) endif() endif() -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) + add_dependencies(${exe_name} core) if(WIN32) - target_link_libraries(${exe_name} core - ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a + include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) + target_link_libraries(${exe_name} core + ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a ws2_32) else() - target_link_libraries(${exe_name} core + target_link_libraries(${exe_name} core sodium) endif() endmacro() cmake_policy(SET CMP0011 NEW) -ADD_SUBDIRECTORY(testing) -ADD_SUBDIRECTORY(other) \ No newline at end of file +add_subdirectory(core) +add_subdirectory(testing) +add_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 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 +``` 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 @@ +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}) 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 @@ +cmake_minimum_required(VERSION 2.6.0) + +cmake_policy(SET CMP0011 NEW) + 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 @@ -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) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) \ No newline at end of file +if(NOT WIN32) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) +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 @@ /* 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