From 0a61d1108547513211560e66809479cab5082ede Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 4 Jan 2017 21:15:48 +0000 Subject: [PATCH] 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. --- CMakeLists.txt | 10 +++++----- cmake/ModulePackage.cmake | 8 ++++++++ other/travis/toxcore-script | 21 +++++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9888601..f0707a76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index 26c6c39a..613633ba 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake @@ -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) diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script index d25dc135..9b81b863 100755 --- a/other/travis/toxcore-script +++ b/other/travis/toxcore-script @@ -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. \