File: CPackConfig.cmake.in

package info (click to toggle)
openorienteering-mapper 0.9.6-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 67,132 kB
  • sloc: cpp: 114,710; ansic: 1,455; sh: 430; java: 240; xml: 140; sed: 64; makefile: 28
file content (123 lines) | stat: -rw-r--r-- 3,727 bytes parent folder | download | duplicates (5)
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
#
#    Copyright 2017-2020 Kai Pastor
#    
#    This file is part of OpenOrienteering.
# 
#    OpenOrienteering is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
# 
#    OpenOrienteering is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
# 
#    You should have received a copy of the GNU General Public License
#    along with OpenOrienteering.  If not, see <http://www.gnu.org/licenses/>.


execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Creating APK package")

# For Android, we don't use a CPack generator,
# but run androiddeployqt from this file.
set(CPACK_GENERATOR "")


if(@RELEASE_APK@)
	set(config "CONFIG+=release")
	set(apk "release/android-build-release" )
else()
	set(config "CONFIG+=debug")
	set(apk "debug/android-build-debug" )
endif()

set(SIGN_APK "@SIGN_APK@")
if(SIGN_APK AND "@CMAKE_HOST_UNIX@")
	execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Checking if we are running in a terminal")
	execute_process(COMMAND tty RESULT_VARIABLE result)
	if(result)
		# APK signing enabled at configuration time, but not possible at build time.
		message(WARNING "Not running in a terminal, signing disabled.")
		set(SIGN_APK 0)
	endif()
endif()

if(SIGN_APK)
	set(sign --sign "@KEYSTORE_URL@" "@KEYSTORE_ALIAS@")
	set(apk "${apk}-signed.apk" )
else()
	set(sign )
	if(@RELEASE_APK@)
		set(apk "${apk}-unsigned.apk")
	else()
		set(apk "${apk}.apk")
	endif()
	message(STATUS "The build creates an unsigned APK. To sign the APK, run:
  apksigner sign --ks <keystore> --ks-key-alias <alias> ${apk}"
	)
endif()



set(staging_dir "@ANDROID_PACKAGE_SOURCE_DIR@")

# Don't always clear the staging dir: It slows down the packaging, and it is
# rarely needed. We can rely Mapper.pro, and even add extra variables there.
if(EXISTS "${staging_dir}" AND "@MAPPER_PRO_DIR@/Mapper.pro" IS_NEWER_THAN "${staging_dir}")
	FILE(REMOVE_RECURSE "${staging_dir}")
endif()
execute_process(
  COMMAND "${CMAKE_COMMAND}"
    "-DCMAKE_INSTALL_PREFIX=${staging_dir}"
	"-DCMAKE_INSTALL_DO_STRIP=1"
	-P cmake_install.cmake
  WORKING_DIRECTORY "@PROJECT_BINARY_DIR@"
  RESULT_VARIABLE result
)
if(result)
	message(FATAL_ERROR "Installation failed: ${result}")
endif()

# Create an androiddeployqt configuration file via qmake project.
set(deployment_settings "@CMAKE_CURRENT_BINARY_DIR@/Mapper/Mapper-deployment-settings.json")
execute_process(
  COMMAND "$<TARGET_FILE:Qt5::qmake>"
    -spec android-clang
    "${config}"
    "ANDROID_ABIS=@ANDROID_ABI@"
    "ANDROID_DEPLOYMENT_SETTINGS_FILE=${deployment_settings}"
  WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/Mapper"
  RESULT_VARIABLE result
)
if(result)
	message(FATAL_ERROR "Creating APK configuration failed: ${result}")
endif()

execute_process(
  COMMAND androiddeployqt
    --input "${deployment_settings}"
    --output "@MAPPER_PRO_DIR@/android-build"
    --deployment "bundled"
    --gradle
    --verbose
$<@RELEASE_APK@:
    --release
>
$<@SIGN_APK@:
    ${sign}
>
  WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/Mapper"
  RESULT_VARIABLE result
)
if(result)
	message(FATAL_ERROR "Running androiddeployqt failed: ${result}")
endif()

configure_file(
  "@MAPPER_PRO_DIR@/android-build/build/outputs/apk/${apk}"
  "@PROJECT_BINARY_DIR@/@CPACK_PACKAGE_FILE_NAME@.apk"
  COPYONLY
)
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Created @PROJECT_BINARY_DIR@/@CPACK_PACKAGE_FILE_NAME@.apk")