forked from ezhangle/glexamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·99 lines (87 loc) · 3.21 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
# Default options
BUILD_DIR="build"
CMAKE_GENERATOR="Unix Makefiles"
BUILD_TYPE="Release"
INSTALL_OPTIONS=""
EXTRA_OPTIONS=""
# Create default configs
if [ ! -d "./.localconfig" ]
then
mkdir ".localconfig"
touch ".localconfig/default"
echo "#!/bin/bash" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Default configuration for configure (is always sourced)" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# CMake generator" >> ".localconfig/default"
echo "CMAKE_GENERATOR=\"Unix Makefiles\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Build directory and build type" >> ".localconfig/default"
echo "BUILD_DIR=\"build\"" >> ".localconfig/default"
echo "BUILD_TYPE=\"Release\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# CMake installation options" >> ".localconfig/default"
echo "INSTALL_OPTIONS=\"\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Additional CMake options" >> ".localconfig/default"
echo "EXTRA_OPTIONS=\"\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Environment variables (e.g., search paths for external libraries)" >> ".localconfig/default"
echo "#export CMAKE_PREFIX_PATH=\"/opt/Qt5.2.1/5.2.1/gcc_64/\"" >> ".localconfig/default"
echo "#export GMOCK_HOME=/opt/gmock-1.7.0" >> ".localconfig/default"
echo "#export GTEST_HOME=/opt/gtest-1.7.0" >> ".localconfig/default"
touch ".localconfig/debug"
echo "#!/bin/bash" >> ".localconfig/debug"
echo "" >> ".localconfig/debug"
echo "# Configuration option 'debug'" >> ".localconfig/debug"
echo "" >> ".localconfig/debug"
echo "# Build directory and build type" >> ".localconfig/debug"
echo "BUILD_DIR=\"build-debug\"" >> ".localconfig/debug"
echo "BUILD_TYPE=\"Debug\"" >> ".localconfig/debug"
touch ".localconfig/portable"
echo "#!/bin/bash" >> ".localconfig/portable"
echo "" >> ".localconfig/portable"
echo "# Configuration option 'portable'" >> ".localconfig/portable"
echo "" >> ".localconfig/portable"
echo "# Enable portable installation" >> ".localconfig/portable"
echo "INSTALL_OPTIONS=\"-DCMAKE_INSTALL_PREFIX:PATH=./install -DOPTION_PORTABLE_INSTALL=ON\"" >> ".localconfig/portable"
echo "Default configuration has been written to .localconfig"
echo "Please review and adjust the configuration, then run again"
echo " ./configure"
exit
fi
# Read local default options
if [ -f "./.localconfig/default" ]
then
. ./.localconfig/default
fi
# Parse command line arguments
for ARG in "$@"
do
# Read in configuration for that command-line argument
CONFIGFILE="./.localconfig/$ARG"
if [ -f "$CONFIGFILE" ]
then
. "$CONFIGFILE"
fi
done
# Configure build
echo "Configuring ..."
# Create build directory
if [ ! -d "./$BUILD_DIR" ]
then
mkdir $BUILD_DIR
fi
# Configure project
cd $BUILD_DIR
cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $INSTALL_OPTIONS $EXTRA_OPTIONS ..
if [ $? == 0 ]
then
echo "Project configured. To build the project, use";
echo " cd $BUILD_DIR"
echo " make"
else
echo "Configuration failed.";
fi
cd ..