forked from rdb/panda3d-thirdparty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libode.cmake
208 lines (173 loc) · 6.1 KB
/
libode.cmake
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
# Made by rdb, based on the premake4.lua that's in the build directory of the
# ode source tree. Released in the public domain. Use as you will.
cmake_minimum_required(VERSION 2.8)
project(ode)
######################################################################
## Configuration options
######################################################################
#option(WITH_DEMOS "Builds the demo applications and DrawStuff library" OFF)
#option(WITH_TESTS "Builds the unit test application" OFF)
option(WITH_GIMPACT "Use GIMPACT for trimesh collisions (experimental)" OFF)
option(WITH_LIBCCD "Uses libccd for handling some collision tests absent in ODE." ON)
option(NO_DIF "Exclude DIF (Dynamics Interchange Format) exports" OFF)
option(NO_TRIMESH "Exclude trimesh collision geometry" OFF)
option(WITH_OU "Use TLS for global caches (allows threaded collision checks for separated spaces)" OFF)
option(WITH_BUILTIN_THREADING_IMPL "Include built-in multithreaded threading implementation (still must be created and assigned to be used)" OFF)
option(NO_THREADING_INTF "Disable threading interface support (external implementations may not be assigned; overrides WITH_BUILTIN_THREADING_IMPL)" OFF)
option(16BIT_INDICES "Use 16-bit indices for trimeshes (default is 32-bit)" OFF)
option(OLD_TRIMESH "Use old OPCODE trimesh-trimesh collider" OFF)
option(BUILD_SHARED_LIBS "Build shared (DLL) version of the library" OFF)
if(MSVC)
# In MSVC, we can build both configurations.
option(ONLY_SINGLE "Only use single-precision math" OFF)
option(ONLY_DOUBLE "Only use double-precision math" OFF)
else()
# In other systems, we must choose at configure time.
option(WITH_DOUBLE_PRECISION "Use double-precision math" OFF)
if(WITH_DOUBLE_PRECISION)
set(ONLY_DOUBLE ON)
set(ONLY_SINGLE OFF)
else()
set(ONLY_DOUBLE OFF)
set(ONLY_SINGLE ON)
endif()
endif()
include_directories(include ode/src)
if(WIN32)
add_definitions(-DWIN32)
endif()
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(/D_CRT_SECURE_NO_DEPRECATE /D_USE_MATH_DEFINES /wd4244)
endif()
if(APPLE)
add_definitions(-DMAC_OS_X_VERSION=1050)
endif()
######################################################################
## Write a custom <config.h> to build, based on the supplied flags
######################################################################
if(NO_TRIMESH)
elseif(WITH_GIMPACT)
set(dTRIMESH_ENABLED 1)
set(dTRIMESH_GIMPACT 1)
else()
set(dTRIMESH_ENABLED 1)
set(dTRIMESH_OPCODE 1)
endif()
if(WITH_OU OR NOT NO_THREADING_INTF)
set(dOU_ENABLED 1)
set(dATOMICS_ENABLED 1)
endif()
if(WITH_OU)
set(dTLS_ENABLED 1)
endif()
if(NO_THREADING_INTF)
set(dTHREADING_INTF_DISABLED 1)
elseif(WITH_BUILDIN_THREADING_IMPL)
set(dBUILTIN_THREADING_IMPL_ENABLED 1)
endif()
if(16BIT_INDICES)
set(dTRIMESH_16BIT_INDICES 1)
endif()
if(OLD_TRIMESH)
set(dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 1)
endif()
configure_file(ode/src/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/ode/src/config.h)
############################
## Write precision headers
############################
if(ONLY_SINGLE)
set(ODE_PRECISION dSINGLE)
set(CCD_PRECISION CCD_SINGLE)
elseif(ONLY_DOUBLE)
set(ODE_PRECISION dDOUBLE)
set(CCD_PRECISION CCD_DOUBLE)
else()
set(ODE_PRECISION dUNDEFINEDPRECISION)
set(CCD_PRECISION CCD_UNDEFINEDPRECISION)
endif()
configure_file(include/ode/precision.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/ode/precision.h)
configure_file(libccd/src/ccd/precision.h.in ${CMAKE_CURRENT_SOURCE_DIR}/libccd/src/ccd/precision.h)
######################################################################
## The ODE library project
######################################################################
include_directories(
ode/src/joints
OPCODE
GIMPACT/include
libccd/src
)
file(GLOB ODE_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
include/ode/*.h
ode/src/joints/*.h
ode/src/joints/*.cpp
ode/src/*.h
ode/src/*.c
ode/src/*.cpp
)
file(GLOB OPCODE_FILES "OPCODE/*.cpp" "OPCODE/Ice/*.cpp" "OPCODE/*.h" "OPCODE/Ice/*.h")
file(GLOB GIMPACT_FILES "GIMPACT/src/*.cpp" "GIMPACT/include/GIMPACT/*.h")
file(GLOB LIBCCD_FILES "libccd/src/ccd/*.h" "libccd/src/*.c")
file(GLOB OU_FILES "ou/include/ou/*.h" "ou/src/ou/*.cpp")
source_group(ode FILES ${ODE_FILES})
source_group(opcode FILES ${OPCODE_FILES})
source_group(gimpact FILES ${GIMPACT_FILES})
source_group(libccd FILES ${LIBCCD_FILES})
source_group(ou FILES ${OU_FILES})
set(SOURCES ${ODE_FILES})
list(REMOVE_ITEM SOURCES ode/src/collision_std.cpp)
if(WITH_OU OR NOT NO_THREADING_INTF)
include_directories(ou/include)
set(SOURCES ${SOURCES} ${OU_FILES})
add_definitions(-D_OU_NAMESPACE=odeou)
endif()
if(NO_DIF)
list(REMOVE_ITEM SOURCES ode/src/export-dif.cpp)
endif()
if(NO_TRIMESH)
list(REMOVE_ITEM SOURCES
ode/src/collision_trimesh_colliders.h
ode/src/collision_trimesh_internal.h
ode/src/collision_trimesh_opcode.cpp
ode/src/collision_trimesh_gimpact.cpp
ode/src/collision_trimesh_box.cpp
ode/src/collision_trimesh_ccylinder.cpp
ode/src/collision_cylinder_trimesh.cpp
ode/src/collision_trimesh_distance.cpp
ode/src/collision_trimesh_ray.cpp
ode/src/collision_trimesh_sphere.cpp
ode/src/collision_trimesh_trimesh.cpp
ode/src/collision_trimesh_plane.cpp
)
elseif(WITH_GIMPACT)
set(SOURCES ${SOURCES} ${GIMPACT_FILES})
else()
set(SOURCES ${SOURCES} ${OPCODE_FILES})
endif()
if(WITH_LIBCCD)
set(SOURCES ${SOURCES} ${LIBCCD_FILES})
add_definitions(-DdLIBCCD_ENABLED -DdLIBCCD_CYL_CYL)
endif()
if(BUILD_SHARED_LIBS)
add_definitions(-DODE_DLL)
else()
add_definitions(-DODE_LIB)
endif()
if(WITH_GIMPACT)
set(SOURCES ${SOURCES} ${GIMPACT_FILES})
else()
set(SOURCES ${SOURCES} ${OPCODE_FILES})
endif()
if(MSVC)
add_library(ode_single ${SOURCES})
add_library(ode_double ${SOURCES})
target_compile_definitions(ode_single PUBLIC -DdIDESINGLE -DCCD_IDESINGLE)
target_compile_definitions(ode_double PUBLIC -DdIDEDOUBLE -DCCD_IDEDOUBLE)
install(TARGETS ode_single ode_double DESTINATION lib)
else()
add_library(ode ${SOURCES})
install(TARGETS ode DESTINATION lib)
endif()
file(GLOB ODE_HEADERS include/ode/*.h)
install(FILES ${ODE_HEADERS} DESTINATION include/ode)