-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
75 lines (65 loc) · 5.83 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
################################################################################
# #
# Copyright (C) 2018 Fondazione Istitito Italiano di Tecnologia (IIT) #
# All Rights Reserved. #
# #
################################################################################
cmake_minimum_required(VERSION 3.5)
project(ironcub-mk1-software
VERSION 0.0.1
LANGUAGES C CXX)
# Disable in source build
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds of ironcub-mk1-software are not allowed. "
"Please remove CMakeCache.txt and the CMakeFiles/ directory, then build out-of-source. "
"If you really want to do an in-source build, feel free to comment out this error.")
endif("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
# Check the Operative System
if(MSVC OR WIN32)
set(EXPORT_VAR "set")
set(PATH_SEPARATOR "\\")
set(VARIABLE_START "%")
set(VARIABLE_END "%")
set(PATH_LIST_SEPARATOR ";")
set(PLUGIN_FOLDER_NAME "bin")
set(SETUP_SCRIPT_EXTENSION ".bat")
elseif(UNIX)
set(EXPORT_VAR "export")
set(PATH_SEPARATOR "/")
set(VARIABLE_START "$")
set(VARIABLE_END "")
set(PATH_LIST_SEPARATOR ":")
set(PLUGIN_FOLDER_NAME "lib")
set(SETUP_SCRIPT_EXTENSION ".sh")
endif()
option(ENABLE_MK1_MODEL_GENERATION "Re-Generate iRonCub-Mk1 urdf model." FALSE)
option(ENABLE_MK1_1_MODEL_GENERATION "Re-Generate iRonCub-Mk1_1 urdf model." FALSE)
option(INSTALL_IRONCUB_MODELS "Install iRonCub models in CMAKE_INSTALL_PREFIX." TRUE)
option(INSTALL_LIBRARY "Install iRonCub gazebo plugin and simulink library." TRUE)
option(USE_NONLINEAR_JET_DYNAMICS_PLUGIN "Install the nonlinear dynamics of the jet" FALSE)
option(USE_FIRST_ORDER_JET_DYNAMICS_PLUGIN "Install the firstorder dynamics of the jet" TRUE)
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}" IRONCUB_SOURCE_DIR)
# Set paths for using the iRonCub models in Gazebo
set(SETUP_PATH_GAZEBO_MODELS "
${EXPORT_VAR} GAZEBO_MODEL_PATH=${VARIABLE_START}GAZEBO_MODEL_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}
${EXPORT_VAR} GAZEBO_MODEL_PATH=${VARIABLE_START}GAZEBO_MODEL_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}iRonCub-Mk1${PATH_SEPARATOR}iRonCub${PATH_SEPARATOR}robots
${EXPORT_VAR} GAZEBO_MODEL_PATH=${VARIABLE_START}GAZEBO_MODEL_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}iRonCub-Mk1_1${PATH_SEPARATOR}iRonCub${PATH_SEPARATOR}robots
${EXPORT_VAR} GAZEBO_RESOURCE_PATH=${VARIABLE_START}GAZEBO_RESOURCE_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}worlds${PATH_SEPARATOR}iRonCub-Mk1_world
${EXPORT_VAR} GAZEBO_RESOURCE_PATH=${VARIABLE_START}GAZEBO_RESOURCE_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}worlds${PATH_SEPARATOR}iRonCub-Mk1_1_world
${EXPORT_VAR} YARP_DATA_DIRS=${VARIABLE_START}YARP_DATA_DIRS${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}iRonCub-Mk1${PATH_SEPARATOR}iRonCub${PATH_SEPARATOR}
${EXPORT_VAR} YARP_DATA_DIRS=${VARIABLE_START}YARP_DATA_DIRS${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_SOURCE_DIR${VARIABLE_END}${PATH_SEPARATOR}models${PATH_SEPARATOR}iRonCub-Mk1_1${PATH_SEPARATOR}iRonCub${PATH_SEPARATOR}")
# Add jets-plugin to Gazebo plugin path
set(SETUP_PATH_GAZEBO_PLUGINS "${EXPORT_VAR} GAZEBO_PLUGIN_PATH=${VARIABLE_START}GAZEBO_PLUGIN_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}${PLUGIN_FOLDER_NAME}")
# Add Simulink library to MATLAB path
set(SETUP_PATH_SIMULINK_LIBRARY "
${EXPORT_VAR} MATLABPATH=${VARIABLE_START}MATLABPATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}lib${PATH_SEPARATOR}simulink_v1${PATH_SEPARATOR}
${EXPORT_VAR} MATLABPATH=${VARIABLE_START}MATLABPATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}lib${PATH_SEPARATOR}simulink_v1${PATH_SEPARATOR}matlab_src${PATH_SEPARATOR}
${EXPORT_VAR} MATLABPATH=${VARIABLE_START}MATLABPATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}lib${PATH_SEPARATOR}simulink_v1${PATH_SEPARATOR}conf${PATH_SEPARATOR}
${EXPORT_VAR} BLOCKFACTORY_PLUGIN_PATH=${VARIABLE_START}BLOCKFACTORY_PLUGIN_PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}${PLUGIN_FOLDER_NAME}
${EXPORT_VAR} YARP_DATA_DIRS=${VARIABLE_START}YARP_DATA_DIRS${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}lib${PATH_SEPARATOR}simulink_v1${PATH_SEPARATOR}conf${PATH_SEPARATOR}
${EXPORT_VAR} PATH=${VARIABLE_START}PATH${VARIABLE_END}${PATH_LIST_SEPARATOR}${VARIABLE_START}IRONCUB_SOFTWARE_INSTALL_PREFIX${VARIABLE_END}${PATH_SEPARATOR}bin${PATH_SEPARATOR}")
add_subdirectory(lib)
add_subdirectory(models)
# Configure MATLAB startup file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/setup.in ${CMAKE_BINARY_DIR}/share/setup${SETUP_SCRIPT_EXTENSION})
INSTALL(FILES ${CMAKE_BINARY_DIR}/share/setup${SETUP_SCRIPT_EXTENSION} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/ironcub-mk1-software)