-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
cmake_raspberry.sh
82 lines (68 loc) · 2.54 KB
/
cmake_raspberry.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
#!/bin/bash
#move to project directory
BASEDIR=$(dirname $0);
set -e
cd $BASEDIR/projects
#treat script parameter (if there is one, then directly use it for cases)
if [ -z "$1" ]
then
echo "Which choice would you like?"
echo " -> Generate a linux makefile to run on RaspberryPI (a) "
echo " -> Generate a linux makefile to run on RaspberryPI RELEASE (b)"
echo " -> Generate a linux makefile to run on RaspberryPI forcing g++ 4.9 (p) "
echo " -> Generate a linux makefile to run on RaspberryPI forcing g++ 4.9 RELEASE (q)"
echo " -> Generate a linux makefile for Cross Compilation (c)"
echo " -> Generate a linux makefile for Cross Compilation RELEASE (r)"
echo " -> Generate Eclipse CDT4 project files for CrossCompilation (e)"
read choice
else
choice=$1
fi
getCMakeExecutable () {
local cmakePath=$( grep -oP '^[\t ]*set\(ALTERNATIVE_CMAKE_ROOT[[:space:]]\"\K.*(?=")' ../sources/CMakeListsUserConfig.txt )
if [ -z "$cmakePath" ]
then
echo cmake
else
echo $cmakePath/bin/cmake
fi
}
cmake_executable=$(getCMakeExecutable)
echo "Use cmake executable $cmake_executable"
$cmake_executable --version
#run cmake depending on user choice (or script parameter)
case "$choice" in
p)
# cmake for makefile
$cmake_executable -DCMAKE_YADOMS_PLATFORM=Raspberry -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_CC_COMPILER=gcc-4.9 ../sources
;;
q)
# cmake for makefile
$cmake_executable -DCMAKE_BUILD_TYPE="Release" -DCMAKE_YADOMS_PLATFORM=Raspberry -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_CC_COMPILER=gcc-4.9 ../sources
;;
a)
# cmake for makefile
$cmake_executable -DCMAKE_YADOMS_PLATFORM=Raspberry ../sources
;;
b)
# cmake for makefile
$cmake_executable -DCMAKE_BUILD_TYPE="Release" -DCMAKE_YADOMS_PLATFORM=Raspberry ../sources
;;
c)
# cmake for cross compilation
$cmake_executable -DCMAKE_YADOMS_PLATFORM=Raspberry -DCC_RPI_GCC=arm-linux-gnueabihf-gcc -DCC_RPI_GXX=arm-linux-gnueabihf-g++ -DCMAKE_TOOLCHAIN_FILE=../sources/cmake/raspberrypi.cmake ../sources
;;
r)
# cmake for cross compilation RELEASE
cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_YADOMS_PLATFORM=Raspberry -DCC_RPI_GCC=arm-linux-gnueabihf-gcc -DCC_RPI_GXX=arm-linux-gnueabihf-g++ -DCMAKE_TOOLCHAIN_FILE=../sources/cmake/raspberrypi.cmake ../sources
;;
e)
# cmake for compilation and debug with Eclipse
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_YADOMS_PLATFORM=Raspberry -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../sources
;;
*)
# generate an error and return 1
echo "$choice is not a valid choice"
exit 1
;;
esac