dockcross/imagefiles/install-cmake.sh
Jean-Christophe Fillion-Robin 0552c37fea
common.docker: Improve OpenSSL and CMake install introducing helper scripts
To accommodate the requirements associated with x86 and x64 images, the
command building OpenSSL and CMake became overly complex and hard to
maintain.

This commit has multiple purposes:

(1) simplify common.docker

(2) fix the building of 64-bit shared libraries against the static openssl
libraries by passing the -fPIC flag.

(3) ensure [many]linux-x86 and [many]linux-x64 images have an up-to-date
OpenSSL install. Openssl static libraries are installed in /usr

(4) simplify and speedup CMake build avoiding the second build with
explicit -DCMAKE_USE_OPENSSL:BOOL=ON. Indeed, configuring CMake on Linux
already looks for OpenSSL.

(5) speedup download of CMake source directly downloading the archive
corresponding to the revision.

(6) test CMake by:
  - running CMake.FileDownload test
  - trying to download a file served over https
2016-11-21 06:08:30 -05:00

96 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
#
# Configure, build and install CMake
#
# Usage:
#
# install-cmake.sh [-32]
#
# Options:
#
# -32 Build CMake as a 32-bit executable
#
# Notes:
#
# * build directory is /usr/src/CMake
#
# * install directory is /usr
#
# * after installation, archive, source and build directories are removed
#
set -e
set -o pipefail
WRAPPER=""
CONFIG_FLAG=""
SUFFIX=64
while [ $# -gt 0 ]; do
case "$1" in
-32)
WRAPPER="linux32"
CONFIG_FLAG="-m32"
SUFFIX=32
;;
*)
echo "Usage: Usage: ${0##*/} [-32]"
exit 1
;;
esac
shift
done
cd /usr/src
# Download
CMAKE_REV=ab2ae4823c3b60347825da4b851cd4e676f8bed1
wget https://github.com/kitware/cmake/archive/$CMAKE_REV.tar.gz -O CMake.tar.gz
mkdir CMake
tar -xzvf ./CMake.tar.gz --strip-components=1 -C ./CMake
mkdir /usr/src/CMake-build
pushd /usr/src/CMake-build
NUM_PROCESSOR=$(grep -c processor /proc/cpuinfo)
# Configure boostrap
${WRAPPER} /usr/src/CMake/bootstrap \
--parallel=$NUM_PROCESSOR \
--prefix=/usr
# Build and Install
${WRAPPER} make install -j$NUM_PROCESSOR
# Test
ctest -R CMake.FileDownload
# Write test script
cat <<EOF > cmake-test-https-download.cmake
file(
DOWNLOAD https://raw.githubusercontent.com/Kitware/CMake/master/README.rst /tmp/README.rst
STATUS status
)
list(GET status 0 error_code)
list(GET status 1 error_msg)
if(error_code)
message(FATAL_ERROR "error: Failed to download ${url} - ${error_msg}")
else()
message(STATUS "CMake: HTTPS download works")
endif()
file(REMOVE /tmp/README.rst)
EOF
# Execute test script
cmake -P cmake-test-https-download.cmake
rm cmake-test-https-download.cmake
popd
rm -rf CMake*