-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
143 lines (119 loc) · 3.27 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
cmake_minimum_required(VERSION 3.16...3.22)
option(VAMP_LTO "Use LTO." ON)
option(VAMP_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output." ON)
option(VAMP_FORCE_CLANG "Force the use of Clang." OFF)
option(VAMP_BUILD_OMPL_DEMO "Build VAMP C++ OMPL Integration Demo Script" OFF)
option(VAMP_OMPL_PATH "Search Path for OMPL Installation - Only Needed for Demo Script" "")
if(VAMP_FORCE_CLANG)
find_program(CLANG "clang")
find_program(CLANGPP "clang++")
set(CMAKE_C_COMPILER ${CLANG} CACHE STRING "C compiler" FORCE)
set(CMAKE_CXX_COMPILER ${CLANGPP} CACHE STRING "C++ compiler" FORCE)
endif()
if(VAMP_FORCE_COLORED_OUTPUT)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
project(
vamp
VERSION 0.2
LANGUAGES C CXX
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CompilerSettings)
include(FetchInitCPM)
include(Dependencies)
list(APPEND VAMP_EXT_SOURCES
src/impl/vamp/bindings/python.cc
src/impl/vamp/bindings/environment.cc
src/impl/vamp/bindings/settings.cc
)
list(APPEND VAMP_ROBOT_MODULES
sphere
ur5
panda
fetch
baxter
)
foreach(robot_name IN LISTS VAMP_ROBOT_MODULES)
list(APPEND VAMP_EXT_SOURCES "src/impl/vamp/bindings/${robot_name}.cc")
endforeach()
list(APPEND VAMP_EXT_INCLUDES
${NIGH_INCLUDE_DIRS}
${PDQSORT_INCLUDE_DIRS}
src/impl
)
nanobind_add_module(_core_ext
NB_STATIC
STABLE_ABI
NOMINSIZE
${VAMP_EXT_SOURCES}
)
target_include_directories(_core_ext
SYSTEM PRIVATE
${VAMP_EXT_INCLUDES}
)
target_link_libraries(_core_ext
PRIVATE
Eigen3::Eigen
)
if($ENV{GITHUB_ACTIONS})
set(STUB_PREFIX "")
else()
set(STUB_PREFIX "${CMAKE_BINARY_DIR}/stubs/")
endif()
nanobind_add_stub(
vamp_stub
MODULE _core_ext
OUTPUT "${STUB_PREFIX}__init__.pyi"
PYTHON_PATH $<TARGET_FILE_DIR:_core_ext>
DEPENDS _core_ext
VERBOSE
)
foreach(robot_name IN LISTS VAMP_ROBOT_MODULES)
nanobind_add_stub(
"vamp_${robot_name}_stub"
MODULE "_core_ext.${robot_name}"
OUTPUT "${STUB_PREFIX}${robot_name}.pyi"
PYTHON_PATH $<TARGET_FILE_DIR:_core_ext>
DEPENDS _core_ext
VERBOSE
)
endforeach()
install(
TARGETS _core_ext
LIBRARY
DESTINATION vamp/_core
)
install(
FILES "${STUB_PREFIX}__init__.pyi"
DESTINATION "${CMAKE_SOURCE_DIR}/src/vamp/_core"
)
foreach(robot_name IN LISTS VAMP_ROBOT_MODULES)
install(
FILES "${STUB_PREFIX}${robot_name}.pyi"
DESTINATION "${CMAKE_SOURCE_DIR}/src/vamp/_core"
)
endforeach()
if(VAMP_BUILD_OMPL_DEMO)
find_package(ompl QUIET PATHS ${VAMP_OMPL_PATH})
if(ompl_FOUND)
add_executable(vamp_ompl_integration scripts/cpp/ompl_integration.cc)
target_link_libraries(vamp_ompl_integration PRIVATE ompl::ompl Eigen3::Eigen)
target_include_directories(vamp_ompl_integration SYSTEM PRIVATE ${VAMP_EXT_INCLUDES})
else()
message(WARNING "OMPL not found! Cannot build OMPL demo.")
endif()
endif()