glew/cmake-testbuild.sh
Tamas Kenez d2e6823451 cmake: install config-module
Installs a config module if CMake verion >= 2.8.12.
The config-module creates the import library targets
built in the project (glew, glew_s, glewmx, glewmx_s)
but in accordance with the FindGLEW module shipped with
CMake, it also creates GLEW::GLEW and GLEW::GLEWMX.

GLEW::GLEW and GLEW::GLEWMX will be simply copies of
glew/glewmx or glew_s/glewmx_s. If both versions are
available they alias the shared versions.

The default behaviour can be changed either when installing
or when using the package:

- Set BUILD_SHARED_LIBS to OFF or ON when building and
  installing GLEW. This controls which libraries
  (shared or static) will be installed (and not which
  will be built).
- Set GLEW_USE_STATIC_LIBS to OFF or ON before calling
  `find_package(GLEW CONFIG REQUIRED)` to force
  the config-module to create GLEW::GLEW and GLEWMX
  as aliases to glew/glewmx or glew_s/glewmx_s

The script ./cmake-testbuild.sh is added to test the
CMake build and config-module. See instructions there.
2015-06-22 14:06:50 +02:00

71 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# This script tests the CMake build:
#
# - 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 and installs the GLEW libraries. Set BUILD_SHARED_LIBS to
# ON or OFF to install only static or shared libs. Leave it unset to
# install both.
#
# Note: BUILD_SHARED_LIBS controls only what to install not what to build.
#
# - GLEW_USE_STATIC_LIBS will be forwarded to the test project that calls
# `find_package` to find GLEW. Set GLEW_USE_STATIC LIBS to ON or OFF force
# finding the shared or static versions of GLEW. Leave it unset to find
# the shared or what is available.
#
# Examples:
#
# Build & install shared + static, find default (shared)
#
# ./cmake-testbuild.shh
#
# Build & install shared + static, find static
#
# GLEW_USE_STATIC_LIBS=ON ./cmake-testbuild.sh
#
# Install static only (still build both)
#
# BUILD_SHARED_LIBS=OFF ./cmake-testbuild.sh
#
set -ex
rm -rf out/include
rm -rf out/lib*
rm -rf out/bin
if [ -n "$BUILD_SHARED_LIBS" ]; then
bsl=-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS
else
bsl=-UBUILD_SHARED_LIBS
fi
if [ -n "$GLEW_USE_STATIC_LIBS" ]; then
gusl=-DGLEW_USE_STATIC_LIBS=$GLEW_USE_STATIC_LIBS
else
gusl=-UGLEW_USE_STATIC_LIBS
fi
cmake -Hbuild/cmake -Bout/build/glew -DCMAKE_INSTALL_PREFIX=${PWD}/out -DCMAKE_BUILD_TYPE=Debug $bsl
cmake --build out/build/glew --target install --config Debug
cmake out/build/glew -DCMAKE_BUILD_TYPE=Release
cmake --build out/build/glew --target install --config Release --clean-first
cmake -Hbuild/cmake/testbuild -Bout/build/cmake-testbuild -DCMAKE_INSTALL_PREFIX=${PWD}/out -DCMAKE_PREFIX_PATH=${PWD}/out -DCMAKE_BUILD_TYPE=Debug $gusl
cmake --build out/build/cmake-testbuild --target install --config Debug
cmake out/build/cmake-testbuild -DCMAKE_BUILD_TYPE=Release
cmake --build out/build/cmake-testbuild --target install --config Release --clean-first
export LD_LIBRARY_PATH=${PWD}/out/lib:$LD_LIBRARY_PATH
out/bin/cmake-test_d
out/bin/cmake-test