This repository has been archived by the owner on Nov 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmetapod.cmake
127 lines (117 loc) · 4.48 KB
/
metapod.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
# Copyright 2012,
#
# Sébastien Barthélémy (Aldebaran Robotics)
#
# This file is part of metapod.
# metapod is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# metapod 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 Lesser Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with metapod. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2010, 2012, 2013
# GENERATE_CONFIG_HEADER
#
# Generates a configuration header for DLL API import/export
#
# OUTPUT: path (including filename) of the generated file. Usually the filename
# is config.hh
# LIBRARY_NAME: the name of the library. It will be normalized.
FUNCTION(GENERATE_CONFIG_HEADER OUTPUT LIBRARY_NAME)
STRING(REGEX REPLACE "[^a-zA-Z0-9]" "_" LIBRARY_NAME "${LIBRARY_NAME}")
STRING(TOLOWER "${LIBRARY_NAME}" "LIBRARY_NAME_LOWER")
SET(EXPORT_SYMBOL "${LIBRARY_NAME_LOWER}_EXPORTS")
STRING(TOUPPER "${LIBRARY_NAME}" "LIBRARY_NAME")
# create the directory (and its parents)
GET_FILENAME_COMPONENT(OUTPUT_DIR "${OUTPUT}" PATH)
FILE(MAKE_DIRECTORY "${OUTPUT_DIR}")
# Generate the header. The following variables are used in the template
# LIBRARY_NAME: CPP symbol prefix, should match the compiled library name,
# usually in upper case
# EXPORT_SYMBOL: what symbol controls the switch between symbol
# import/export, usually libname_EXPORTS, with libname in
# lower case.
# PROJECT_VERSION: the project version
CONFIGURE_FILE(
${PROJECT_SOURCE_DIR}/cmake/config.hh.cmake
${OUTPUT}
@ONLY)
ENDFUNCTION(GENERATE_CONFIG_HEADER)
FUNCTION(FIND_GENERATOR GENERATOR_NAME)
SET(WITH_${GENERATOR_NAME} FALSE)
# maybe the user passed the location
IF(${GENERATOR_NAME}_EXECUTABLE)
SET(WITH_${GENERATOR_NAME} TRUE)
ELSE()
# last resort: search for it
FIND_PACKAGE(${GENERATOR_NAME} QUIET)
SET(WITH_${GENERATOR_NAME} ${${GENERATOR_NAME}_FOUND})
ENDIF()
SET(WITH_${GENERATOR_NAME} ${WITH_${GENERATOR_NAME}} PARENT_SCOPE)
ENDFUNCTION()
# ADD_SAMPLEURDFMODEL
#
# Call metapodfromurdf to create one of the sample models
#
# name: the name of the model. Either simple_arm or simple_humanoid.
# arg1: path to urdf file
# arg2: path to data files : config and license_file
# arg3: path to the directory where the model will be generated
FUNCTION(ADD_SAMPLEURDFMODEL name)
SET(_libname "metapod_${name}")
# Checking the path to the urdf file
IF(ARGV1)
SET(_urdf_file "${ARGV1}/${name}.urdf")
ELSE()
SET(_urdf_file "${PROJECT_SOURCE_DIR}/data/${name}.urdf")
ENDIF()
MESSAGE(STATUS "_urdf_file: ${_urdf_file}")
# Checking the path to the config file and the license
IF(ARGV2)
SET(_config_file "${ARGV2}/${name}.config")
SET(_license_file "${ARGV2}/${name}_license_file.txt")
ELSE()
SET(_config_file "${PROJECT_SOURCE_DIR}/data/${name}.config")
SET(_license_file "${PROJECT_SOURCE_DIR}/data/metapod_license_file.txt")
ENDIF()
# Checking the path where to generate the files
IF(argv3)
SET(_model_dir "${ARGV3}/${name}")
ELSE()
SET(_model_dir "${CMAKE_CURRENT_BINARY_DIR}/include/metapod/models/${name}")
ENDIF()
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
FIND_PROGRAM(LMETAPODFROMURDF_EXECUTABLE metapodfromurdf HINTS ${PROJECT_BINARY_DIR}/metapodfromurdf)
IF(NOT LMETAPODFROMURDF_EXECUTABLE)
IF(NOT BUILD_METAPODFROMURDF)
MESSAGE(ERROR " Could not find metapodfromurdf")
ELSE()
SET(LMETAPODFROMURDF_EXECUTABLE ${METAPODFROMURDF_EXECUTABLE})
ENDIF()
ENDIF()
SET(_sources
${_model_dir}/config.hh
${_model_dir}/${name}.hh
${_model_dir}/${name}.cc)
ADD_CUSTOM_COMMAND(
OUTPUT ${_sources}
COMMAND ${LMETAPODFROMURDF_EXECUTABLE}
--name ${name}
--libname ${_libname}
--directory ${_model_dir}
--config-file ${_config_file}
--license-file ${_license_file}
${_urdf_file}
DEPENDS ${METAPODFROMURDF_EXECUTABLE} ${_urdf_file} ${_config_file}
${_license_file}
MAIN_DEPENDENCY ${_urdf_file}
)
ADD_LIBRARY(${_libname} SHARED ${_sources})
INSTALL ( FILES ${_urdf_file} ${_config_file} ${_license_file}
DESTINATION share/metapod/data/${name} )
ENDFUNCTION()