Add and use CMake build script

Also, fix the hstox build that was taking half an hour. It now takes 5 minutes.
Also, perform distcheck on travis to ensure that make dist works. It's not
actually failing the build at the moment due to broken tests.
This commit is contained in:
iphydf 2016-08-10 12:28:33 +01:00
parent 459f8f2013
commit b5cfd33340
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
10 changed files with 207 additions and 29 deletions

3
.gitignore vendored
View File

@ -10,6 +10,9 @@ Thumbs.db
*.tmp
# Make
/_build
/_install
/tox-0.0.0*
CMakeCache.txt
CMakeFiles
Makefile

View File

@ -1,22 +1,23 @@
language: c
compiler:
- clang
- gcc
env:
matrix:
# - BUILD=hstox
- BUILD=toxcore
matrix:
include:
- env: BUILD=hstox
language: haskell
ghc: 7.8
- env: BUILD=toxcore
compiler: clang
- env: BUILD=toxcore
compiler: gcc
- env: BUILD=autotools
compiler: clang
addons:
apt:
sources:
- avsm
- hvr-ghc
packages:
- cabal-install-1.22
- check
- ghc-7.10.3
- libvpx-dev
- opam # For apidsl and Frama-C.
- texinfo # For libconfig.
@ -28,9 +29,6 @@ cache:
- $HOME/cache
install:
# Set up PATH for the /opt packages.
- export PATH=/opt/cabal/1.22/bin:$PATH
- export PATH=/opt/ghc/7.10.3/bin:$PATH
# Globally used environment variables.
- export CACHE_DIR=$HOME/cache
- export OPAMROOT=$CACHE_DIR/.opam

158
CMakeLists.txt Normal file
View File

