summaryrefslogtreecommitdiff
path: root/src/navigation/CMakeLists.txt
blob: acab237cd570272e94403916c9a5b7957118cded (plain)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
###########################################################################
# @licence app begin@
# SPDX-License-Identifier: MPL-2.0
#
# Component Name: navigation
#
# Author: Philippe Colliot
#
# Copyright (C) 2014, PCA Peugeot Citroën
# 
# License:
# This Source Code Form is subject to the terms of the
# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# @licence end@
###########################################################################
project(navigation)
cmake_minimum_required(VERSION 2.8)

message(STATUS "navigation")

find_package(PkgConfig REQUIRED)
find_program(XSLTPROC xsltproc REQUIRED)
find_program(GIT git)
find_program(SVN svn)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

set (git_get_src_version git rev-parse HEAD)
set (git_executable ${GIT})
set (create_file cmake -E touch)
set (remove_file cmake -E rm)

set (svn_executable ${SVN})
set (svn_get_src_version svnversion)

set(cmake_create_dir cmake -E make_directory)
set (apply_patch patch -p1 -s) 

set(WITH_LM $ENV{WLD}) 

# Check if ivi layer management stuff with the right version has been cloned and do it if necessary
# ilm is cloned into sub dir
set(wayland-ivi-extension_SRC_DIR ${layer-management_SRC_DIR}/wayland-ivi-extension)
set(weston-ivi-shell_SRC_DIR ${layer-management_SRC_DIR}/weston-ivi-shell)

# Get the wayland-ivi-extension
set(wayland-ivi-extension_URL http://git.projects.genivi.org/wayland-ivi-extension.git)
set(wayland-ivi-extension_VERSION 278437417d1ac0958a800eecfebd2a388d6d9ca7)

if (EXISTS ${wayland-ivi-extension_SRC_DIR})
	execute_process(	
		COMMAND ${git_get_src_version}  
		WORKING_DIRECTORY "${wayland-ivi-extension_SRC_DIR}"
		RESULT_VARIABLE result
		OUTPUT_VARIABLE version
	)
	if (${version} MATCHES ${wayland-ivi-extension_VERSION})
		message(STATUS "version of wayland-ivi-extension up to date")	
	else()
		message(STATUS "get the right version of wayland-ivi-extension")
	 	execute_process(
			COMMAND "${git_executable}" pull
			COMMAND "${git_executable}" checkout ${wayland-ivi-extension_VERSION}
			WORKING_DIRECTORY "${wayland-ivi-extension_SRC_DIR}"
			RESULT_VARIABLE error_code
		)
		if(error_code)
			message(FATAL_ERROR "Failed to checkout version: '${wayland-ivi-extension_VERSION}'")
		endif()	
	endif()
else()
	message(STATUS "clone wayland-ivi-extension")
	execute_process(
		COMMAND "${git_executable}" clone "${wayland-ivi-extension_URL}" "${wayland-ivi-extension_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
 	if(error_code)
		message(FATAL_ERROR "Failed to clone repository: '${wayland-ivi-extension_URL}'")
	endif()
	message(STATUS "get the right version of wayland-ivi-extension")
 	execute_process(
		COMMAND "${git_executable}" pull
		COMMAND "${git_executable}" checkout ${wayland-ivi-extension_VERSION}
		WORKING_DIRECTORY "${wayland-ivi-extension_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
	if(error_code)
		message(FATAL_ERROR "Failed to checkout version: '${wayland-ivi-extension_VERSION}'")
	endif()	
endif()

# Get the weston-ivi-shell
set(weston-ivi-shell_URL https://github.com/ntanibata/weston-ivi-shell.git)
set(weston-ivi-shell_VERSION a3dd3192343e573e9cbf349022cb81b77bfbdaca)
set(weston-ivi-shell_PATCH_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches)
set(weston-ivi-shell_PATCH_DUMMY_FILE ${weston-ivi-shell_SRC_DIR}/.patched)

if (EXISTS ${weston-ivi-shell_SRC_DIR})
	execute_process(	
		COMMAND ${git_get_src_version}  
		WORKING_DIRECTORY "${weston-ivi-shell_SRC_DIR}"
		RESULT_VARIABLE result
		OUTPUT_VARIABLE version
	)
	if (${version} MATCHES ${weston-ivi-shell_VERSION})
		message(STATUS "version of weston-ivi-shell up to date")	
	else()
		message(STATUS "get the right version of weston-ivi-shell")
	 	execute_process(
			COMMAND "${git_executable}" pull
			COMMAND "${git_executable}" checkout ${weston-ivi-shell_VERSION}
			WORKING_DIRECTORY "${weston-ivi-shell_SRC_DIR}"
			RESULT_VARIABLE error_code
		)
		if(error_code)
			message(FATAL_ERROR "Failed to checkout version: '${weston-ivi-shell_VERSION}'")
		endif()	
	endif()
else()
	message(STATUS "clone weston-ivi-shell")
	execute_process(
		COMMAND "${git_executable}" clone "${weston-ivi-shell_URL}" "${weston-ivi-shell_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
 	if(error_code)
		message(FATAL_ERROR "Failed to clone repository: '${weston-ivi-shell_URL}'")
	endif()
	message(STATUS "get the right version of weston-ivi-shell")
 	execute_process(
		COMMAND "${git_executable}" pull
		COMMAND "${git_executable}" checkout ${weston-ivi-shell_VERSION}
		WORKING_DIRECTORY "${weston-ivi-shell_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
	if(error_code)
		message(FATAL_ERROR "Failed to checkout version: '${weston-ivi-shell_VERSION}'")
	endif()	
endif()

if (EXISTS ${weston-ivi-shell_PATCH_DUMMY_FILE})
	message(STATUS "patch already applied to weston-ivi-shell")
else()
	message(STATUS "apply the patches to weston-ivi-shell")
	execute_process(
		COMMAND ${apply_patch} -i ${weston-ivi-shell_PATCH_SRC_DIR}/0001-client.pro-Disable-create_cmake-configuration.patch
		COMMAND ${apply_patch} -i ${weston-ivi-shell_PATCH_SRC_DIR}/0002-Update-ivi-application.xml-and-fix-inplementation-of.patch
		COMMAND ${create_file} ${weston-ivi-shell_PATCH_DUMMY_FILE}
		TIMEOUT 0.1 #cmake -E touch never ends so add a timeout here
		WORKING_DIRECTORY "${weston-ivi-shell_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
	if(error_code)
		message(FATAL_ERROR "Failed to apply the patch")
	endif()	
endif()

# Check if positioning stuff with the right version has been cloned and do it if necessary
# positioning_SRC_DIR is set by cmake -Dpositioning_SRC_DIR=<path to positioning src dir> 
set(positioning_URL http://git.projects.genivi.org/lbs/positioning.git)
set(positioning_VERSION 98c626c1a3856f444e9441950f6500db6ae9b997)

if (EXISTS ${positioning_SRC_DIR})
	execute_process(COMMAND ${git_get_src_version}  
					WORKING_DIRECTORY "${positioning_SRC_DIR}"
					RESULT_VARIABLE result
					OUTPUT_VARIABLE version)
	if (${version} MATCHES ${positioning_VERSION})
		message(STATUS "version of positioning up to date")	
	else()
		message(STATUS "get the right version of positioning")
	 	execute_process(
			COMMAND "${git_executable}" pull
			COMMAND "${git_executable}" checkout ${positioning_VERSION}
			WORKING_DIRECTORY "${positioning_SRC_DIR}"
			RESULT_VARIABLE error_code
		)
		if(error_code)
			message(FATAL_ERROR "Failed to checkout version: '${positioning_VERSION}'")
		endif()	
	endif()
else()
	message(STATUS "clone positioning")
	execute_process(
		COMMAND "${git_executable}" clone "${positioning_URL}" "${positioning_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
 	if(error_code)
		message(FATAL_ERROR "Failed to clone repository: '${positioning_URL}'")
	endif()

	message(STATUS "get the right version of positioning")
 	execute_process(
		COMMAND "${git_executable}" pull
		COMMAND "${git_executable}" checkout ${positioning_VERSION}
		WORKING_DIRECTORY "${positioning_SRC_DIR}"
		RESULT_VARIABLE error_code
	)
	if(error_code)
		message(FATAL_ERROR "Failed to checkout version: '${positioning_VERSION}'")
	endif()	
endif()

# Check if navit stuff with the right version has been cloned and do it if necessary
set(navit_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/navit)
set(navit_URL http://svn.code.sf.net/p/navit/code/trunk)
set(navit_VERSION 5532)
set(navit_PATCH_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches)
set(navit_PATCH_DUMMY_FILE ${navit_SRC_DIR}/.patched)

if (EXISTS ${navit_SRC_DIR})
	execute_process(COMMAND ${svn_get_src_version}  
					WORKING_DIRECTORY "${navit_SRC_DIR}"
					RESULT_VARIABLE result
					OUTPUT_VARIABLE version)
	if (${version} MATCHES ${navit_VERSION})
		message(STATUS "version of navit up to date")	
	else()
		message(STATUS "get the right version of navit")
	 	execute_process(
			COMMAND "${svn_executable}" checkout ${navit_URL} navit -r ${navit_VERSION}
			WORKING_DIRECTORY "${navit_SRC_DIR}/.."
			RESULT_VARIABLE error_code
		)
		if(error_code)
			message(FATAL_ERROR "Failed to checkout version: '${navit_VERSION}'")
		endif()	
	endif()
else()
	message(STATUS "clone navit")
	execute_process(
		COMMAND "${svn_executable}" checkout ${navit_URL} navit -r ${navit_VERSION}
		WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
		RESULT_VARIABLE error_code
	)
 	if(error_code)
		message(FATAL_ERROR "Failed to clone repository: '${navit_URL}'")
	endif()
endif()

if (WITH_LM)
	if (EXISTS ${navit_PATCH_DUMMY_FILE})
		message(STATUS "patch already applied to navit")
	else()
		message(STATUS "apply the patches to navit")
		execute_process(
			COMMAND ${apply_patch} -i ${navit_PATCH_SRC_DIR}/0001-add-wayland-ilm-support-navit.patch
			COMMAND ${create_file} ${navit_PATCH_DUMMY_FILE}
			TIMEOUT 0.1 #cmake -E touch never ends so add a timeout here
			WORKING_DIRECTORY "${navit_SRC_DIR}"
			RESULT_VARIABLE error_code
		)
		if(error_code)
			message(FATAL_ERROR "Failed to apply the patch")
		endif()	
	endif()
endif()

# Check if the map data base have been got and do it if necessary (no version checked for the moment)
set(map_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/map)
set(MAP_FILE switzerland.bin)
set(map_URL http://www.navit-project.org/${MAP_FILE})
set(wget wget -O)

if (NOT EXISTS ${map_SRC_DIR}/${MAP_FILE})
	message(STATUS "get the map")
	execute_process(
		COMMAND ${wget} "${map_SRC_DIR}/${MAP_FILE}.tmp" "${map_URL}"
		RESULT_VARIABLE error_code
	)
 	if(error_code)
		message(FATAL_ERROR "Failed to get map: '${MAP_FILE}', what about your proxy ?")
	endif()
	execute_process(
		COMMAND mv "${map_SRC_DIR}/${MAP_FILE}.tmp" ${map_SRC_DIR}/${MAP_FILE}
	)
endif()