Skip to content

Commit 0b003c0

Browse files
committed
Adding CMake build script.
Signed-off-by: Damian Rouson <[email protected]>
1 parent b078f10 commit 0b003c0

File tree

3 files changed

+139
-1
lines changed

3 files changed

+139
-1
lines changed

install_prerequisites/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,13 @@ install(
1818
)
1919
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/buildmpich BUILDMPICH_SCRIPT)
2020
file(WRITE "${mpich_build_script}" "${BUILDMPICH_SCRIPT}\n")
21+
22+
# Write the script that builds CMake from source
23+
set(cmake_build_script ${exe_dir}/buildcmake)
24+
install(
25+
FILES "${cmake_build_script}"
26+
PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
27+
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
28+
)
29+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/buildcmake BUILDCMAKE_SCRIPT)
30+
file(WRITE "${cmake_build_script}" "${BUILDCMAKE_SCRIPT}\n")

install_prerequisites/buildcmake

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
#
3+
# buildcmake
4+
#
5+
# -- This script downloads and installs the CMake cross-platform Makefile generator
6+
# (http://www.cmake.org).
7+
#
8+
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
9+
# Copyright (c) 2015, Sourcery, Inc.
10+
# Copyright (c) 2015, Sourcery Institute
11+
# All rights reserved.
12+
#
13+
# All rights reserved.
14+
# Redistribution and use in source and binary forms, with or without modification,
15+
# are permitted provided that the following conditions are met:
16+
#
17+
# 1. Redistributions of source code must retain the above copyright notice, this
18+
# list of conditions and the following disclaimer.
19+
# 2. Redistributions in binary form must reproduce the above copyright notice, this
20+
# list of conditions and the following disclaimer in the documentation and/or
21+
# other materials provided with the distribution.
22+
# 3. Neither the names of the copyright holders nor the names of their contributors
23+
# may be used to endorse or promote products derived from this software without
24+
# specific prior written permission.
25+
#
26+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29+
# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
# POSSIBILITY OF SUCH DAMAGE.
36+
37+
cmd=`basename $0`
38+
usage()
39+
{
40+
echo ""
41+
echo " $cmd - Bash script for building CMake from source"
42+
echo ""
43+
echo " Usage (optional arguments in square brackets): "
44+
echo " $cmd <version-number>"
45+
echo " or $cmd [options] "
46+
echo ""
47+
echo " Options:"
48+
echo " --help, -h Show this help message"
49+
echo " --version, -v, -V Report version and copyright information"
50+
echo ""
51+
echo " Example usage:"
52+
echo ""
53+
echo " $cmd default"
54+
echo " $cmd 3.3"
55+
echo " $cmd -v"
56+
echo " $cmd --help"
57+
echo ""
58+
echo " Note: For a list of available CMake versions, visit"
59+
echo " http://www.cmake.org/files/"
60+
echo ""
61+
exit 1
62+
}
63+
64+
# Default to compiling with the GNU compilers if the environment
65+
# variables CC, FC, and CXX, are empty:
66+
if [ -z "$CC" ]; then
67+
CC=gcc
68+
fi
69+
if [ -z "$FC" ]; then
70+
FC=gfortran
71+
fi
72+
if [ -z "$CXX" ]; then
73+
CXX=g++
74+
fi
75+
76+
# Default to installing CMake 3.3 if no version specified in the first
77+
# command-line argument
78+
if [[ $1 == 'default' ]]; then
79+
version=3.3
80+
else
81+
version=$1
82+
fi
83+
84+
# Make the build directory, configure, and build
85+
build()
86+
{
87+
./cmake-$version.0-1.sh all
88+
}
89+
90+
if [ $# == 0 ]; then
91+
# Print usage information if script is invoked without arguments
92+
usage | less
93+
elif [[ $1 == '--help' || $1 == '-h' ]]; then
94+
# Print usage information if script is invoked with --help or -h argument
95+
usage | less
96+
elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
97+
# Print script copyright if invoked with -v, -V, or --version argument
98+
echo ""
99+
echo "CMake Build Script"
100+
echo "Copyright (C) 2015 Sourcery, Inc."
101+
echo "Copyright (C) 2015 Sourcery Institute"
102+
echo ""
103+
echo "$cmd comes with NO WARRANTY, to the extent permitted by law."
104+
echo "You may redistribute copies of $cmd under the terms of the"
105+
echo "BSD 3-Clause License. For more information about these matters, see"
106+
echo "http://www.sourceryinstitute.org/license.html"
107+
echo ""
108+
else
109+
# Download and build CMake
110+
time \
111+
{
112+
if ! type wget > /dev/null; then
113+
echo
114+
echo "$cmd requires 'wget'. Please install it. Aborting."
115+
exit 1;
116+
else
117+
# Download CMake
118+
wget http://www.cmake.org/files/v$version/cmake-$version.0-1-src.tar.bz2 &&
119+
# Unpack the downloaded tape archive
120+
tar xvjf cmake-$version.0-1-src.tar.bz2 &&
121+
# Compile Cmake source
122+
build $version
123+
fi
124+
} >&1 | tee build.log
125+
echo ""
126+
echo "Check build.log for results."
127+
echo ""
128+
fi

install_prerequisites/buildmpich

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# buildmpich
44
#
5-
# -- This script ownloads and installs the MPICH library (http://www.mpich.org).
5+
# -- This script downloads and installs the MPICH library (http://www.mpich.org).
66
#
77
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
88
# Copyright (c) 2015, Sourcery, Inc.

0 commit comments

Comments
 (0)