-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgen_cmake.sh
executable file
·169 lines (144 loc) · 4.56 KB
/
gen_cmake.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env bash
# Useful script to generate project files using cmake
# Override default cmake options
cmake_opt="-DBUILD_HIVE_TESTS=TRUE -DENABLE_HIVE_CPACK=FALSE -DENABLE_CODE_SIGNING=FALSE -DENABLE_HIVE_FEATURE_SPARKLE=FALSE"
############################ DO NOT MODIFY AFTER THAT LINE #############
# Get absolute folder for this script
selfFolderPath="`cd "${BASH_SOURCE[0]%/*}"; pwd -P`/" # Command to get the absolute path
# Check if setup_fresh_env has been called
if [ ! -f "${selfFolderPath}.initialized" ]; then
echo "ERROR: Please run setup_fresh_env.sh (just once) after having cloned this repository."
exit 4
fi
# Include default values
if [ ! -f "${selfFolderPath}.defaults.sh" ]; then
echo "ERROR: Missing ${selfFolderPath}.defaults.sh file"
echo "Copy .defaults.sh.sample file to .defaults.sh then edit it to your needs."
exit 4
fi
. "${selfFolderPath}.defaults.sh"
# Include utils functions
. "${selfFolderPath}3rdparty/avdecc/scripts/bashUtils/utils.sh"
# Include config file extension
. "${selfFolderPath}extend_config_file.sh"
# Include config file functions
. "${selfFolderPath}3rdparty/avdecc/scripts/bashUtils/load_config_file.sh"
# Load config file
configFile=".hive_config"
loadConfigFile
if isLinux; then
which g++ &> /dev/null
if [ $? -ne 0 ];
then
echo "ERROR: g++ not found"
exit 4
fi
fi
# Parse variables
overrideQtDir=0
QtDir=""
overrideQtVers=0
QtVersion="${default_qt_version}"
useSparkle=0
dsaFilePath="${selfFolderPath}resources/dsa_pub.pem"
# Override defaults using config file
if [[ "x${params["use_sparkle"]}" == "xtrue" ]]; then
useSparkle=1
fi
function extend_gc_fnc_help()
{
local qtBaseInstallPath=""
local qtArchName=""
local default_path=""
get_default_qt_path qtBaseInstallPath
get_default_qt_arch qtArchName
getQtDir default_path "${qtBaseInstallPath}" "${qtArchName}" "${QtVersion}"
echo " -no-sparkle -> Disable sparkle usage, even if specified in config file"
echo " -qtvers <Qt Version> -> Override the default Qt version (v${default_qt_version}) with the specified one."
echo " -qtdir <Qt CMake Folder> -> Override default Qt path (${default_path}) with the specified one."
echo "Note: You can also use the -qtdir option to use Qt source instead of precompiled binaries (specify 'Src/qtbase' instead of binary arch)."
}
function extend_gc_fnc_unhandled_arg()
{
case "$1" in
-no-sparkle)
useSparkle=0
return 1
;;
-qtvers)
shift
if [ $# -lt 1 ]; then
echo "ERROR: Missing parameter for -qtvers option, see help (-h)"
exit 4
fi
overrideQtVers=1
QtVersion="$1"
return 2
;;
-qtdir)
shift
if [ $# -lt 1 ]; then
echo "ERROR: Missing parameter for -qtdir option, see help (-h)"
exit 4
fi
overrideQtDir=1
QtDir="$1"
return 2
;;
esac
return 0
}
function extend_gc_fnc_postparse()
{
# Get DSA public key (macOS needs it in the plist)
if [ $useSparkle -eq 1 ]; then
add_cmake_opt+=("-DENABLE_HIVE_FEATURE_SPARKLE=TRUE")
if [[ $OSTYPE == darwin* ]]; then
if [ ! -f "${dsaFilePath}" ]; then
echo "ERROR: Please run setup_fresh_env.sh (just once) after having having changed use_sparkle value in config file."
exit 4
fi
dsaPubKey="$(< "${dsaFilePath}")"
add_cmake_opt+=("-DHIVE_DSA_PUB_KEY=${dsaPubKey}")
fi
fi
# -qtvers is required if -qtdir is used
if [[ ${overrideQtDir} -eq 1 && ${overrideQtVers} -eq 0 ]]; then
echo "ERROR: -qtdir option requires -qtvers option, see help (-h)"
exit 4
fi
}
function extend_gc_fnc_precmake()
{
# Using automatic Qt detection
if [ $overrideQtDir -eq 0 ]; then
local qtBaseInstallPath=""
local qtArchName=""
get_default_qt_path qtBaseInstallPath
get_default_qt_arch qtArchName
getQtDir QtDir "${qtBaseInstallPath}" "${qtArchName}" "${QtVersion}"
fi
# Validate QtDir
local qtMajorVersion="${QtVersion%%.*}"
local qtConfigFileName="Qt${qtMajorVersion}Config.cmake"
local qtConfigFilePath="${QtDir}/Qt${qtMajorVersion}/${qtConfigFileName}"
if isWSL; then
# Convert Windows path to WSL path
qtConfigFilePath=$(wslpath -u "${qtConfigFilePath}")
fi
if [ ! -f "${qtConfigFilePath}" ]; then
echo "Invalid Qt folder (${QtDir}): ${qtConfigFileName} not found in the folder."
echo "Maybe try the -qtdir option, see help (-h)"
exit 1
fi
add_cmake_opt+=("-DCMAKE_PREFIX_PATH=${QtDir}")
add_cmake_opt+=("-DQT_MAJOR_VERSION=${qtMajorVersion}")
# Add NewsFeeds
add_cmake_opt+=("-DNEWSFEED_URL=${params["newsfeed_url"]}")
}
function extend_gc_fnc_props_summary()
{
echo "| - QT VERS: ${QtVersion}"
}
# execute gen_cmake script from bashUtils
. "${selfFolderPath}3rdparty/avdecc/scripts/bashUtils/gen_cmake.sh"