Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b6a34a4d authored by Thomas PRAMPART's avatar Thomas PRAMPART
Browse files

Unix: download specific version of cmake (if needed) in local dependencies...

Unix: download specific version of cmake (if needed) in local dependencies rather than installing an OS dependant one on the system.
parent 2464d52a
Branches
Tags
1 merge request!160Resolve "Update: Unix set fixed CMake version"
#!/usr/bin/perl
# Intended to be run from linux-install_dependencies.pl
# Intended to be run from linux-install_dependencies.pl which defines the dependencies_dir variable.
#
# Variables are wrt that parent scope
#
if (!$no_install && $distribution eq 'Ubuntu 14.04') {
# Install cmake 3.5.1 from source if it is not already
# This is because Ubuntu 14.04 only has an old version of cmake
if (-e "/usr/local/bin/cmake") {
print STDERR "Warning: cmake is already installed in /usr/local\n";
} else {
my $old_dir = Cwd::getcwd();
my $dependencies_dir = $FindBin::Bin . "/../dependencies";
my $cmake_build_folder = $dependencies_dir . "/cmake-build";
my $cmake_extracted_folder = $cmake_build_folder . "/cmake-3.5.1";
if (! -e $dependencies_dir) {
mkdir($dependencies_dir) or die("Failed to create directory [$dependencies_dir]");
}
if (! -e $cmake_build_folder) {
mkdir($cmake_build_folder) or die("Failed to create directory [$cmake_build_folder]");
}
chdir $cmake_build_folder;
if (! -e "cmake-3.5.1.tar.gz") {
system('wget "http://www.cmake.org/files/v3.5/cmake-3.5.1.tar.gz"');
($CHILD_ERROR != 0) and die ("Could not download the CMake sources [$CHILD_ERROR]");
}
if (! -e $cmake_extracted_folder) {
system('tar -xzf "cmake-3.5.1.tar.gz"');
($CHILD_ERROR != 0) and die ("Could not extract the CMake archive");
}
chdir $cmake_extracted_folder;
system("./configure");
($CHILD_ERROR != 0) and die("Failed to configure for cmake [$CHILD_ERROR]");
system("sudo make install");
($CHILD_ERROR != 0) and die("Failed make install cmake [$CHILD_ERROR]");
# Go back to the scripts folder
chdir $old_dir;
use strict;
use warnings;
use Getopt::Long;
use English;
use FindBin;
use File::Copy;
use File::Spec;
# Version of CMake to install if needed (latest as of 08/2020)
my $version_major = 3;
my $version_minor = 18;
my $version_patch = 1;
# Minimum version needed for the project.
# 3.12 for FindPython functionalities.
my $minimum_major = 3;
my $minimum_minor = 15;
my $install_dir = $dependencies_dir;
# Updating path with potentially installed cmake before looking for it.
if ("$dependencies_dir/cmake") {
print "Found cmake folder in deps\n";
my $path = $ENV{'PATH'};
$path = "$dependencies_dir/cmake/bin:$path";
$ENV{'PATH'} = $path;
#system("PATH=$dependencies_dir/cmake/bin:$PATH")
}
# Checking for CMake presence
my $major_found = 0;
my $minor_found = 0;
if (`which cmake`) {
`cmake --version` =~ /.*(\d)\.(\d\d)\.*/;
print "cmake version found: $1.$2\n";
$major_found = $1;
$minor_found = $2;
}
# Minimum cmake version required for the project: 3.12
if (int($major_found) < $minimum_major || int($minor_found) < $minimum_minor) {
my $old_dir = Cwd::getcwd();
my $cmake_archive = "cmake-${version_major}.${version_minor}.${version_patch}.tar.gz";
my $cmake_folder = "cmake-${version_major}.${version_minor}.${version_patch}";
print "CMake version too low. Installing newer one in $install_dir\n";
if (! -d $install_dir) {
mkdir($install_dir) or die("Failed to create directory [$install_dir]");
}
# Download
print "Downloading ${cmake_archive}\n";
system("wget http://www.cmake.org/files/v${version_major}.${version_minor}/${cmake_archive}") == 0
or die "Could not download the CMake sources - err $?";
# Extract
system("tar -xzf ${cmake_archive}") == 0
or die ("Could not extract the CMake archive - err $?");
# Configure, compile and install
chdir $cmake_folder;
system("./configure --prefix=$install_dir/cmake") == 0
or die("Failed to configure for cmake - err $?");
system("make install") == 0
or die ("Failed make install cmake - err $?");
# Go back to previous folder
chdir $old_dir;
#Clear
system("rm -r ${cmake_archive} ${cmake_folder}") == 0
or die ("Failed to clear after install - err $?");
}
doxygen
make
cmake
gcc
g++
libexpat1-dev
......
......@@ -43,7 +43,6 @@ ov_build_validation=0
gtest_include_dir="/usr/src/gtest/src"
# Parse arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
......@@ -68,6 +67,7 @@ while [[ $# -gt 0 ]]; do
;;
--dependencies-dir)
dependencies_dir_token="-DOV_CUSTOM_DEPENDENCIES_PATH=$2"
dependencies_dir=$2
shift
;;
--test-data-dir)
......@@ -119,6 +119,13 @@ while [[ $# -gt 0 ]]; do
shift # past argument or value
done
if [[ ! -z ${dependencies_dir} ]]
then
./unix-init-env.sh --dependencies-dir ${dependencies_dir}
else
echo "dependencies_dir not set: not initialisaing environment"
fi
# Check parameters validity
if [[ ${ov_build_type} != "Debug" ]] \
&& [[ ${ov_build_type} != "Release" ]] \
......
#!/bin/bash
# This script performs any environment initialisation needed for the build of OpenViBE.
function usage()
{
echo "usage: ./unix-init-env.sh [options]"
echo ""
echo "-h | --help : usage"
echo "-v | --verbose : verbose output at building step"
echo "--dependencies-dir <dirname> : directory where dependencies are located"
}
# variable inits
dependencies_dir=""
# arg parsing
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h | --help)
usage
exit 0
;;
-v | --verbose)
verbose=1
;;
--dependencies-dir)
dependencies_dir=$2
shift
;;
*)
echo "ERROR: Unknown parameter $key"
exit 1
;;
esac
shift # past argument or value
done
if [ -z "$dependencies_dir" ]
then
echo "Missing --dependencies-dir"
usage
else
echo "unix-init-env: adding dependencies to path"
# Add to the front of PATH any needed dependency.
export PATH=$dependencies_dir/cmake/bin:$PATH
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment