forked from ReneNyffenegger/cpp-base64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·134 lines (120 loc) · 4.99 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# Default options
BUILD_DIR="build"
CMAKE_GENERATOR="Unix Makefiles"
BUILD_TYPE="Release"
CMAKE_OPTIONS="$CMAKE_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 "# Installation directory" >> ".localconfig/default"
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=../install\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Build static libraries" >> ".localconfig/default"
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Enable examples" >> ".localconfig/default"
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Enable documentation" >> ".localconfig/default"
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Disable tests" >> ".localconfig/default"
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# CMake and environment variables (e.g., search paths for external libraries)" >> ".localconfig/default"
echo "" >> ".localconfig/default"
echo "# Qt" >> ".localconfig/default"
echo "#export CMAKE_PREFIX_PATH=\"\${CMAKE_PREFIX_PATH}:/opt/Qt5.2.1/5.2.1/gcc_64/\"" >> ".localconfig/default"
touch ".localconfig/debug"
echo "#!/bin/bash" >> ".localconfig/debug"
echo "" >> ".localconfig/debug"
echo "# Configuration for debug builds" >> ".localconfig/debug"
echo "" >> ".localconfig/debug"
echo "# Build directory and build type" >> ".localconfig/debug"
echo "BUILD_DIR=\"\${BUILD_DIR}-debug\"" >> ".localconfig/debug"
echo "BUILD_TYPE=\"Debug\"" >> ".localconfig/debug"
touch ".localconfig/pack"
echo "#!/bin/bash" >> ".localconfig/pack"
echo "" >> ".localconfig/pack"
echo "# Configuration for creating packages" >> ".localconfig/pack"
echo "" >> ".localconfig/pack"
echo "# Installation directory" >> ".localconfig/pack"
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr\"" >> ".localconfig/pack"
echo "" >> ".localconfig/pack"
echo "# Enable self-contained installation" >> ".localconfig/pack"
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_SELF_CONTAINED:BOOL=ON\"" >> ".localconfig/pack"
echo "" >> ".localconfig/pack"
echo "# Enable all components for the package" >> ".localconfig/pack"
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/pack"
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/pack"
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/pack"
echo "Default configuration has been written to .localconfig"
echo "Please review and adjust the configuration, then run again"
echo ""
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 "./.localconfig/$ARG" ]
then
. "./.localconfig/$ARG"
elif [ -f "$HOME/.localconfig/$ARG" ]
then
. "$HOME/.localconfig/$ARG"
else
echo "Configuration \"$ARG\" not found (searched in ./.localconfig and ~/.localconfig)"
fi
done
if [ "$CMAKE_GENERATOR_OVERRIDE" != "" ]
then
echo "Override CMAKE_GENERATOR to $CMAKE_GENERATOR_OVERRIDE"
CMAKE_GENERATOR="$CMAKE_GENERATOR_OVERRIDE"
fi
# Configure build
echo "Configuring in $BUILD_DIR..."
echo ""
# Create build directory
if [ ! -d "$BUILD_DIR" ]
then
mkdir -p "$BUILD_DIR"
fi
# Configure project
PREVIOUS_DIR=$(pwd)
cd $BUILD_DIR
echo cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR"
cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR"
if [ $? == 0 ]
then
echo ""
echo "Project configured. To build the project, use";
echo ""
echo " cmake --build $BUILD_DIR"
else
echo ""
echo "Configuration failed.";
fi
cd "$PREVIOUS_DIR"