Add cmake building support to Travis CI To make it easier to extend the CI support and to be able to execute the contained tests locally, a dedicated shell script tools/ci_build.sh was added to execute the tests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
diff --git a/.travis.yml b/.travis.yml
index 3205fa9..4df8ce7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,8 +9,11 @@ addons:
packages:
- gcc-mingw-w64
- wine
+ - cmake
+
+env:
+ - ci_buildsys=cmake
+ - ci_buildsys=Makefile
script:
- - ./configure --enable-shared --enable-static --enable-wine --cross-prefix=${CC%-*}-
- - make
- - make test
+ - ci_target=${CC%-*} ./tools/ci-build.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c6fe4c..ec52939 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ endif ()
project (dlfcn-win32 C)
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
include(Macros)
option(BUILD_SHARED_LIBS "shared/static libs" ON)
diff --git a/tools/ci-build.sh b/tools/ci-build.sh
new file mode 100755
index 0000000..a7d79b1
--- /dev/null
+++ b/tools/ci-build.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+set -euo pipefail
+set -x
+
+# ci_buildsys:
+# Build system under test: Makefile or cmake
+: "${ci_buildsys:=cmake}"
+
+# ci_target:
+# target to build for
+: "${ci_target:=${CROSS_COMPILE%-}}"
+
+install_prefix=$(${ci_target}-gcc --print-sysroot)/${ci_target}
+
+case "$ci_buildsys" in
+ (Makefile)
+ ./configure --enable-shared --enable-static --enable-wine --cross-prefix=${ci_target}-
+ make
+ make test
+ ;;
+
+ (cmake)
+ cmake --version
+ rm -rf build
+ mkdir build
+ cd build
+ cmake \
+ --no-warn-unused-cli \
+ -DCMAKE_FIND_ROOT_PATH=$install_prefix \
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DCMAKE_C_COMPILER=$(which ${ci_target}-gcc) \
+ -DCMAKE_SYSTEM_PROCESSOR=${ci_target%-*-*} \
+ -DCMAKE_CROSSCOMPILING=TRUE \
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
+ -DCMAKE_SYSTEM_NAME=Windows \
+ -DBUILD_TESTS=1 \
+ -DENABLE_WINE=ON \
+ -DWINE_EXECUTABLE=/usr/bin/wine \
+ ..
+ make
+ ctest --output-on-failure
+ make install DESTDIR=$(pwd)/DESTDIR
+ ;;
+esac
+
+# vim:set sw=4 sts=4 et: