forked from manips-sai-org/sai-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
105 lines (84 loc) · 3.2 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
cmake_minimum_required(VERSION 3.10)
project(SAI2-MODEL)
set(PROJECT_VERSION 0.1.0) # major version is zero for now since api will
# certainly change in future
set(CMAKE_CXX_FLAGS "-std=c++17 -I/usr/include -I/usr/local/include -fPIC")
if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/homebrew/include")
endif()
# set default build to release with debug info. mimic'ed from RBDL project.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
# Set the default build, and also the possible values of build type for
# cmake-gui
set(CMAKE_BUILD_TYPE
Release
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_TESTS "Build tests" OFF)
# include Eigen
find_package(Eigen3 REQUIRED)
# include RBDL
set(RBDL_LOCAL_DIR ${PROJECT_SOURCE_DIR}/rbdl)
set(RBDL_INCLUDE_DIR ${RBDL_LOCAL_DIR}/include ${RBDL_LOCAL_DIR}/build/include)
# include sai2-URDF
find_package(SAI2-URDF REQUIRED)
# include Parser
set(PARSER_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/parser)
set(PARSER_SOURCE ${PROJECT_SOURCE_DIR}/src/parser/UrdfToSai2Model.cpp
${PROJECT_SOURCE_DIR}/src/parser/Sai2ModelParserUtils.cpp)
# include Model
set(SAI2-MODEL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src)
set(MODEL_SOURCE ${PROJECT_SOURCE_DIR}/src/Sai2Model.cpp
${PROJECT_SOURCE_DIR}/src/RBDLExtensions.cpp)
# Add the include directory to the include paths
include_directories(
${SAI2-MODEL_INCLUDE_DIRS}
${SAI2-URDF_INCLUDE_DIRS}
${PARSER_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${RBDL_INCLUDE_DIR}
)
# Create the library
add_library(sai2-model STATIC ${MODEL_SOURCE} ${PARSER_SOURCE})
find_library(
RBDL_LIBRARIES rbdl
PATHS ${RBDL_LOCAL_DIR}/build
NO_DEFAULT_PATH)
set(SAI2-MODEL_LIBRARIES sai2-model ${RBDL_LIBRARIES})
# set the urdf model folder
set(URDF_MODELS_FOLDER ${PROJECT_SOURCE_DIR}/urdf_models)
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/../src/parser/Sai2Model_UrdfFolder.h
"#ifndef SAI2_MODEL_URDF_FOLDER_H_
#define SAI2_MODEL_URDF_FOLDER_H_
#define SAI2_MODEL_URDF_FOLDER \"${URDF_MODELS_FOLDER}\"
#endif // SAI2_MODEL_URDF_FOLDER_H_")
#
# export package
#
# export package for use from the build tree
export(TARGETS sai2-model FILE ${PROJECT_BINARY_DIR}/SAI2-MODELTargets.cmake)
export(PACKAGE SAI2-MODEL)
# configure package
set(CONF_INCLUDE_DIRS ${SAI2-MODEL_INCLUDE_DIRS} ${RBDL_INCLUDE_DIR})
set(CONF_LIBRARIES ${SAI2-MODEL_LIBRARIES})
# create package configuration and version files
configure_file(SAI2-MODELConfig.cmake.in
"${PROJECT_BINARY_DIR}/SAI2-MODELConfig.cmake" @ONLY)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SAI2-MODELConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
if(BUILD_EXAMPLES)
# add examples
add_subdirectory(${PROJECT_SOURCE_DIR}/examples)
endif()
if(BUILD_TESTS)
# add tests
add_subdirectory(${PROJECT_SOURCE_DIR}/tests)
endif()