From ef0efd72b51a44d30272dccffdc365165d385291 Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Wed, 17 Jul 2013 18:06:05 -0400 Subject: [PATCH] Improved build system --- .gitignore | 6 +++ .travis.yml | 4 +- CMakeLists.txt | 51 +++++++++++---------- other/CMakeLists.txt | 1 + other/cmake/DHT_bootstrap.cmake | 10 ++++ testing/CMakeLists.txt | 7 +++ testing/cmake/DHT_cryptosendfiletest.cmake | 10 ++++ testing/cmake/DHT_sendfiletest.cmake | 10 ++++ testing/cmake/DHT_test.cmake | 10 ++++ testing/cmake/Lossless_UDP_testclient.cmake | 10 ++++ testing/cmake/Lossless_UDP_testserver.cmake | 10 ++++ testing/cmake/Messenger_test.cmake | 10 ++++ testing/cmake/nTox.cmake | 12 +++++ 13 files changed, 125 insertions(+), 26 deletions(-) create mode 100644 other/CMakeLists.txt create mode 100644 other/cmake/DHT_bootstrap.cmake create mode 100644 testing/CMakeLists.txt create mode 100644 testing/cmake/DHT_cryptosendfiletest.cmake create mode 100644 testing/cmake/DHT_sendfiletest.cmake create mode 100644 testing/cmake/DHT_test.cmake create mode 100644 testing/cmake/Lossless_UDP_testclient.cmake create mode 100644 testing/cmake/Lossless_UDP_testserver.cmake create mode 100644 testing/cmake/Messenger_test.cmake create mode 100644 testing/cmake/nTox.cmake diff --git a/.gitignore b/.gitignore index 263cdb90..0b178e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,9 @@ //nacl build nacl/build/ build + +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +install_manifest.txt diff --git a/.travis.yml b/.travis.yml index a304a0a4..fe62910d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,9 @@ before_script: script: - cmake CMakeLists.txt - - make -j3 + - make DHT_bootstrap -j3 + - make Messenger_test -j3 + - make nTox -j3 notifications: email: false diff --git a/CMakeLists.txt b/CMakeLists.txt index ec474ffb..db417a2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 2.6.0) -project(TOX C) -set(exe_name toxMessengerTest) +if(WIN32) + include_directories(${CMAKE_HOME_DIRECTORY}/sodium/include/) +endif() set(core_sources core/DHT.c @@ -9,29 +10,29 @@ set(core_sources core/Lossless_UDP.c core/net_crypto.c core/Messenger.c) -if(WIN32) - set(test_sources - testing/Messenger_test.c) -else() - set(test_sources - testing/nTox.c) - #testing/Messenger_test.c) -endif() -add_executable(${exe_name} - ${core_sources} - ${test_sources}) +add_library(core ${core_sources}) -if(WIN32) - include_directories(${TOX_SOURCE_DIR}/sodium/include/) - target_link_libraries(${exe_name} ws2_32 - ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a) -else() - target_link_libraries(${exe_name} sodium) - target_link_libraries(${exe_name} ncurses) -endif() +macro(linkCoreLibraries exe_name) + if(WIN32) + target_link_libraries(${exe_name} core + ${CMAKE_SOURCE_DIR}/sodium/lib/libsodium.a + ws2_32) + else() + target_link_libraries(${exe_name} core + sodium) + endif() +endmacro() -if(CMAKE_COMPILER_IS_GNUCC) - message(STATUS "==== GCC detected - Adding compiler flags ====") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") -endif() + +macro(addCompilerFlags) + 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 ====") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") + endif() + endif() +endmacro() + +ADD_SUBDIRECTORY(testing) +ADD_SUBDIRECTORY(other) \ No newline at end of file diff --git a/other/CMakeLists.txt b/other/CMakeLists.txt new file mode 100644 index 00000000..22dc8e25 --- /dev/null +++ b/other/CMakeLists.txt @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake) diff --git a/other/cmake/DHT_bootstrap.cmake b/other/cmake/DHT_bootstrap.cmake new file mode 100644 index 00000000..f978baa4 --- /dev/null +++ b/other/cmake/DHT_bootstrap.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(DHT_bootstrap C) + +set(exe_name DHT_bootstrap) + +add_executable(${exe_name} + DHT_bootstrap.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt new file mode 100644 index 00000000..bb599b86 --- /dev/null +++ b/testing/CMakeLists.txt @@ -0,0 +1,7 @@ +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 diff --git a/testing/cmake/DHT_cryptosendfiletest.cmake b/testing/cmake/DHT_cryptosendfiletest.cmake new file mode 100644 index 00000000..9396d91a --- /dev/null +++ b/testing/cmake/DHT_cryptosendfiletest.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(DHT_cryptosendfiletest C) + +set(exe_name DHT_cryptosendfiletest) + +add_executable(${exe_name} + DHT_cryptosendfiletest.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/cmake/DHT_sendfiletest.cmake b/testing/cmake/DHT_sendfiletest.cmake new file mode 100644 index 00000000..c7595224 --- /dev/null +++ b/testing/cmake/DHT_sendfiletest.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(DHT_sendfiletest C) + +set(exe_name DHT_sendfiletest) + +add_executable(${exe_name} + DHT_sendfiletest.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/cmake/DHT_test.cmake b/testing/cmake/DHT_test.cmake new file mode 100644 index 00000000..e5c18c03 --- /dev/null +++ b/testing/cmake/DHT_test.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(DHT_test C) + +set(exe_name DHT_test) + +add_executable(${exe_name} + DHT_test.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/cmake/Lossless_UDP_testclient.cmake b/testing/cmake/Lossless_UDP_testclient.cmake new file mode 100644 index 00000000..375bb733 --- /dev/null +++ b/testing/cmake/Lossless_UDP_testclient.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(Lossless_UDP_testclient C) + +set(exe_name Lossless_UDP_testclient) + +add_executable(${exe_name} + Lossless_UDP_testclient.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/cmake/Lossless_UDP_testserver.cmake b/testing/cmake/Lossless_UDP_testserver.cmake new file mode 100644 index 00000000..fe16e937 --- /dev/null +++ b/testing/cmake/Lossless_UDP_testserver.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(Lossless_UDP_testserver C) + +set(exe_name Lossless_UDP_testserver) + +add_executable(${exe_name} + Lossless_UDP_testserver.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/cmake/Messenger_test.cmake b/testing/cmake/Messenger_test.cmake new file mode 100644 index 00000000..2848818b --- /dev/null +++ b/testing/cmake/Messenger_test.cmake @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.6.0) +project(Messenger_test C) + +set(exe_name Messenger_test) + +add_executable(${exe_name} + Messenger_test.c) + +linkCoreLibraries(${exe_name}) +addCompilerFlags() diff --git a/testing/cmake/nTox.cmake b/testing/cmake/nTox.cmake new file mode 100644 index 00000000..814b1427 --- /dev/null +++ b/testing/cmake/nTox.cmake @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.6.0) +project(nTox C) + +set(exe_name nTox) + +add_executable(${exe_name} + nTox.c) + +target_link_libraries(${exe_name} ncurses) + +linkCoreLibraries(${exe_name}) +addCompilerFlags()