forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.cmake
236 lines (210 loc) · 8.27 KB
/
install.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
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
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(DRAKE_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake")
set(DRAKE_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(DRAKE_INSTALL_LIBRARY_DIR "${CMAKE_INSTALL_LIBDIR}")
set(DRAKE_INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
set(DRAKE_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}")
set(DRAKE_INSTALL_DOCUMENTATION_DIR "${CMAKE_INSTALL_DOCDIR}")
set(DRAKE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${DRAKE_INSTALL_INCLUDE_DIR}")
set(DRAKE_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/${DRAKE_INSTALL_LIBRARY_DIR}")
set(DRAKE_PKGCONFIG_DIR
"${CMAKE_INSTALL_PREFIX}/${DRAKE_INSTALL_PKGCONFIG_DIR}")
set(DRAKE_RUNTIME_DIR "${CMAKE_INSTALL_PREFIX}/${DRAKE_INSTALL_RUNTIME_DIR}")
set(DRAKE_DOCUMENTATION_DIR "${CMAKE_INSTALL_PREFIX}/${DRAKE_INSTALL_DOCUMENTATION_DIR}")
#------------------------------------------------------------------------------
# Generate and install the "drake-config.cmake", "drake-config-version.cmake",
# "drake-targets.cmake", and "drake-targets-*.cmake" files to the "cmake"
# subdirectory of the library installation directory ("lib", "lib32", or
# "lib64") of the drake project.
#
# See the documentation of the "GNUInstallDirs" module for the rules that are
# used to choose the library installation directory for a given host operating
# system.
#------------------------------------------------------------------------------
function(drake_install_cmake_package_config_files)
configure_package_config_file(
${PROJECT_NAME}-config.cmake.in ${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${DRAKE_INSTALL_CMAKE_DIR}
PATH_VARS DRAKE_INCLUDE_DIR DRAKE_LIBRARY_DIR)
write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMajorVersion)
install(EXPORT ${PROJECT_NAME}-targets
DESTINATION "${DRAKE_INSTALL_CMAKE_DIR}")
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION ${DRAKE_INSTALL_CMAKE_DIR})
endfunction()
#------------------------------------------------------------------------------
# Install a list of runtime targets to the "bin" installation directory of the
# drake project.
#
# drake_install_executables(<targets...>)
#
# drake_install_executables([<args...>] TARGETS <targets...>)
#
# Arguments:
# TARGETS <targets...>
# List of runtime targets. Files installed by this function are given
# permissions OWNER_EXECUTE, OWNER_READ, OWNER_WRITE, GROUP_READ,
# GROUP_EXECUTE, WORLD_READ, and WORLD_EXECUTE.
#
# <args...>
# Additional arguments to be passed through to install(TARGETS).
#------------------------------------------------------------------------------
function(drake_install_executables)
cmake_parse_arguments("" "" "" "TARGETS" ${ARGN})
if(NOT _TARGETS)
set(_TARGETS ${_UNPARSED_ARGUMENTS})
set(_UNPARSED_ARGUMENTS)
endif()
install(TARGETS ${_TARGETS}
RUNTIME DESTINATION "${DRAKE_INSTALL_RUNTIME_DIR}"
${_UNPARSED_ARGUMENTS})
endfunction()
#------------------------------------------------------------------------------
# Install a list of header files to the "include" installation directory of the
# drake project.
#
# drake_install_headers(<files...>)
#
# drake_install_headers([<args...>] FILES <files...>)
#
# Arguments:
# FILES <files...>
# List of header file names. File names given as relative paths are
# interpreted with respect to the current source directory. Files installed
# by this function are given permissions OWNER_READ, OWNER_WRITE, GROUP_READ,
# and WORLD_READ.
#
# <args...>
# Additional arguments to be passed through to install(FILES).
#------------------------------------------------------------------------------
function(drake_install_headers)
cmake_parse_arguments("" "" "" "FILES" ${ARGN})
if(NOT _FILES)
set(_FILES ${_UNPARSED_ARGUMENTS})
set(_UNPARSED_ARGUMENTS)
endif()
file(RELATIVE_PATH _relative_path
"${PROJECT_SOURCE_DIR}/"
"${CMAKE_CURRENT_SOURCE_DIR}")
install(FILES ${_FILES}
DESTINATION "${DRAKE_INSTALL_INCLUDE_DIR}/drake/${_relative_path}"
${_UNPARSED_ARGUMENTS})
endfunction()
#------------------------------------------------------------------------------
# Install a list of archive or library targets to the library installation
# directory ("lib", "lib32", or "lib64") of the drake project. Add the library
# targets to "drake-targets.cmake".
#
# drake_install_libraries(<targets...>)
#
# drake_install_libraries([<args...>] TARGETS <targets...>)
#
# Arguments:
# TARGETS <targets...>
# List of library targets to install.
#
# <args...>
# Additional arguments to be passed through to install(TARGETS).
#
# See the documentation of the "GNUInstallDirs" module for the rules that are
# used to choose the library installation directory for a given host operating
# system.
#------------------------------------------------------------------------------
function(drake_install_libraries)
cmake_parse_arguments("" "" "" "TARGETS" ${ARGN})
if(NOT _TARGETS)
set(_TARGETS ${_UNPARSED_ARGUMENTS})
set(_UNPARSED_ARGUMENTS)
endif()
install(TARGETS ${_TARGETS}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION "${DRAKE_INSTALL_LIBRARY_DIR}"
LIBRARY DESTINATION "${DRAKE_INSTALL_LIBRARY_DIR}"
RUNTIME DESTINATION "${DRAKE_INSTALL_RUNTIME_DIR}"
INCLUDES DESTINATION "${DRAKE_INSTALL_INCLUDE_DIR}"
${_UNPARSED_ARGUMENTS})
endfunction()
#------------------------------------------------------------------------------
# Generate and install a pkg-config .pc file for a package to the "pkgconfig"
# subdirectory of the library installation directory ("lib", "lib32", or
# "lib64") of the drake project.
#
# drake_install_pkg_config_file(<name> [TARGET <target>]
# [DESCRIPTION <description>] [URL <url>]
# [VERSION <major.minor.patch>]
# [REQUIRES <packages...>]
# [LIBS <flags...>] [CFLAGS <flags...>]
# [CLASSPATH <paths...>])
#
# Arguments:
# <name>
# Name of the pkg-config package. The generated pkg-config file will be
# named "<name>.pc".
#
# TARGET <target>
# Target associated with the pkg-config package. Reserved for future use.
#
# DESCRIPTION <description>
# Description field of the package.
#
# URL <url>
# URL field of the package or "http://drake.mit.edu/" if not specified.
#
# VERSION <major.minor.patch>
# Version field of the package or PROJECT_VERSION if not specified.
#
# REQUIRES <packages...>
# Requires field of the package.
#
# LIBS <flags...>
# Libs field of the package. The flag "-L${libdir}" is automatically
# prepended to the field.
#
# CFLAGS <flags...>
# Cflags field of the package. The flag "-I${includedir}" automatically
# prepended to the field.
#
# CLASSPATH <paths...>
# Non-standard classpath field of the package.
#
# See the documentation of the "GNUInstallDirs" module for the rules that are
# used to choose the library installation directory for a given host operating
# system.
#------------------------------------------------------------------------------
function(drake_install_pkg_config_file _NAME)
cmake_parse_arguments("" "" "DESCRIPTION;TARGET;URL;VERSION"
"CFLAGS;CLASSPATH;LIBS;REQUIRES" ${ARGN})
if(_TARGET)
# TODO(jamiesnape): Generate _REQUIRES automatically using this property
set_target_properties(${_TARGET} PROPERTIES PKG_CONFIG_NAME ${_NAME})
endif()
if(NOT _URL)
set(_URL "http://drake.mit.edu/")
endif()
if(NOT _VERSION)
set(_VERSION "${PROJECT_VERSION}")
endif()
if(_CLASSPATH)
string(REPLACE ";" ":" _classpath "${_CLASSPATH}")
set(_classpath "classpath=${_classpath}")
else()
set(_classpath)
endif()
if(_LIBS)
string(REPLACE ";" " " _libs "${_LIBS}")
set(_libs "-L\${libdir} ${_libs}")
else()
set(_libs)
endif()
string(REPLACE ";" " " _cflags "${_CFLAGS}")
string(REPLACE ";" " " _requires "${_REQUIRES}")
set(_pkg_config_file "${CMAKE_CURRENT_BINARY_DIR}/${_NAME}.pc")
configure_file("${PROJECT_SOURCE_DIR}/../cmake/template.pc.in"
"${_pkg_config_file}" @ONLY)
install(FILES "${_pkg_config_file}"
DESTINATION "${DRAKE_INSTALL_PKGCONFIG_DIR}")
endfunction()