@ -0,0 +1,158 @@
cmake_minimum_required(VERSION 2.8.6)
project(toxcore)
include(CTest)
################################################################################
#
# :: Dependencies and configuration.
#
################################################################################
set(CMAKE_MACOSX_RPATH ON)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_library(UTIL_LIBRARIES util)
pkg_search_module(LIBSODIUM REQUIRED libsodium)
pkg_search_module(CHECK REQUIRED check)
pkg_search_module(OPUS REQUIRED opus)
pkg_search_module(VPX REQUIRED vpx)
link_directories(${LIBSODIUM_LIBRARY_DIRS})
link_directories(${CHECK_LIBRARY_DIRS})
link_directories(${OPUS_LIBRARY_DIRS})
link_directories(${VPX_LIBRARY_DIRS})
include_directories(${LIBSODIUM_INCLUDE_DIRS})
include_directories(${CHECK_INCLUDE_DIRS})
include_directories(${OPUS_INCLUDE_DIRS})
include_directories(${VPX_INCLUDE_DIRS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBSODIUM_CFLAGS_OTHER}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CHECK_CFLAGS_OTHER}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPUS_CFLAGS_OTHER}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VPX_CFLAGS_OTHER}")
################################################################################
#
# :: Libraries.
#
################################################################################
add_library(toxcore SHARED
toxcore/DHT.c
toxcore/LAN_discovery.c
toxcore/Messenger.c
toxcore/TCP_client.c
toxcore/TCP_connection.c
toxcore/TCP_server.c
toxcore/assoc.c
toxcore/crypto_core.c
toxcore/friend_connection.c
toxcore/friend_requests.c
toxcore/group.c
toxcore/list.c
toxcore/logger.c
toxcore/net_crypto.c
toxcore/network.c
toxcore/onion.c
toxcore/onion_announce.c
toxcore/onion_client.c
toxcore/ping.c
toxcore/ping_array.c
toxcore/tox.c
toxcore/util.c)
target_link_libraries(toxcore ${LIBSODIUM_LIBRARIES})
target_link_libraries(toxcore rt)
add_library(toxav SHARED
toxav/audio.c
toxav/bwcontroller.c
toxav/group.c
toxav/msi.c
toxav/rtp.c
toxav/toxav.c
toxav/toxav_old.c
toxav/video.c)
target_link_libraries(toxav toxcore)
target_link_libraries(toxav ${OPUS_LIBRARIES})
target_link_libraries(toxav ${VPX_LIBRARIES})
add_library(toxdns SHARED
toxdns/toxdns.c)
target_link_libraries(toxdns toxcore)
add_library(toxencryptsave SHARED
toxencryptsave/toxencryptsave.c)
target_link_libraries(toxencryptsave toxcore)
################################################################################
#
# :: Automated regression tests.
#
################################################################################
function(auto_test target)
if(CHECK_FOUND)
add_executable(auto_${target} auto_tests/${target}.c)
target_link_libraries(auto_${target}
toxcore
toxav
toxencryptsave
${CHECK_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
add_test(${target} auto_${target})
endif()
endfunction()
auto_test(TCP_test)
auto_test(assoc_test)
auto_test(crypto_test)
auto_test(dht_test)
auto_test(encryptsave_test)
# This test doesn't link (missing symbol).
#auto_test(friends_test)
auto_test(messenger_test)
auto_test(network_test)
auto_test(onion_test)
auto_test(skeleton_test)
auto_test(tox_test)
auto_test(toxav_basic_test)
auto_test(toxav_many_test)
################################################################################
#
# :: Test programs.
#
################################################################################
add_executable(nTox testing/nTox.c)
target_link_libraries(nTox toxcore ncurses ${CMAKE_THREAD_LIBS_INIT})
add_executable(DHT_test testing/DHT_test.c)
target_link_libraries(DHT_test toxcore ${CMAKE_THREAD_LIBS_INIT})
add_executable(Messenger_test testing/Messenger_test.c)
target_link_libraries(Messenger_test toxcore ${CMAKE_THREAD_LIBS_INIT})
add_executable(dns3_test testing/dns3_test.c)
target_link_libraries(dns3_test toxdns ${CMAKE_THREAD_LIBS_INIT})
add_executable(tox_sync testing/tox_sync.c)
target_link_libraries(tox_sync toxcore ${CMAKE_THREAD_LIBS_INIT})
add_executable(tox_shell testing/tox_shell.c)
target_link_libraries(tox_shell toxcore ${CMAKE_THREAD_LIBS_INIT} ${UTIL_LIBRARIES})
add_executable(irc_syncbot testing/irc_syncbot.c)
target_link_libraries(irc_syncbot toxcore ${CMAKE_THREAD_LIBS_INIT})

View File

@ -108,3 +108,4 @@ encryptsave_test_LDADD = $(AUTOTEST_LDADD)
EXTRA_DIST += $(top_srcdir)/auto_tests/friends_test.c
EXTRA_DIST += $(top_srcdir)/auto_tests/helpers.h

View File

@ -0,0 +1,3 @@
#!/bin/sh
set -e -x

View File

@ -0,0 +1 @@
toxcore-install

20
other/travis/autotools-script Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e -x
# Build toxcore and run tests.
./autogen.sh
./configure \
--with-libsodium-libs=$CACHE_DIR/lib \
--with-libsodium-headers=$CACHE_DIR/include \
--enable-daemon \
--enable-logging \
--enable-ntox
make -j `nproc`
# This doesn't currently work on Travis, because the autotools build is broken.
# It does not look up libsodium by pkg-config, so without the --with flags it
# won't find it. We don't care that much about distcheck at this point, but we
# do care whether it configures/builds at all, which is exercised by the make
# call above. Tests are executed by the cmake build.
make distcheck -j `nproc` || true

View File

@ -2,6 +2,8 @@
set -e -x
BUILD_DIR=_build
# Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h.
../apidsl/_build/apigen.native other/apidsl/tox.in.h | $ASTYLE --options=other/astyle/astylerc > toxcore/tox.h
../apidsl/_build/apigen.native other/apidsl/toxav.in.h | $ASTYLE --options=other/astyle/astylerc > toxav/toxav.h
@ -10,18 +12,10 @@ $ASTYLE --options=other/astyle/astylerc `find . -name "*.[ch]" -and -not -name "
git diff --exit-code
# Build toxcore and run tests.
./autogen.sh
./configure \
--with-libsodium-libs=$CACHE_DIR/lib \
--with-libsodium-headers=$CACHE_DIR/include \
--enable-daemon \
--enable-logging \
--enable-ntox \
CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1"
export CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1"
cmake -B$BUILD_DIR -H.
make
make check
if [ -f build/test-suite.log ]; then
cat build/test-suite.log
fi
make dist
export CTEST_OUTPUT_ON_FAILURE=1
make -C $BUILD_DIR -j `nproc`
make -C $BUILD_DIR -j `nproc` test

View File

@ -22,7 +22,7 @@
#ifndef AUDIO_H
#define AUDIO_H
#include <opus.h>
#include <opus/opus.h>
#include <pthread.h>
#include "toxav.h"

View File

@ -19,7 +19,7 @@
*/
/* Audio encoding/decoding */
#include <opus.h>
#include <opus/opus.h>
#include "../toxcore/group.h"