freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 30fdfe6 6/6: [cmake] Add script to test the config mo


From: Werner LEMBERG
Subject: [freetype2] master 30fdfe6 6/6: [cmake] Add script to test the config module.
Date: Fri, 27 Nov 2015 22:17:02 +0000

branch: master
commit 30fdfe6c6624d0fa4d52d4291beb70c9e2a353b1
Author: Tamas Kenez <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [cmake] Add script to test the config module.
    
    * builds/cmake/testbuild.sh: New file.
---
 ChangeLog                 |    6 ++
 builds/cmake/testbuild.sh |  157 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 163 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 33c9637..85e00c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2015-11-27  Tamas Kenez  <address@hidden>
 
+       [cmake] Add script to test the config module.
+
+       * builds/cmake/testbuild.sh: New file.
+
+2015-11-27  Tamas Kenez  <address@hidden>
+
        * CMakeLists.txt: Create `freetype-config.cmake' config module.
 
 2015-11-27  Tamas Kenez  <address@hidden>
diff --git a/builds/cmake/testbuild.sh b/builds/cmake/testbuild.sh
new file mode 100755
index 0000000..5af669c
--- /dev/null
+++ b/builds/cmake/testbuild.sh
@@ -0,0 +1,157 @@
+#!/bin/sh -e
+
+# Copyright 2015 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT.  By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+# This script tests the CMake build. Simply run
+#
+#     builds/cmake/testbuild.sh
+#
+# or
+#
+#     BUILD_SHARED_LIBS=1 builds/cmake/testbuild.sh
+#
+# The script:
+#
+# - builds the main CMakeLists.txt
+# - builds and runs a small test app in a separate build tree so
+#   the config-module is tested, too
+#
+# Options (environment variables):
+#
+# - The variable BUILD_SHARED_LIBS will be forwarded to the CMake project
+#   that builds the library.
+#
+
+
+# prepare temporary dir
+
+cd `dirname $0`/../..
+ftdir=`pwd`
+tmpdir=/tmp/freetype-cmake-testbuild
+rm -rf $tmpdir
+mkdir -p $tmpdir
+
+
+# build and install freetype
+
+if test -n "$BUILD_SHARED_LIBS"; then
+  bsl=-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS
+else
+  bsl=-UBUILD_SHARED_LIBS
+fi
+
+build_opts="-DWITH_ZLIB=0 \
+            -DWITH_BZip2=0 \
+            -DWITH_PNG=0 \
+            -DWITH_HarfBuzz=0 \
+            $bsl \
+            -DCMAKE_INSTALL_PREFIX=$tmpdir/out"
+
+(set -x; cmake -H$ftdir \
+               -B$tmpdir/ftb \
+               -DCMAKE_BUILD_TYPE=Debug \
+               $build_opts)
+(set -x; cmake --build $tmpdir/ftb \
+               --config Debug \
+               --target install)
+
+(set -x; cmake $tmpdir/ftb \
+               -DCMAKE_BUILD_TYPE=Release)
+(set -x; cmake --build $tmpdir/ftb \
+               --config Release \
+               --target install \
+               --clean-first)
+
+
+# create test project CMakeLists.txt
+
+cat >$tmpdir/CMakeLists.txt << END
+cmake_minimum_required(VERSION 2.6)
+project(freetype-cmake-testbuild)
+
+find_package(Freetype REQUIRED CONFIG)
+
+add_executable(freetype-cmake-test main.c)
+target_link_libraries(freetype-cmake-test freetype)
+
+enable_testing()
+add_test(freetype-cmake-test freetype-cmake-test)
+END
+
+
+# create test project main.c
+
+cat >$tmpdir/main.c << END
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+
+FT_Library library;
+
+
+int main(int argc,
+         char*argv[])
+{
+  FT_Error error;
+  FT_Int major = 0;
+  FT_Int minor = 0;
+  FT_Int patch = 0;
+
+  error = FT_Init_FreeType(&library);
+  if (error)
+    return EXIT_FAILURE;
+
+  FT_Library_Version(library, &major, &minor, &patch);
+  if (major != FREETYPE_MAJOR
+      || minor != FREETYPE_MINOR
+      || patch != FREETYPE_PATCH)
+    return EXIT_FAILURE;
+
+  printf("FT_Library_Version: %d.%d.%d\n", major, minor, patch);
+
+  error = FT_Done_FreeType(library);
+  if (error)
+    return EXIT_FAILURE;
+
+  return EXIT_SUCCESS;
+}
+END
+
+
+# build and test
+
+mkdir -p $tmpdir/tb
+cd $tmpdir/tb
+
+LD_LIBRARY_PATH=$tmpdir/out/lib:$LD_LIBRARY_PATH
+DYLD_LIBRARY_PATH=$tmpdir/out/lib:$DYLD_LIBRARY_PATH
+export LD_LIBRARY_PATH
+export DYLD_LIBRARY_PATH
+
+(set -x; cmake $tmpdir \
+               -DCMAKE_BUILD_TYPE=Debug \
+               -DCMAKE_PREFIX_PATH=$tmpdir/out)
+(set -x; cmake --build . \
+               --config Debug)
+(set -x; ctest -V -C Debug)
+
+(set -x; cmake . \
+               -DCMAKE_BUILD_TYPE=Release)
+(set -x; cmake --build . \
+               --config Release \
+               --clean-first)
+(set -x; ctest -V -C Release)
+
+rm -rf $tmpdir
+
+# EOF



reply via email to

[Prev in Thread] Current Thread [Next in Thread]