-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
209 lines (156 loc) · 6.77 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
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
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(URRobotControllerRTC NONE)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")
set(LINUX_PACKAGE_GENERATOR "DEB")
#set(LINUX_PACKAGE_GENERATOR "RPM")
# component settings
set(RTC_NAME "${PROJECT_NAME}")
set(RTC_VERSION "1.0.0")
set(RTC_VERSION_MAJOR "1")
set(RTC_VERSION_MINOR "0")
set(RTC_VERSION_PATCH "0")
set(RTC_LANG "python")
set(RTC_DESCRIPTION "Controller RTC for Universal Robot URx")
set(RTC_VENDOR "takahasi")
set(RTC_MAINTAINER "[email protected]")
string(TOLOWER ${RTC_NAME} PACKAGE_NAME)
set(PACKAGE_VERSION "${RTC_VERSION_MAJOR}.${RTC_VERSION_MINOR}.${RTC_VERSION_PATCH}")
set(IDL_FILES ""
ManipulatorCommonInterface_Middle.idl
ManipulatorCommonInterface_Common.idl
)
set(EXEC_FILES ""
URRobotControllerRTC.py
ManipulatorCommonInterface_Middle_idl_example.py
ManipulatorCommonInterface_Common_idl_example.py
)
set(OTHER_SRCS CMakeLists.txt
RTC.xml URRobotControllerRTC.conf rtc.conf)
# check OpenRTM installed
find_package(OpenRTMPython REQUIRED)
# check doxygen installed
find_package(Doxygen)
if(DOXYGEN_FOUND STREQUAL "NO")
message(FATAL_ERROR "Doxygen not found.")
endif()
# check python installed
find_package(PythonInterp)
find_package(PythonLibs)
if(WIN32)
# add command path
set($ENV{PATH} $ENV{PATH} "${OPENRTM_DIR}/bin")
# set install path prefix
set(CMAKE_INSTALL_PREFIX "${OPENRTM_DIR}")
set(INSTALL_PREFIX "components/${RTC_LANG}/${PACKAGE_NAME}${PACKAGE_VERSION}")
else()
# add command path
set($ENV{PATH} $ENV{PATH} "${OPENRTM_DIR}/bin")
# set install path prefix
set(CMAKE_INSTALL_PREFIX "${OPENRTM_DIR}")
set(OPENRTM_SHARE_PREFIX "share/openrtm-${OPENRTM_VERSION_MAJOR}.${OPENRTM_VERSION_MINOR}")
set(INSTALL_PREFIX "${OPENRTM_SHARE_PREFIX}/components/${RTC_LANG}/${PACKAGE_NAME}${PACKAGE_VERSION}")
endif()
# add uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall_target.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall_target.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# add build target
add_custom_target(build ALL)
add_custom_command(TARGET build PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory bin)
foreach(idl ${IDL_FILES})
add_custom_command(TARGET build PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "IDL Compiling \"${idl}\""
COMMAND ${OPENRTM_IDLC} ${OPENRTM_IDLFLAGS} -Cbin "${PROJECT_SOURCE_DIR}/${idl}")
endforeach()
install(PROGRAMS ${EXEC_FILES} DESTINATION "${INSTALL_PREFIX}"
COMPONENT "applications")
install(FILES RTC.xml DESTINATION "${INSTALL_PREFIX}"
COMPONENT "applications")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/ DESTINATION "${INSTALL_PREFIX}"
COMPONENT "applications"
PATTERN "bin/*")
# target settings for document
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/doxyfile.in"
"${CMAKE_CURRENT_BINARY_DIR}/doc/doxyfile")
add_custom_target(doxygen COMMAND
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxyfile)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES doc)
get_target_property(DOC_TARGET doc TYPE)
if(NOT DOC_TARGET)
add_custom_target(doc)
endif()
add_dependencies(doc doxygen)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc DESTINATION "${INSTALL_PREFIX}"
COMPONENT "documents")
# install source files
install(FILES ${IDL_FILES} ${EXEC_FILES} ${OTHER_SRCS}
DESTINATION "${INSTALL_PREFIX}/src"
COMPONENT "sources")
install(DIRECTORY cmake_modules cpack_resources
DESTINATION "${INSTALL_PREFIX}/src"
COMPONENT "sources")
# package settings
set(CPACK_PACKAGE_NAME "${RTC_NAME}")
set(CPACK_PACKAGE_VERSION_MAJOR "${RTC_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${RTC_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${RTC_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_VENDOR "${RTC_VENDOR}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${RTC_DESCRIPTION}")
set(CPACK_PACKAGE_CONTACT "${RTC_MAINTAINER}")
set(CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/cpack_resources/License.txt")
set(CPACK_PACKAGE_DESCRIPTION_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/cpack_resources/Description.txt")
set(CPACK_COMPONENTS_ALL applications documents sources)
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Applications")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "RT-Component applications")
set(CPACK_COMPONENT_APPLICATIONS_DISABLED FALSE)
set(CPACK_COMPONENT_DOCUMENTS_DISPLAY_NAME "Documents")
set(CPACK_COMPONENT_DOCUMENTS_DESCRIPTION "RT-Component documents")
set(CPACK_COMPONENT_DOCUMENTS_DISABLED TRUE)
set(CPACK_COMPONENT_SOURCES_DISPLAY_NAME "Source files")
set(CPACK_COMPONENT_SOURCES_DESCRIPTION "RT-Component source files")
set(CPACK_COMPONENT_SOURCES_DISABLED TRUE)
if(WIN32)
set(CPACK_GENERATOR "WIX")
# Windows WiX package settings
set(CPACK_WIX_XSL "@CMAKE_CURRENT_BINARY_DIR@/wix.xsl")
set(CPACK_WIX_LANG "ja-jp")
set(CPACK_RESOURCE_FILE_LICENSE
"@CMAKE_CURRENT_SOURCE_DIR@/cpack_resources/License.rtf")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cpack_resources/wix.xsl.in"
"${CMAKE_CURRENT_BINARY_DIR}/wix.xsl" @ONLY)
set(CPACK_PACKAGE_FILE_NAME
"rtc${OPENRTM_VERSION}-${PACKAGE_NAME}${PACKAGE_VERSION}")
else()
set(CPACK_GENERATOR "${LINUX_PACKAGE_GENERATOR}")
if(CPACK_GENERATOR STREQUAL "DEB")
# Linux Debian package settings
set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}-1")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
set(CPACK_DEBIAN_PACKAGE_SECTION "main")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "openrtm-aist (>= 1.0.0)")
set(CPACK_PACKAGE_FILE_NAME
"rtc${OPENRTM_VERSION}-${PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
elseif(CPACK_GENERATOR STREQUAL "RPM")
# Linux RPM package settings
set(CPACK_RPM_PACKAGE_RELEASE "1.fc10")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "i386")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_PACKAGE_LICENSE "LGPL")
set(CPACK_RPM_PACKAGE_REQUIRES "OpenRTM-aist >= 1.0.0")
set(CPACK_PACKAGE_FILE_NAME
"rtc${OPENRTM_VERSION}-${PACKAGE_NAME}-${PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
endif()
endif()
message(STATUS "Package type: ${CPACK_GENERATOR}")
message(STATUS "Package name: ${CPACK_PACKAGE_FILE_NAME}")
include(CPack)