-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·149 lines (114 loc) · 4.49 KB
/
configure.sh
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# =========================
# === Define Parameters ===
# =========================
RELEASE=true
CMAKE_VERSION="VERSION 2.8"
BOOST_VERSION="1.55.0"
INSTALL_PATH="$HOME/opt/proteo"
THREAD_NUMBER=1
USE_QT=false
QT_CMAKE_PATH=""
# =====================
# === HELP FUNCTION ===
# =====================
function fct_help {
echo " -d | --debug Debug build"
echo " --qt [qt cmake widget path] Enable qt gui build"
exit 0
}
# =======================
# === Parse Arguments ===
# =======================
while [ "$1" != "" ]; do
case "$1" in
-h|--help)
fct_help
shift ;;
-d|--debug)
RELEASE=false
shift ;;
--qt)
shift
USE_QT=true
QT_CMAKE_PATH=$1
shift ;;
*)
# unknown option
echo "Unknown option !" ; exit 1 ;;
esac
done
# ========================
# === Write CMakeLists ===
# ========================
echo "-- create CMakeLists.txt"
# Minimum cmake version
echo 'CMAKE_MINIMUM_REQUIRED('$CMAKE_VERSION')' > CMakeLists.txt
echo '' >> CMakeLists.txt
# Release / Debug
if $RELEASE ; then
echo '-- release'
echo 'SET(CMAKE_BUILD_TYPE "RELEASE")' >> CMakeLists.txt
else
echo '-- debug'
echo 'SET(CMAKE_BUILD_TYPE "DEBUG")' >> CMakeLists.txt
fi
echo '' >> CMakeLists.txt
# Python
echo 'SET(Python_ADDITIONAL_VERSIONS 2.7)' >> CMakeLists.txt
echo 'FIND_PACKAGE( PythonLibs 2.7 REQUIRED )' >> CMakeLists.txt
echo 'INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} )' >> CMakeLists.txt
echo '' >> CMakeLists.txt
# Boost
echo 'FIND_PACKAGE( Boost 1.55.0 COMPONENTS' >> CMakeLists.txt
echo ' thread' >> CMakeLists.txt
echo ' python' >> CMakeLists.txt
echo ' REQUIRED )' >> CMakeLists.txt
echo 'INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )' >> CMakeLists.txt
echo '' >> CMakeLists.txt
# Compile flag for C++11
echo 'LIST(APPEND CMAKE_CXX_FLAGS "-std=c++0x -Wno-write-strings")' >> CMakeLists.txt
if $USE_QT ; then
echo "-- use qt (cmake: '$QT_CMAKE_PATH')"
# Search for Qt config
echo 'SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} '$QT_CMAKE_PATH' )' >> CMakeLists.txt
# Qt configuration
echo 'SET(CMAKE_INCLUDE_CURRENT_DIR ON)' >> CMakeLists.txt
echo 'SET(CMAKE_AUTOMOC ON)' >> CMakeLists.txt
echo 'FIND_PACKAGE(Qt5Widgets REQUIRED)' >> CMakeLists.txt
echo '' >> CMakeLists.txt
fi
# Append build cmake script
echo 'INCLUDE(cmake/module.cmake)' >> CMakeLists.txt
echo '' >> CMakeLists.txt
# ===================
# === Write build ===
# ===================
echo "-- create build.sh"
# Tag
echo '#!/bin/bash' > build.sh
echo '' >> build.sh
# Create build directory
echo 'mkdir build' >> build.sh
echo 'cd build' >> build.sh
echo '' >> build.sh
# Execute cmake
echo 'cmake -DCMAKE_INSTALL_PREFIX='$INSTALL_PATH' ..' >> build.sh
echo '' >> build.sh
# Make and install
echo 'make -j'$THREAD_NUMBER >> build.sh
echo 'make install' >> build.sh
echo '' >> build.sh
# ===================
# === Write clean ===
# ===================
echo "-- create clean.sh"
# Tag
echo '#!/bin/bash' > clean.sh
echo 'rm -r build' >> clean.sh
echo '' >> clean.sh
# ========================
# === Export variables ===
# ========================
echo "-- create sysetup.sh"
echo "echo 'export PYTHONPATH=$PYTHONPATH:'"$INSTALL_PATH"/py >> ~/.bashrc" > sysetup.sh