-
Notifications
You must be signed in to change notification settings - Fork 280
/
Copy pathcatkin_generate_environment.cmake
146 lines (133 loc) · 5.29 KB
/
catkin_generate_environment.cmake
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
function(catkin_generate_environment)
set(SETUP_FILENAME "setup")
# devel space
set(SETUP_DIR ${CATKIN_DEVEL_PREFIX})
# generate empty file to prevent searching for packages in binary dir
# except if source space and build space are identical (which is the case for dry eclipse projects)
if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
file(WRITE "${CMAKE_BINARY_DIR}/CATKIN_IGNORE" "")
endif()
# get multiarch name
set(CATKIN_LIB_ENVIRONMENT_PATHS "'${CATKIN_GLOBAL_LIB_DESTINATION}'")
set(CATKIN_PKGCONFIG_ENVIRONMENT_PATHS "os.path.join('${CATKIN_GLOBAL_LIB_DESTINATION}', 'pkgconfig')")
if (UNIX AND NOT APPLE)
# Two step looking for multiarch support: check for gcc -print-multiarch
# and, if failed, try to run dpkg-architecture
execute_process(COMMAND gcc -print-multiarch
OUTPUT_VARIABLE CATKIN_MULTIARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if ("${CATKIN_MULTIARCH}" STREQUAL "")
execute_process(COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
OUTPUT_VARIABLE CATKIN_MULTIARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
if (NOT "${CATKIN_MULTIARCH}" STREQUAL "")
set(CATKIN_LIB_ENVIRONMENT_PATHS
"[${CATKIN_LIB_ENVIRONMENT_PATHS}, os.path.join('${CATKIN_GLOBAL_LIB_DESTINATION}', '${CATKIN_MULTIARCH}')]")
set(CATKIN_PKGCONFIG_ENVIRONMENT_PATHS
"[${CATKIN_PKGCONFIG_ENVIRONMENT_PATHS}, os.path.join('${CATKIN_GLOBAL_LIB_DESTINATION}', '${CATKIN_MULTIARCH}', 'pkgconfig')]")
endif()
endif()
# generate Python setup util
atomic_configure_file(${catkin_EXTRAS_DIR}/templates/_setup_util.py.in
${CATKIN_DEVEL_PREFIX}/_setup_util.py
@ONLY)
if(NOT WIN32)
# non-windows
# generate env
atomic_configure_file(${catkin_EXTRAS_DIR}/templates/env.sh.in
${CATKIN_DEVEL_PREFIX}/env.sh
@ONLY)
# generate setup for various shells
foreach(shell bash sh zsh)
atomic_configure_file(${catkin_EXTRAS_DIR}/templates/setup.${shell}.in
${CATKIN_DEVEL_PREFIX}/setup.${shell}
@ONLY)
endforeach()
else()
# windows
# generate env
atomic_configure_file(${catkin_EXTRAS_DIR}/templates/env.bat.in
${CATKIN_DEVEL_PREFIX}/env.bat
@ONLY)
# generate setup
atomic_configure_file(${catkin_EXTRAS_DIR}/templates/setup.bat.in
${CATKIN_DEVEL_PREFIX}/setup.bat
@ONLY)
endif()
# generate rosinstall file referencing setup.sh
atomic_configure_file(${catkin_EXTRAS_DIR}/templates/rosinstall.in
${CATKIN_DEVEL_PREFIX}/.rosinstall
@ONLY)
# installspace
set(SETUP_DIR ${CMAKE_INSTALL_PREFIX})
if(NOT CATKIN_BUILD_BINARY_PACKAGE)
# install empty workspace marker if it doesn't already exist
install(CODE "
if (NOT EXISTS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
endif()
if (NOT EXISTS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/.catkin\")
file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/.catkin\" \"\")
endif()")
# generate and install Python setup util
configure_file(${catkin_EXTRAS_DIR}/templates/_setup_util.py.in
${CMAKE_BINARY_DIR}/catkin_generated/installspace/_setup_util.py
@ONLY)
catkin_install_python(PROGRAMS
${CMAKE_BINARY_DIR}/catkin_generated/installspace/_setup_util.py
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
if(NOT WIN32)
# non-windows
# generate and install env
configure_file(${catkin_EXTRAS_DIR}/templates/env.sh.in
${CMAKE_BINARY_DIR}/catkin_generated/installspace/env.sh
@ONLY)
if(NOT CATKIN_BUILD_BINARY_PACKAGE)
install(PROGRAMS
${CMAKE_BINARY_DIR}/catkin_generated/installspace/env.sh
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
# generate and install setup for various shells
foreach(shell bash sh zsh)
configure_file(${catkin_EXTRAS_DIR}/templates/setup.${shell}.in
${CMAKE_BINARY_DIR}/catkin_generated/installspace/setup.${shell}
@ONLY)
if(NOT CATKIN_BUILD_BINARY_PACKAGE)
install(FILES
${CMAKE_BINARY_DIR}/catkin_generated/installspace/setup.${shell}
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
endforeach()
else()
# windows
# generate and install env
configure_file(${catkin_EXTRAS_DIR}/templates/env.bat.in
${CMAKE_BINARY_DIR}/catkin_generated/installspace/env.bat
@ONLY)
install(PROGRAMS
${CMAKE_BINARY_DIR}/catkin_generated/installspace/env.bat
DESTINATION ${CMAKE_INSTALL_PREFIX})
# generate and install setup
configure_file(${catkin_EXTRAS_DIR}/templates/setup.bat.in
${CMAKE_BINARY_DIR}/catkin_generated/installspace/setup.bat
@ONLY)
install(FILES
${CMAKE_BINARY_DIR}/catkin_generated/installspace/setup.bat
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
# generate rosinstall file referencing setup.sh
configure_file(${catkin_EXTRAS_DIR}/templates/rosinstall.in
${CMAKE_BINARY_DIR}/catkin_generated/installspace/.rosinstall
@ONLY)
if(NOT CATKIN_BUILD_BINARY_PACKAGE)
install(FILES
${CMAKE_BINARY_DIR}/catkin_generated/installspace/.rosinstall
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
endfunction()