Test a few cmake option combinations before the build.

This takes a few seconds but allows us to cover cases that aren't checked
often.
This commit is contained in:
iphydf 2017-01-04 21:15:48 +00:00
parent 69e1b99b1d
commit 0a61d11085
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 32 additions and 7 deletions

View File

@ -596,11 +596,11 @@ endif()
#
################################################################################
find_program(SH NAMES sh dash bash zsh)
find_program(SHELL NAMES sh dash bash zsh)
if(SH)
if(SHELL)
execute_process(
COMMAND ${SH} ${toxcore_SOURCE_DIR}/other/version-sync
COMMAND ${SHELL} ${toxcore_SOURCE_DIR}/other/version-sync
${toxcore_SOURCE_DIR}
${PROJECT_VERSION_MAJOR}
${PROJECT_VERSION_MINOR}
@ -615,7 +615,7 @@ endif()
function(make_version_script header ns lib)
execute_process(
COMMAND ${SH} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '\\w+' | sort -u"
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '\\w+' | sort -u"
OUTPUT_VARIABLE ${lib}_SYMS
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "\n" ";" ${lib}_SYMS ${${lib}_SYMS})
@ -641,7 +641,7 @@ if(WIN32 OR APPLE)
set(STRICT_ABI OFF)
endif()
if(STRICT_ABI AND SH)
if(STRICT_ABI AND SHELL AND ENABLE_SHARED)
if(BUILD_TOXAV)
make_version_script(${toxcore_SOURCE_DIR}/toxav/toxav.h toxav toxav)
endif()

View File

@ -2,6 +2,14 @@ option(ENABLE_SHARED "Build shared (dynamic) libraries for all modules" ON)
option(ENABLE_STATIC "Build static libraries for all modules" ON)
option(COMPILE_AS_CXX "Compile all C code as C++ code" OFF)
if(NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
message(WARNING
"Both static and shared libraries are disabled; "
"enabling only shared libraries. Use -DENABLE_SHARED or -DENABLE_STATIC to "
"select one manually.")
set(ENABLE_SHARED ON)
endif()
find_package(PkgConfig REQUIRED)
if(COMPILE_AS_CXX)

View File

@ -3,9 +3,26 @@
# Enable test coverage recording.
export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
set_opt() {
opts="$opts -D$1="`expr ON \& \( $i % 2 \) \| OFF`
set +e # result can be 0
i=`expr $i / 2`
set -e
}
# Try some combinations of cmake options.
for i in `seq 0 7`; do
set +x
opts="$CMAKE_EXTRA_FLAGS -DWARNINGS=OFF"
set_opt STRICT_ABI
set_opt ENABLE_STATIC
set_opt ENABLE_SHARED
set -x
RUN $CMAKE -B$BUILD_DIR -H. $opts
rm -rf $BUILD_DIR
done
# Build toxcore and run tests.
# TODO(iphydf): Enable ASAN. It currently has some bad interactions with gcov,
# so it's disabled on Travis.
RUN $CMAKE \
-B$BUILD_DIR \
-H. \