-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
102 lines (89 loc) · 3.17 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.5)
project(pepper_meshes)
find_package(ament_cmake REQUIRED)
ament_package()
# When getting a new binay, the MD5 might change, and the folder hierarchy too
# read comments below to adapt
set(PACKAGE_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME})
set(TMP_DIR ${PACKAGE_SHARE_DIR}/tmp)
set(INSTALLER_PATH ${TMP_DIR}/installer.run)
# Try to figure out the architecture
string(FIND ${CMAKE_INSTALL_PREFIX} "i686" IS_32)
message(STATUS "Architecture is apparently 32 (-1 for no): ${IS_32}")
if(${IS_32} STREQUAL "-1")
# Trust CMAKE_SYSTEM_PROCESSOR which does not work on the farm
if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(IS_32 FALSE)
else()
set(IS_32 TRUE)
endif()
endif()
if (NOT ${IS_32})
message(STATUS "Downloading 64 bit installer")
file(DOWNLOAD
"https://github.com/ros-naoqi/pepper_meshes_installer/raw/master/peppermeshes-0.2.0-linux-x64-installer.run"
${INSTALLER_PATH} SHOW_PROGRESS
INACTIVITY_TIMEOUT 60
EXPECTED_MD5 9e78f24b52838e704210881f92c0983d
)
else()
message(STATUS "Downloading 32 bit installer")
file(DOWNLOAD
"https://github.com/ros-naoqi/pepper_meshes_installer/raw/master/peppermeshes-0.2.0-linux-installer.run"
${INSTALLER_PATH} SHOW_PROGRESS
INACTIVITY_TIMEOUT 60
EXPECTED_MD5 f48a610633d2db48bc84db16f4847b70
)
endif()
# specify the interesting folder in the archive. You might want to change
# that for a new binary where the structure is different
set(TMP_MESH_PATH ${TMP_DIR}/meshes)
# final path in devel/install space
set(FINAL_MESH_PATH share/${PROJECT_NAME}/)
# make the file executable to install
file(COPY ${INSTALLER_TMP_PATH}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${TMP_DIR}
)
# add a target for devel space
add_custom_target(${PROJECT_NAME}_meshes
COMMAND ${INSTALLER_PATH} --mode text --prefix ${TMP_DIR}
COMMAND cp -fr ${TMP_MESH_PATH} ${PACKAGE_SHARE_DIR}
COMMAND rm -fr ${TMP_DIR}/rollback*
)
# uncompress the meshes during install
install(CODE
"
# uncompress the archive
message(STATUS \"using ${INSTALLER_PATH} to decompress to ${TMP_DIR}\")
execute_process(COMMAND ${INSTALLER_PATH} --mode unattended --prefix ${TMP_DIR}
OUTPUT_VARIABLE OUT
ERROR_VARIABLE ERROR
RESULT_VARIABLE RESULT
)
message(STATUS \"intall out: \${OUT}\")
message(STATUS \"install error: \${ERROR}\")
message(STATUS \"install result: \${RESULT}\")
execute_process(COMMAND ls
WORKING_DIRECTORY ${TMP_DIR}
OUTPUT_VARIABLE OUT_LS
ERROR_VARIABLE ERROR_LS
RESULT_VARIABLE RESULT_LS
)
message(STATUS \"ls out: \${OUT_LS}\")
message(STATUS \"ls error: \${ERROR_LS}\")
message(STATUS \"ls result: \${RESULT_LS}\")
execute_process(COMMAND file ${TMP_DIR}/installer.run
OUTPUT_VARIABLE OUT_FILE
ERROR_VARIABLE ERROR_FILE_CMD
RESULT_VARIABLE RESULT_FILE
)
message(STATUS \"file out: \${OUT_FILE}\")
message(STATUS \"file error: \${ERROR_FILE_CMD}\")
message(STATUS \"file result: \${RESULT_FILE}\")
"
)
# install the archive
install(DIRECTORY ${TMP_MESH_PATH}
DESTINATION ${FINAL_MESH_PATH}/
)