-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
321 lines (284 loc) · 9.13 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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
SET ( TOOLKIT_VERSION_MAJOR 1 )
SET ( TOOLKIT_VERSION_MINOR 1 )
SET ( TOOLKIT_VERSION_PATCH 4 )
SET ( TOOLKIT_VERSION
${TOOLKIT_VERSION_MAJOR}.${TOOLKIT_VERSION_MINOR}.${TOOLKIT_VERSION_PATCH} )
STRING(TIMESTAMP TOOLKIT_BUILD_DATE "%Y-%m-%d")
PROJECT ( RBDL-Toolkit VERSION ${TOOLKIT_VERSION} )
CMAKE_MINIMUM_REQUIRED (VERSION 3.0)
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
OPTION(USE_QT6 "if on build toolkit using qt6 else qt5")
IF(APPLE)
OPTION(BUILD_OSX_BUNDLE "Build Application as osx app bundle" OFF)
ENDIF(APPLE)
IF(MSVC)
ADD_DEFINITIONS (-DWINDOWS_BUILD)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /permissive- ")
ENDIF(MSVC)
SET(CMAKE_CXX_STANDARD 17)
# The QT Interface
SET( QT_USE_QTXML TRUE )
SET( QT_WRAP_CPP TRUE )
SET(CMAKE_AUTOMOC ON )
SET(CMAKE_AUTORCC ON )
SET(CMAKE_AUTOUIC ON )
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTOOLKIT_DEBUG")
SET(CUSTOM_RBDL_PATH "" CACHE PATH "Path to specific RBDL Installation")
SET(CUSTOM_QT_PATH "" CACHE PATH "Path to Qt Installation")
SET(IFW_INSTALL_PATH "" CACHE PATH "Path to Qt Installer Framework Installation")
IF (CUSTOM_QT_PATH)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_PREFIX_PATH "${CUSTOM_QT_PATH}/lib/cmake")
ENDIF(CUSTOM_QT_PATH)
FIND_PACKAGE (RBDL COMPONENTS LUAMODEL URDFREADER REQUIRED)
FIND_PACKAGE (Eigen3 REQUIRED)
FIND_PACKAGE (Boost REQUIRED)
IF(USE_QT6)
FIND_PACKAGE (Qt6 REQUIRED COMPONENTS Core Gui Widgets 3DCore 3DExtras 3DRender 3DInput Concurrent )
ADD_DEFINITIONS (${QT_DEFINITIONS})
ADD_DEFINITIONS ( -DUSE_QT6 )
SET( QT_INCLUDE_DIR
${Qt6Core_INCLUDE_DIRS}
${Qt6Gui_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt63DCore_INCLUDE_DIRS}
${Qt63DExtras_INCLUDE_DIRS}
${Qt63DRender_INCLUDE_DIRS}
${Qt63DInput_INCLUDE_DIRS}
${Qt6Concurrent_INCLUDE_DIRS}
)
SET( QT_LIBRARIES
${Qt6Core_LIBRARIES}
${Qt6Gui_LIBRARIES}
${Qt6Widgets_LIBRARIES}
${Qt63DCore_LIBRARIES}
${Qt63DExtras_LIBRARIES}
${Qt63DRender_LIBRARIES}
${Qt63DInput_LIBRARIES}
${Qt6Concurrent_LIBRARIES}
)
QT6_WRAP_UI ( UI_SRC
ui/Timeline.ui
ui/ModelSelector.ui
ui/SceneGroupList.ui
ui/SettingsEditor.ui
ui/VectorEditor.ui
)
#Sources that contain q objects
QT6_WRAP_CPP ( MOC_SRCS
include/ToolkitApp.h
include/SceneWidget.h
include/ModelSelectorDialog.h
include/Timeline.h
include/VectorEditor.h
include/rbdl_wrapper.h
include/SceneGroupsWidget.h
include/variantdelegate.h
include/ToolkitSettings.h
)
ELSE (USE_QT6)
FIND_PACKAGE (Qt5 REQUIRED COMPONENTS Core Gui Widgets 3DCore 3DExtras 3DRender 3DInput Concurrent )
ADD_DEFINITIONS (${QT_DEFINITIONS})
SET( QT_INCLUDE_DIR
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt53DCore_INCLUDE_DIRS}
${Qt53DExtras_INCLUDE_DIRS}
${Qt53DRender_INCLUDE_DIRS}
${Qt53DInput_INCLUDE_DIRS}
${Qt5Concurrent_INCLUDE_DIRS}
)
SET( QT_LIBRARIES
${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt53DCore_LIBRARIES}
${Qt53DExtras_LIBRARIES}
${Qt53DRender_LIBRARIES}
${Qt53DInput_LIBRARIES}
${Qt5Concurrent_LIBRARIES}
)
QT5_WRAP_UI ( UI_SRC
ui/Timeline.ui
ui/ModelSelector.ui
ui/SceneGroupList.ui
ui/SettingsEditor.ui
ui/VectorEditor.ui
)
#Sources that contain q objects
QT5_WRAP_CPP ( MOC_SRCS
include/ToolkitApp.h
include/SceneWidget.h
include/ModelSelectorDialog.h
include/Timeline.h
include/VectorEditor.h
include/rbdl_wrapper.h
include/SceneGroupsWidget.h
include/variantdelegate.h
include/ToolkitSettings.h
)
ENDIF (USE_QT6)
CONFIGURE_FILE (
"${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit_config.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/include/toolkit_config.h"
)
INCLUDE_DIRECTORIES (${QT_INCLUDE_DIR})
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}/include)
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/vendor/urdfparser/include)
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}/ui)
INCLUDE_DIRECTORIES (${RBDL_INCLUDE_DIR})
INCLUDE_DIRECTORIES (${EIGEN3_INCLUDE_DIR})
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR})
IF ( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
ADD_DEFINITIONS (-DTOOKIT_VERSION="${TOOLKIT_VERSION}" -DINSTALL_DIR="${CMAKE_INSTALL_PREFIX}/share/ORB/rbdl-toolkit")
ELSE( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
ADD_COMPILE_DEFINITIONS (TOOKIT_VERSION="${TOOLKIT_VERSION}" INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/share/ORB/rbdl-toolkit")
ENDIF( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
IF(NOT APPLE)
IF(NOT MSVC)
CONFIGURE_FILE(extra/mk_appimage.sh mk_appimage.sh)
CONFIGURE_FILE(extra/mk_pluginbuilder.sh mk_pluginbuilder.sh)
ENDIF(NOT MSVC)
ENDIF(NOT APPLE)
ADD_SUBDIRECTORY (
vendor
)
SET ( ToolkitLib_SRCS
src/ToolkitApp.cc
src/Timeline.cc
src/ToolkitSettings.cc
src/SceneWidget.cc
src/ModelSelectorDialog.cc
src/util.cc
src/render_util.cc
src/math_util.cc
src/rbdl_wrapper.cc
src/variantdelegate.cc
src/toolkit_errors.cc
src/luamodel_wrapper.cc
src/urdfmodel_wrapper.cc
)
SET ( Toolkit_SRCS
src/main.cc
)
ADD_LIBRARY ( toolkitlib SHARED
${ToolkitLib_SRCS}
${MOC_SRCS}
${UI_SRC}
)
TARGET_COMPILE_DEFINITIONS (toolkitlib PRIVATE TOOLKIT_COMPILE_LIB)
TARGET_LINK_LIBRARIES ( toolkitlib
${QT_LIBRARIES}
${RBDL_LIBRARY}
${RBDL_LUAMODEL_LIBRARY}
${RBDL_URDFREADER_LIBRARY}
urdfparser
)
ADD_SUBDIRECTORY (
plugins
)
IF(BUILD_OSX_BUNDLE)
CONFIGURE_FILE(extra/mk_dmg.sh mk_dmg.sh)
SET( MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
SET( MACOSX_BUNDLE_GUI_IDENTIFIER orb.rbdl-toolkit)
SET( MACOSX_BUNDLE_INFO_STRING "RBDL-Toolkit Application for rigid body modeling")
SET( MACOSX_BUNDLE_ICON_FILE "rbdl-toolkit.icns")
SET( MACOSX_BUNDLE_LONG_VERISO ${TOOLKIT_VERSION})
SET( MACOSX_BUNDLE_SHORT_VERISO ${TOOLKIT_VERSION})
SET( MACOSX_BUNDLE_BUNDLE_VERISO ${TOOLKIT_VERSION})
ADD_EXECUTABLE ( rbdl-toolkit
MACOSX_BUNDLE
${Toolkit_SRCS}
extra/rbdl-toolkit.icns
)
SET_TARGET_PROPERTIES(
rbdl-toolkit
PROPERTIES
RESOURCE "extra/rbdl-toolkit.icns"
)
ADD_CUSTOM_TARGET(dmg
BYPRODUCTS rbdl-toolkit.dmg rbdl-toolkit.app
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/mk_dmg.sh
)
ELSE(BUILD_OSX_BUNDLE)
ADD_EXECUTABLE ( rbdl-toolkit
${Toolkit_SRCS}
)
ENDIF(BUILD_OSX_BUNDLE)
TARGET_LINK_LIBRARIES ( rbdl-toolkit
toolkitlib
)
IF (CUSTOM_QT_PATH)
ADD_CUSTOM_TARGET(appimage
BYPRODUCTS rbdl-toolkit-x86_64.AppImage rbdl-toolkit.AppDir
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/mk_appimage.sh -customqt
)
ELSE(CUSTOM_QT_PATH)
ADD_CUSTOM_TARGET(appimage
BYPRODUCTS rbdl-toolkit-x86_64.AppImage rbdl-toolkit.AppDir
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/mk_appimage.sh
)
ENDIF(CUSTOM_QT_PATH)
IF(NOT BUILD_OSX_BUNDLE)
IF(MSVC)
## the windeployqt executable
GET_TARGET_PROPERTY(QMAKE_EXE Qt5::qmake IMPORTED_LOCATION)
GET_FILENAME_COMPONENT(QT_BIN_DIR "${QMAKE_EXE}" DIRECTORY)
FIND_PROGRAM(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${QT_BIN_DIR}")
FIND_PROGRAM(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
#create script to deploy qt plugin dependencies
CONFIGURE_FILE(extra/windeploy.bat ${CMAKE_BINARY_DIR}/windeploy.bat)
CONFIGURE_FILE(extra/win_install.bat ${CMAKE_BINARY_DIR}/win_install.bat)
## Run windeployqt immediately after build
ADD_CUSTOM_COMMAND(TARGET rbdl-toolkit POST_BUILD
COMMAND ${CMAKE_BINARY_DIR}/windeploy.bat $<CONFIG>/rbdl-toolkit.exe
)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_BINARY_DIR}/win_install.bat ${CMAKE_INSTALL_PREFIX})")
FIND_PACKAGE(IFW)
IF(IFW_FOUND)
SET(INSTALLER_DIR ${CMAKE_BINARY_DIR}/rbdl-toolkit_Installer)
SET(INSTALLER_CONFIG_DIR ${INSTALLER_DIR}/config)
SET(INSTALLER_PACKAGE_DIR ${INSTALLER_DIR}/package)
MAKE_DIRECTORY(${INSTALLER_CONFIG_DIR})
MAKE_DIRECTORY(${INSTALLER_PACKAGE_DIR})
SET(INSTALLER_PACKAGE_DATA_DIR ${INSTALLER_PACKAGE_DIR}/orb.rbdl-toolkit/data)
SET(INSTALLER_PACKAGE_META_DIR ${INSTALLER_PACKAGE_DIR}/orb.rbdl-toolkit/meta)
MAKE_DIRECTORY(${INSTALLER_PACKAGE_DATA_DIR})
MAKE_DIRECTORY(${INSTALLER_PACKAGE_META_DIR})
FILE(COPY_FILE LICENSE ${INSTALLER_PACKAGE_META_DIR}/license.txt)
CONFIGURE_FILE(extra/installer_config.xml.cmake ${INSTALLER_CONFIG_DIR}/config.xml)
CONFIGURE_FILE(extra/installer_package.xml.cmake ${INSTALLER_PACKAGE_META_DIR}/package.xml)
CONFIGURE_FILE(extra/win_pack.bat.cmake ${CMAKE_BINARY_DIR}/win_pack.bat)
CONFIGURE_FILE(extra/win_create_installer.bat.cmake ${INSTALLER_DIR}/win_create_installer.bat)
ADD_CUSTOM_TARGET(installer
COMMAND ${CMAKE_BINARY_DIR}/win_pack.bat
)
ENDIF(IFW_FOUND)
ELSE(MSVC)
INSTALL ( TARGETS rbdl-toolkit RUNTIME DESTINATION bin )
INSTALL ( TARGETS toolkitlib LIBRARY DESTINATION lib )
ENDIF(MSVC)
ENDIF()
FILE ( GLOB MESH_FILES meshes/*.obj )
IF(BUILD_OSX_BUNDLE)
INSTALL ( FILES ${MESH_FILES} DESTINATION ${CMAKE_BINARY_DIR}/rbdl-toolkit.app/Contents/Resources/meshes )
ELSE(BUILD_OSX_BUNDLE)
IF(MSVC)
ADD_CUSTOM_COMMAND(TARGET rbdl-toolkit POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/meshes
${CMAKE_BINARY_DIR}/$<CONFIG>/meshes
)
ELSE(MSVC)
INSTALL ( FILES ${MESH_FILES} DESTINATION share/ORB/rbdl-toolkit/meshes )
ENDIF(MSVC)
ENDIF(BUILD_OSX_BUNDLE)