Fixed: Windows target Subsystem was fixed for demos in CMake to match changes in...
[ode.git] / CMakeLists.txt
blob59ed299d903225973500abbbf1b7a9edbfbee13f
1 cmake_minimum_required(VERSION 2.8.11)
3 project(ODE)
5 include(CheckFunctionExists)
6 include(CheckIncludeFiles)
7 include(CMakeDependentOption)
8 include(GNUInstallDirs)
10 set(VERSION_MAJOR 0)
11 set(VERSION_MINOR 16)
12 set(VERSION_PATCH 0)
13 set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
15 option(BUILD_SHARED_LIBS "Build shared libraries." ON)
16 option(ODE_16BIT_INDICES "Use 16-bit indices for trimeshes (default is 32-bit)." OFF)
17 option(ODE_NO_BUILTIN_THREADING_IMPL "Disable built-in multithreaded threading implementation." OFF)
18 option(ODE_NO_THREADING_INTF "Disable threading interface support (external implementations cannot be assigned." OFF)
19 option(ODE_OLD_TRIMESH "Use old OPCODE trimesh-trimesh collider." OFF)
20 option(ODE_WITH_DEMOS "Builds the demo applications and DrawStuff library." ON)
21 option(ODE_WITH_GIMPACT "Use GIMPACT for trimesh collisions (experimental)." OFF)
22 option(ODE_WITH_LIBCCD "Use libccd for handling some collision tests absent in ODE." OFF)
23 option(ODE_WITH_OPCODE "Use old OPCODE trimesh-trimesh collider." ON)
24 option(ODE_WITH_OU "Use TLS for global caches (allows threaded collision checks for separated spaces)." OFF)
25 option(ODE_WITH_TESTS "Builds the unit test application." ON)
27 cmake_dependent_option(ODE_WITH_LIBCCD_BOX_CYL "Use libccd for box-cylinder." ON "ODE_WITH_LIBCCD" OFF)
28 cmake_dependent_option(ODE_WITH_LIBCCD_CAP_CYL "Use libccd for capsule-cylinder." ON "ODE_WITH_LIBCCD" OFF)
29 cmake_dependent_option(ODE_WITH_LIBCCD_CYL_CYL "Use libccd for cylinder-cylinder." ON "ODE_WITH_LIBCCD" OFF)
30 cmake_dependent_option(ODE_WITH_LIBCCD_CONVEX_BOX "Use libccd for convex-box." ON "ODE_WITH_LIBCCD" OFF)
31 cmake_dependent_option(ODE_WITH_LIBCCD_CONVEX_CAP "Use libccd for convex-capsule." ON "ODE_WITH_LIBCCD" OFF)
32 cmake_dependent_option(ODE_WITH_LIBCCD_CONVEX_CONVEX "Use libccd for convex-convex." ON "ODE_WITH_LIBCCD" OFF)
33 cmake_dependent_option(ODE_WITH_LIBCCD_CONVEX_CYL "Use libccd for convex-cylinder." ON "ODE_WITH_LIBCCD" OFF)
34 cmake_dependent_option(ODE_WITH_LIBCCD_CONVEX_SPHERE "Use libccd for convex-sphere." ON "ODE_WITH_LIBCCD" OFF)
35 cmake_dependent_option(ODE_WITH_LIBCCD_SYSTEM "Use system libccd." OFF "ODE_WITH_LIBCCD" OFF)
37 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
38         option(ODE_DOUBLE_PRECISION "Use double-precision math." OFF)
39 else()
40         option(ODE_DOUBLE_PRECISION "Use double-precision math." ON)
41 endif()
43 find_package(OpenGL)
44 find_package(Threads)
46 set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR})
47 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${OPENGL_LIBRARIES})
49 if(APPLE AND OPENGL_FOUND)
50         set(HAVE_APPLE_OPENGL_FRAMEWORK ON)
51 endif()
52 check_include_files(alloca.h HAVE_ALLOCA_H)
53 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
54 check_include_files(inttypes.h HAVE_INTTYPES_H)
55 check_function_exists(isnan HAVE_ISNAN)
56 check_function_exists(isnanf HAVE_ISNANF)
57 check_include_files(malloc.h HAVE_MALLOC_H)
58 check_function_exists(pthread_attr_setstacklazy HAVE_PTHREAD_ATTR_SETSTACKLAZY)
59 check_function_exists(pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK)
60 check_include_files(stdint.h HAVE_STDINT_H)
61 check_include_files(sys/time.h HAVE_SYS_TIME_H)
62 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
63 check_include_files(unistd.h HAVE_UNISTD_H)
64 check_function_exists(_isnan HAVE__ISNAN)
65 check_function_exists(_isnanf HAVE__ISNANF)
66 check_function_exists(__isnan HAVE___ISNAN)
67 check_function_exists(__isnanf HAVE___ISNANF)
68 if(APPLE)
69         set(MAC_OS_X_VERSION 1000)
70         check_function_exists(OSAtomicAdd32Barrier MAC_OS_X_VERSION_1040)
71         if(MAC_OS_X_VERSION_1040)
72                 set(MAC_OS_X_VERSION 1040)
73         endif()
74         check_function_exists(OSAtomicAnd32OrigBarrier MAC_OS_X_VERSION_1050)
75         if(MAC_OS_X_VERSION_1050)
76                 set(MAC_OS_X_VERSION 1050)
77         endif()
78 endif()
79 if(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|x86.*|x86_64.*|amd64.*|AMD64.*")
80         set(PENTIUM ON)
81 endif()
82 if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64.*|amd64.*|AMD64.*")
83         set(X86_64_SYSTEM ON)
84 endif()
85 if(ODE_WITH_OU)
86         set(_OU_FEATURE_SET _OU_FEATURE_SET_TLS)
87 elseif(NOT ODE_NO_THREADING_INTF)
88         set(_OU_FEATURE_SET _OU_FEATURE_SET_ATOMICS)
89 else()
90         set(_OU_FEATURE_SET _OU_FEATURE_SET_BASICS)
91 endif()
92 set(_OU_NAMESPACE odeou)
93 if(WIN32 OR CYGWIN)
94         set(_OU_TARGET_OS _OU_TARGET_OS_WINDOWS)
95 elseif(APPLE)
96         set(_OU_TARGET_OS _OU_TARGET_OS_MAC)
97 elseif(QNXNTO)
98         set(_OU_TARGET_OS _OU_TARGET_OS_QNX)
99 elseif(CMAKE_SYSTEM MATCHES "SunOS-4")
100         set(_OU_TARGET_OS _OU_TARGET_OS_SUNOS)
101 else()
102         set(_OU_TARGET_OS _OU_TARGET_OS_GENUNIX)
103 endif()
105 configure_file(config.h.cmake.in ode/src/config.h)
107 if(ODE_DOUBLE_PRECISION)
108         set(CCD_PRECISION CCD_DOUBLE)
109         set(ODE_PRECISION dDOUBLE)
110 else()
111         set(CCD_PRECISION CCD_SINGLE)
112         set(ODE_PRECISION dSINGLE)
113 endif()
115 configure_file(libccd/src/ccd/precision.h.in include/ccd/precision.h)
116 configure_file(include/ode/precision.h.in include/ode/precision.h)
118 set(ODE_VERSION ${VERSION})
120 configure_file(include/ode/version.h.in include/ode/version.h)
122 set(
123         HDRS
124         include/ode/collision.h
125         include/ode/collision_space.h
126         include/ode/collision_trimesh.h
127         include/ode/common.h
128         include/ode/compatibility.h
129         include/ode/contact.h
130         include/ode/cooperative.h
131         include/ode/error.h
132         include/ode/export-dif.h
133         include/ode/mass.h
134         include/ode/matrix.h
135         include/ode/matrix_coop.h
136         include/ode/memory.h
137         include/ode/misc.h
138         include/ode/objects.h
139         include/ode/ode.h
140         include/ode/odeconfig.h
141         include/ode/odecpp.h
142         include/ode/odecpp_collision.h
143         include/ode/odeinit.h
144         include/ode/odemath.h
145         include/ode/odemath_legacy.h
146         include/ode/rotation.h
147         include/ode/threading.h
148         include/ode/threading_impl.h
149         include/ode/timer.h
150         ${CMAKE_CURRENT_BINARY_DIR}/include/ode/precision.h
151         ${CMAKE_CURRENT_BINARY_DIR}/include/ode/version.h
154 set(
155         SRCS
156         ode/src/array.cpp
157         ode/src/array.h
158         ode/src/box.cpp
159         ode/src/capsule.cpp
160         ode/src/collision_cylinder_box.cpp
161         ode/src/collision_cylinder_plane.cpp
162         ode/src/collision_cylinder_sphere.cpp
163         ode/src/collision_kernel.cpp
164         ode/src/collision_kernel.h
165         ode/src/collision_quadtreespace.cpp
166         ode/src/collision_sapspace.cpp
167         ode/src/collision_space.cpp
168         ode/src/collision_space_internal.h
169         ode/src/collision_std.h
170         ode/src/collision_transform.cpp
171         ode/src/collision_transform.h
172         ode/src/collision_trimesh_colliders.h
173         ode/src/collision_trimesh_disabled.cpp
174         ode/src/collision_trimesh_gimpact.h
175         ode/src/collision_trimesh_internal.h
176         ode/src/collision_trimesh_opcode.h
177         ode/src/collision_util.cpp
178         ode/src/collision_util.h
179         ode/src/common.h
180         ode/src/convex.cpp
181         ode/src/coop_matrix_types.h
182         ode/src/cylinder.cpp
183         ode/src/default_threading.cpp
184         ode/src/default_threading.h
185         ode/src/error.cpp
186         ode/src/error.h
187         ode/src/export-dif.cpp
188         ode/src/fastdot.cpp
189         ode/src/fastdot_impl.h
190         ode/src/fastldltfactor.cpp
191         ode/src/fastldltfactor_impl.h
192         ode/src/fastldltsolve.cpp
193         ode/src/fastldltsolve_impl.h
194         ode/src/fastlsolve.cpp
195         ode/src/fastlsolve_impl.h
196         ode/src/fastltsolve.cpp
197         ode/src/fastltsolve_impl.h
198         ode/src/fastvecscale.cpp
199         ode/src/fastvecscale_impl.h
200         ode/src/heightfield.cpp
201         ode/src/heightfield.h
202         ode/src/lcp.cpp
203         ode/src/lcp.h
204         ode/src/mass.cpp
205         ode/src/mat.cpp
206         ode/src/mat.h
207         ode/src/matrix.cpp
208         ode/src/matrix.h
209         ode/src/memory.cpp
210         ode/src/misc.cpp
211         ode/src/nextafterf.c
212         ode/src/objects.cpp
213         ode/src/objects.h
214         ode/src/obstack.cpp
215         ode/src/obstack.h
216         ode/src/ode.cpp
217         ode/src/odeinit.cpp
218         ode/src/odemath.cpp
219         ode/src/odemath.h
220         ode/src/odeou.h
221         ode/src/odetls.h
222         ode/src/plane.cpp
223         ode/src/quickstep.cpp
224         ode/src/quickstep.h
225         ode/src/ray.cpp
226         ode/src/resource_control.cpp
227         ode/src/resource_control.h
228         ode/src/rotation.cpp
229         ode/src/simple_cooperative.cpp
230         ode/src/simple_cooperative.h
231         ode/src/sphere.cpp
232         ode/src/step.cpp
233         ode/src/step.h
234         ode/src/threaded_solver_ldlt.h
235         ode/src/threading_atomics_provs.h
236         ode/src/threading_base.cpp
237         ode/src/threading_base.h
238         ode/src/threading_fake_sync.h
239         ode/src/threading_impl.cpp
240         ode/src/threading_impl.h
241         ode/src/threading_impl_posix.h
242         ode/src/threading_impl_templates.h
243         ode/src/threading_impl_win.h
244         ode/src/threading_pool_posix.cpp
245         ode/src/threading_pool_win.cpp
246         ode/src/threadingutils.h
247         ode/src/timer.cpp
248         ode/src/typedefs.h
249         ode/src/util.cpp
250         ode/src/util.h
251         ode/src/joints/amotor.cpp
252         ode/src/joints/amotor.h
253         ode/src/joints/ball.cpp
254         ode/src/joints/ball.h
255         ode/src/joints/contact.cpp
256         ode/src/joints/contact.h
257         ode/src/joints/dball.cpp
258         ode/src/joints/dball.h
259         ode/src/joints/dhinge.cpp
260         ode/src/joints/dhinge.h
261         ode/src/joints/fixed.cpp
262         ode/src/joints/fixed.h
263         ode/src/joints/hinge.cpp
264         ode/src/joints/hinge.h
265         ode/src/joints/hinge2.cpp
266         ode/src/joints/hinge2.h
267         ode/src/joints/joint.cpp
268         ode/src/joints/joint.h
269         ode/src/joints/joint_internal.h
270         ode/src/joints/joints.h
271         ode/src/joints/lmotor.cpp
272         ode/src/joints/lmotor.h
273         ode/src/joints/null.cpp
274         ode/src/joints/null.h
275         ode/src/joints/piston.cpp
276         ode/src/joints/piston.h
277         ode/src/joints/plane2d.cpp
278         ode/src/joints/plane2d.h
279         ode/src/joints/pr.cpp
280         ode/src/joints/pr.h
281         ode/src/joints/pu.cpp
282         ode/src/joints/pu.h
283         ode/src/joints/slider.cpp
284         ode/src/joints/slider.h
285         ode/src/joints/transmission.cpp
286         ode/src/joints/transmission.h
287         ode/src/joints/universal.cpp
288         ode/src/joints/universal.h
291 if(ODE_WITH_GIMPACT AND NOT ODE_NO_TRIMESH)
292         list(
293                 APPEND SRCS
294                 GIMPACT/src/gim_boxpruning.cpp
295                 GIMPACT/src/gim_contact.cpp
296                 GIMPACT/src/gim_math.cpp
297                 GIMPACT/src/gim_memory.cpp
298                 GIMPACT/src/gim_tri_tri_overlap.cpp
299                 GIMPACT/src/gim_trimesh.cpp
300                 GIMPACT/src/gim_trimesh_capsule_collision.cpp
301                 GIMPACT/src/gim_trimesh_ray_collision.cpp
302                 GIMPACT/src/gim_trimesh_sphere_collision.cpp
303                 GIMPACT/src/gim_trimesh_trimesh_collision.cpp
304                 GIMPACT/src/gimpact.cpp
305                 ode/src/collision_convex_trimesh.cpp
306                 ode/src/collision_cylinder_trimesh.cpp
307                 ode/src/collision_trimesh_box.cpp
308                 ode/src/collision_trimesh_ccylinder.cpp
309                 ode/src/collision_trimesh_gimpact.cpp
310                 ode/src/collision_trimesh_internal.cpp
311                 ode/src/collision_trimesh_internal_impl.h
312                 ode/src/collision_trimesh_internal.h
313                 ode/src/collision_trimesh_plane.cpp
314                 ode/src/collision_trimesh_ray.cpp
315                 ode/src/collision_trimesh_sphere.cpp
316                 ode/src/collision_trimesh_trimesh.cpp
317                 ode/src/gimpact_contact_export_helper.cpp
318                 ode/src/gimpact_contact_export_helper.h
319                 ode/src/gimpact_gim_contact_accessor.h
320                 ode/src/gimpact_plane_contact_accessor.h
321         )
322 endif()
324 if(ODE_WITH_LIBCCD)
325         if(NOT ODE_WITH_LIBCCD_SYSTEM)
326                 list(
327                         APPEND SRCS
328                         libccd/src/alloc.c
329                         libccd/src/ccd.c
330                         libccd/src/mpr.c
331                         libccd/src/polytope.c
332                         libccd/src/support.c
333                         libccd/src/vec3.c
334                         libccd/src/ccd/alloc.h
335                         libccd/src/ccd/ccd.h
336                         libccd/src/ccd/compiler.h
337                         libccd/src/ccd/dbg.h
338                         libccd/src/ccd/list.h
339                         libccd/src/ccd/quat.h
340                         libccd/src/ccd/polytope.h
341                         libccd/src/ccd/simplex.h
342                         libccd/src/ccd/support.h
343                         libccd/src/ccd/vec3.h
344                         libccd/src/custom/ccdcustom/quat.h
345                         libccd/src/custom/ccdcustom/vec3.h
346                 )
347         endif()
348         
349         list(
350                 APPEND SRCS
351                 ode/src/collision_libccd.cpp
352                 ode/src/collision_libccd.h
353         )
354 endif()
356 if(ODE_WITH_OPCODE AND NOT ODE_NO_TRIMESH)
357         list(
358                 APPEND SRCS
359                 ode/src/collision_convex_trimesh.cpp
360                 ode/src/collision_cylinder_trimesh.cpp
361                 ode/src/collision_trimesh_box.cpp
362                 ode/src/collision_trimesh_ccylinder.cpp
363                 ode/src/collision_trimesh_internal.cpp
364                 ode/src/collision_trimesh_internal_impl.h
365                 ode/src/collision_trimesh_internal.h
366                 ode/src/collision_trimesh_opcode.cpp
367                 ode/src/collision_trimesh_plane.cpp
368                 ode/src/collision_trimesh_ray.cpp
369                 ode/src/collision_trimesh_sphere.cpp
370                 ode/src/collision_trimesh_trimesh.cpp
371                 ode/src/collision_trimesh_trimesh_old.cpp
372                 OPCODE/OPC_AABBCollider.cpp
373                 OPCODE/OPC_AABBCollider.h
374                 OPCODE/OPC_AABBTree.cpp
375                 OPCODE/OPC_AABBTree.h
376                 OPCODE/OPC_BaseModel.cpp
377                 OPCODE/OPC_BaseModel.h
378                 OPCODE/OPC_BoxBoxOverlap.h
379                 OPCODE/OPC_Collider.cpp
380                 OPCODE/OPC_Collider.h
381                 OPCODE/OPC_Common.cpp
382                 OPCODE/OPC_Common.h
383                 OPCODE/OPC_HybridModel.cpp
384                 OPCODE/OPC_HybridModel.h
385                 OPCODE/OPC_IceHook.h
386                 OPCODE/OPC_LSSAABBOverlap.h
387                 OPCODE/OPC_LSSCollider.cpp
388                 OPCODE/OPC_LSSCollider.h
389                 OPCODE/OPC_LSSTriOverlap.h
390                 OPCODE/OPC_MeshInterface.cpp
391                 OPCODE/OPC_MeshInterface.h
392                 OPCODE/OPC_Model.cpp
393                 OPCODE/OPC_Model.h
394                 OPCODE/OPC_OBBCollider.cpp
395                 OPCODE/OPC_OBBCollider.h
396                 OPCODE/OPC_OptimizedTree.cpp
397                 OPCODE/OPC_OptimizedTree.h
398                 OPCODE/OPC_Picking.cpp
399                 OPCODE/OPC_Picking.h
400                 OPCODE/OPC_PlanesAABBOverlap.h
401                 OPCODE/OPC_PlanesCollider.cpp
402                 OPCODE/OPC_PlanesCollider.h
403                 OPCODE/OPC_PlanesTriOverlap.h
404                 OPCODE/OPC_RayAABBOverlap.h
405                 OPCODE/OPC_RayCollider.cpp
406                 OPCODE/OPC_RayCollider.h
407                 OPCODE/OPC_RayTriOverlap.h
408                 OPCODE/OPC_Settings.h
409                 OPCODE/OPC_SphereAABBOverlap.h
410                 OPCODE/OPC_SphereCollider.cpp
411                 OPCODE/OPC_SphereCollider.h
412                 OPCODE/OPC_SphereTriOverlap.h
413                 OPCODE/OPC_TreeBuilders.cpp
414                 OPCODE/OPC_TreeBuilders.h
415                 OPCODE/OPC_TreeCollider.cpp
416                 OPCODE/OPC_TreeCollider.h
417                 OPCODE/OPC_TriBoxOverlap.h
418                 OPCODE/OPC_TriTriOverlap.h
419                 OPCODE/OPC_VolumeCollider.cpp
420                 OPCODE/OPC_VolumeCollider.h
421                 OPCODE/Opcode.cpp
422                 OPCODE/Opcode.h
423                 OPCODE/Stdafx.h
424                 OPCODE/Ice/IceAABB.cpp
425                 OPCODE/Ice/IceAABB.h
426                 OPCODE/Ice/IceAxes.h
427                 OPCODE/Ice/IceBoundingSphere.h
428                 OPCODE/Ice/IceContainer.cpp
429                 OPCODE/Ice/IceContainer.h
430                 OPCODE/Ice/IceFPU.h
431                 OPCODE/Ice/IceHPoint.cpp
432                 OPCODE/Ice/IceHPoint.h
433                 OPCODE/Ice/IceIndexedTriangle.cpp
434                 OPCODE/Ice/IceIndexedTriangle.h
435                 OPCODE/Ice/IceLSS.h
436                 OPCODE/Ice/IceMatrix3x3.cpp
437                 OPCODE/Ice/IceMatrix3x3.h
438                 OPCODE/Ice/IceMatrix4x4.cpp
439                 OPCODE/Ice/IceMatrix4x4.h
440                 OPCODE/Ice/IceMemoryMacros.h
441                 OPCODE/Ice/IceOBB.cpp
442                 OPCODE/Ice/IceOBB.h
443                 OPCODE/Ice/IcePairs.h
444                 OPCODE/Ice/IcePlane.cpp
445                 OPCODE/Ice/IcePlane.h
446                 OPCODE/Ice/IcePoint.cpp
447                 OPCODE/Ice/IcePoint.h
448                 OPCODE/Ice/IcePreprocessor.h
449                 OPCODE/Ice/IceRandom.cpp
450                 OPCODE/Ice/IceRandom.h
451                 OPCODE/Ice/IceRay.cpp
452                 OPCODE/Ice/IceRay.h
453                 OPCODE/Ice/IceRevisitedRadix.cpp
454                 OPCODE/Ice/IceRevisitedRadix.h
455                 OPCODE/Ice/IceSegment.cpp
456                 OPCODE/Ice/IceSegment.h
457                 OPCODE/Ice/IceTriangle.cpp
458                 OPCODE/Ice/IceTriangle.h
459                 OPCODE/Ice/IceTriList.h
460                 OPCODE/Ice/IceTypes.h
461                 OPCODE/Ice/IceUtils.cpp
462                 OPCODE/Ice/IceUtils.h
463         )
464 endif()
466 list(
467         APPEND SRCS
468         ode/src/odeou.cpp
469         ode/src/odeou.h
470         ode/src/odetls.cpp
471         ode/src/odetls.h
472         ou/src/ou/atomic.cpp
473         ou/src/ou/customization.cpp
474         ou/src/ou/malloc.cpp
475         ou/src/ou/threadlocalstorage.cpp
478 add_library(ODE ${SRCS})
480 set_target_properties(
481         ODE
482         PROPERTIES
483         OUTPUT_NAME ode
484         POSITION_INDEPENDENT_CODE ON
485         VERSION ${VERSION}
488 if(WIN32)
489         if(BUILD_SHARED_LIBS)
490                 set_target_properties(ODE PROPERTIES DEBUG_POSTFIX d)
491         else()
492                 set_target_properties(
493                         ODE
494                         PROPERTIES
495                         DEBUG_POSTFIX sd
496                         MINSIZEREL_POSTFIX s
497                         RELEASE_POSTFIX s
498                         RELWITHDEBINFO_POSTFIX s
499                 )
500         endif()
501         
502         if(ODE_DOUBLE_PRECISION)
503                 set_target_properties(ODE PROPERTIES OUTPUT_NAME ode_double)
504         else()
505                 set_target_properties(ODE PROPERTIES OUTPUT_NAME ode_single)
506         endif()
507 endif()
509 target_compile_definitions(
510         ODE
511         PRIVATE
512         -D_OU_NAMESPACE=${_OU_NAMESPACE}
513         -D_OU_FEATURE_SET=${_OU_FEATURE_SET}
514         -D_OU_TARGET_OS=${_OU_TARGET_OS}
515         $<$<NOT:$<CONFIG:Debug>>:dNODEBUG>
516         -DdOU_ENABLED
519 if(APPLE)
520         target_compile_definitions(ODE PRIVATE -DMAC_OS_X_VERSION=${MAC_OS_X_VERSION})
521 endif()
523 if(WIN32)
524         target_compile_definitions(ODE PRIVATE -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES)
525 endif()
527 if(BUILD_SHARED_LIBS)
528         target_compile_definitions(ODE PRIVATE -DODE_DLL)
529 else()
530         target_compile_definitions(ODE PRIVATE -DODE_LIB)
531 endif()
533 if(ODE_DOUBLE_PRECISION)
534         target_compile_definitions(ODE PUBLIC -DdIDEDOUBLE PRIVATE -DCCD_IDEDOUBLE)
535 else()
536         target_compile_definitions(ODE PUBLIC -DdIDESINGLE PRIVATE -DCCD_IDESINGLE)
537 endif()
539 target_include_directories(
540         ODE
541         PUBLIC
542         $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
543         $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/ode/src>
544         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
545         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ode/src>
546         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ode/src/joints>
547         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ou/include>
548         $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
551 if(ODE_16BIT_INDICES)
552         target_compile_definitions(ODE PRIVATE -DdTRIMESH_16BIT_INDICES)
553 endif()
555 if(NOT ODE_NO_BUILTIN_THREADING_IMPL)
556         target_compile_definitions(ODE PRIVATE -DdBUILTIN_THREADING_IMPL_ENABLED)
557 endif()
559 if(ODE_NO_THREADING_INTF)
560         target_compile_definitions(ODE PRIVATE -DdTHREADING_INTF_DISABLED)
561 endif()
563 if(ODE_WITH_GIMPACT AND NOT ODE_NO_TRIMESH)
564         target_compile_definitions(ODE PRIVATE -DdTRIMESH_ENABLED -DdTRIMESH_GIMPACT)
565         target_include_directories(ODE PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GIMPACT/include>)
566 endif()
568 if(ODE_WITH_LIBCCD)
569         if(ODE_WITH_LIBCCD_SYSTEM)
570                 find_package(ccd)
571                 target_compile_definitions(ode PRIVATE -DdLIBCCD_ENABLED -DdLIBCCD_SYSTEM)
572                 target_link_libraries(ODE ccd::ccd)
573         else()
574                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_ENABLED -DdLIBCCD_INTERNAL)
575                 target_include_directories(
576                         ODE
577                         PRIVATE
578                         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libccd/src>
579                         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libccd/src/custom>
580                 )
581         endif()
582         
583         if(ODE_WITH_LIBCCD_BOX_CYL)
584                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_BOX_CYL)
585         endif()
586         
587         if(ODE_WITH_LIBCCD_CAP_CYL)
588                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CAP_CYL)
589         endif()
590         
591         if(ODE_WITH_LIBCCD_CYL_CYL)
592                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CYL_CYL)
593         endif()
594         
595         if(ODE_WITH_LIBCCD_CONVEX_BOX)
596                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CONVEX_BOX)
597         endif()
598         
599         if(ODE_WITH_LIBCCD_CONVEX_CAP)
600                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CONVEX_CAP)
601         endif()
602         
603         if(ODE_WITH_LIBCCD_CONVEX_CONVEX)
604                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CONVEX_CONVEX)
605         endif()
606         
607         if(ODE_WITH_LIBCCD_CONVEX_CYL)
608                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CONVEX_CYL)
609         endif()
610         
611         if(ODE_WITH_LIBCCD_CONVEX_SPHERE)
612                 target_compile_definitions(ODE PRIVATE -DdLIBCCD_CONVEX_SPHERE)
613         endif()
614 endif()
616 if(ODE_WITH_OPCODE AND NOT ODE_NO_TRIMESH)
617         target_compile_definitions(ODE PRIVATE -DdTRIMESH_ENABLED -DdTRIMESH_OPCODE)
618         
619         if(ODE_OLD_TRIMESH)
620                 target_compile_definitions(ODE PRIVATE -DdTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER)
621         endif()
622         
623         target_include_directories(
624                 ODE
625                 PRIVATE
626                 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/OPCODE>
627                 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/OPCODE/Ice>
628         )
629 endif()
631 if(ODE_WITH_OU)
632         target_compile_definitions(ODE PRIVATE -DdATOMICS_ENABLED -DdTLS_ENABLED)
633 elseif(NOT ODE_NO_THREADING_INTF)
634         target_compile_definitions(ODE PRIVATE -DdATOMICS_ENABLED)
635 endif()
637 if(ODE_WITH_OU OR NOT ODE_NO_THREADING_INTF)
638         target_link_libraries(ODE ${CMAKE_THREAD_LIBS_INIT})
639 endif()
641 install(
642         TARGETS ODE
643         EXPORT ODE
644         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
645         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP
646         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
649 if(BUILD_SHARED_LIBS)
650         install(
651                 TARGETS ODE
652                 EXPORT ODE
653                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development NAMELINK_ONLY
654         )
655 endif()
657 if(MSVC AND BUILD_SHARED_LIBS AND NOT CMAKE_VERSION VERSION_LESS 3.1)
658         install(FILES $<TARGET_PDB_FILE:ODE> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
659 endif()
661 install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ode COMPONENT development)
663 set(prefix ${CMAKE_INSTALL_PREFIX})
664 set(exec_prefix "\${prefix}")
665 set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
666 set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
667 configure_file(ode.pc.in ode.pc @ONLY)
668 configure_file(ode-config.in ode-config @ONLY)
670 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ode.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development)
671 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ode-config DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT development)
673 if(ODE_WITH_DEMOS)
674         set(
675                 DRAWSTUFF_SRCS
676                 include/drawstuff/drawstuff.h
677                 include/drawstuff/version.h
678                 drawstuff/src/drawstuff.cpp
679                 drawstuff/src/internal.h
680         )
681         
682         if(WIN32)
683                 list(
684                         APPEND DRAWSTUFF_SRCS
685                         drawstuff/src/resource.h
686                         drawstuff/src/resources.rc
687                         drawstuff/src/windows.cpp
688                 )
689         elseif(APPLE)
690                 list(APPEND DRAWSTUFF_SRCS drawstuff/src/osx.cpp)
691         else()
692                 list(APPEND DRAWSTUFF_SRCS drawstuff/src/x11.cpp)
693         endif()
694         
695         add_library(drawstuff ${DRAWSTUFF_SRCS})
696         target_compile_definitions(drawstuff PUBLIC -DDRAWSTUFF_TEXTURE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/drawstuff/textures")
697         
698         if(BUILD_SHARED_LIBS)
699                 target_compile_definitions(drawstuff PRIVATE -DDS_DLL -DUSRDLL)
700         else()
701                 target_compile_definitions(drawstuff PRIVATE -DDS_LIB)
702         endif()
703         
704         target_include_directories(drawstuff PUBLIC ${OPENGL_INCLUDE_DIR})
705         target_link_libraries(drawstuff ODE ${OPENGL_LIBRARIES})
706         
707         if(WIN32)
708                 target_link_libraries(drawstuff winmm)
709         elseif(APPLE)
710                 find_package(GLUT)
711                 target_include_directories(drawstuff PUBLIC ${GLUT_INCLUDE_DIR})
712                 target_link_libraries(drawstuff ${GLUT_LIBRARIES})
713         else()
714                 find_package(X11)
715                 target_include_directories(drawstuff PUBLIC ${X11_INCLUDE_DIR})
716                 target_link_libraries(drawstuff ${X11_LIBRARIES})
717         endif()
718         
719         set(
720                 DEMO_SRCS
721                 ode/demo/demo_boxstack.cpp
722                 ode/demo/demo_buggy.cpp
723                 ode/demo/demo_cards.cpp
724                 ode/demo/demo_chain1.c
725                 ode/demo/demo_chain2.cpp
726                 ode/demo/demo_collision.cpp
727                 ode/demo/demo_convex.cpp
728                 ode/demo/demo_crash.cpp
729                 ode/demo/demo_cylvssphere.cpp
730                 ode/demo/demo_dball.cpp
731                 ode/demo/demo_dhinge.cpp
732                 ode/demo/demo_feedback.cpp
733                 ode/demo/demo_friction.cpp
734                 ode/demo/demo_gyro2.cpp
735                 ode/demo/demo_gyroscopic.cpp
736                 ode/demo/demo_heightfield.cpp
737                 ode/demo/demo_hinge.cpp
738                 ode/demo/demo_I.cpp
739                 ode/demo/demo_jointPR.cpp
740                 ode/demo/demo_jointPU.cpp
741                 ode/demo/demo_joints.cpp
742                 ode/demo/demo_kinematic.cpp
743                 ode/demo/demo_motion.cpp
744                 ode/demo/demo_motor.cpp
745                 ode/demo/demo_ode.cpp
746                 ode/demo/demo_piston.cpp
747                 ode/demo/demo_plane2d.cpp
748                 ode/demo/demo_rfriction.cpp
749                 ode/demo/demo_slider.cpp
750                 ode/demo/demo_space.cpp
751                 ode/demo/demo_space_stress.cpp
752                 ode/demo/demo_step.cpp
753                 ode/demo/demo_transmission.cpp
754         )
755         
756         if(NOT ODE_NO_TRIMESH)
757                 list(
758                         APPEND DEMO_SRCS
759                         ode/demo/demo_basket.cpp
760                         ode/demo/demo_cyl.cpp
761                         ode/demo/demo_moving_convex.cpp
762                         ode/demo/demo_moving_trimesh.cpp
763                         ode/demo/demo_tracks.cpp
764                         ode/demo/demo_trimesh.cpp
765                 )
766         endif()
767         
768         foreach(DEMO_SRC ${DEMO_SRCS})
769                 get_filename_component(DEMO ${DEMO_SRC} NAME_WE)
771                 if(NOT WIN32 OR ${DEMO} STREQUAL "demo_ode")
772                         add_executable(${DEMO} ${DEMO_SRC})
773                 else()
774                         add_executable(${DEMO} WIN32 ${DEMO_SRC})
775                 endif()
776                 target_link_libraries(${DEMO} drawstuff)
777                 
778                 if(NOT WIN32 AND ${DEMO} STREQUAL "demo_chain1")
779                         target_link_libraries(${DEMO} m)
780                 endif()
781         endforeach()
782 endif()
784 if(ODE_WITH_TESTS)
785         set(
786                 TEST_SRCS
787                 tests/collision.cpp
788                 tests/friction.cpp
789                 tests/joint.cpp
790                 tests/main.cpp
791                 tests/odemath.cpp
792                 tests/joints/amotor.cpp
793                 tests/joints/ball.cpp
794                 tests/joints/dball.cpp
795                 tests/joints/fixed.cpp
796                 tests/joints/hinge.cpp
797                 tests/joints/hinge2.cpp
798                 tests/joints/piston.cpp
799                 tests/joints/pr.cpp
800                 tests/joints/pu.cpp
801                 tests/joints/slider.cpp
802                 tests/joints/universal.cpp
803                 tests/UnitTest++/src/AssertException.cpp
804                 tests/UnitTest++/src/AssertException.h
805                 tests/UnitTest++/src/CheckMacros.h
806                 tests/UnitTest++/src/Checks.cpp
807                 tests/UnitTest++/src/Checks.h
808                 tests/UnitTest++/src/Config.h
809                 tests/UnitTest++/src/DeferredTestReporter.cpp
810                 tests/UnitTest++/src/DeferredTestReporter.h
811                 tests/UnitTest++/src/DeferredTestResult.cpp
812                 tests/UnitTest++/src/DeferredTestResult.h
813                 tests/UnitTest++/src/MemoryOutStream.cpp
814                 tests/UnitTest++/src/MemoryOutStream.h
815                 tests/UnitTest++/src/ReportAssert.cpp
816                 tests/UnitTest++/src/ReportAssert.h
817                 tests/UnitTest++/src/Test.cpp
818                 tests/UnitTest++/src/TestDetails.cpp
819                 tests/UnitTest++/src/TestDetails.h
820                 tests/UnitTest++/src/Test.h
821                 tests/UnitTest++/src/TestList.cpp
822                 tests/UnitTest++/src/TestList.h
823                 tests/UnitTest++/src/TestMacros.h
824                 tests/UnitTest++/src/TestReporter.cpp
825                 tests/UnitTest++/src/TestReporter.h
826                 tests/UnitTest++/src/TestReporterStdout.cpp
827                 tests/UnitTest++/src/TestReporterStdout.h
828                 tests/UnitTest++/src/TestResults.cpp
829                 tests/UnitTest++/src/TestResults.h
830                 tests/UnitTest++/src/TestRunner.cpp
831                 tests/UnitTest++/src/TestRunner.h
832                 tests/UnitTest++/src/TestSuite.h
833                 tests/UnitTest++/src/TimeConstraint.cpp
834                 tests/UnitTest++/src/TimeConstraint.h
835                 tests/UnitTest++/src/TimeHelpers.h
836                 tests/UnitTest++/src/UnitTest++.h
837                 tests/UnitTest++/src/XmlTestReporter.cpp
838                 tests/UnitTest++/src/XmlTestReporter.h
839         )
840         
841         if(WIN32)
842                 list(
843                         APPEND TEST_SRCS
844                         tests/UnitTest++/src/Win32/TimeHelpers.cpp
845                         tests/UnitTest++/src/Win32/TimeHelpers.h
846                 )
847         else()
848                 list(
849                         APPEND TEST_SRCS
850                         tests/UnitTest++/src/Posix/SignalTranslator.cpp
851                         tests/UnitTest++/src/Posix/SignalTranslator.h
852                         tests/UnitTest++/src/Posix/TimeHelpers.cpp
853                         tests/UnitTest++/src/Posix/TimeHelpers.h
854                 )
855         endif()
856         
857         add_executable(tests ${TEST_SRCS})
858         target_include_directories(tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/UnitTest++/src)
859         target_link_libraries(tests ODE)
860         
861         enable_testing()
862         add_test(tests ${CMAKE_CURRENT_BINARY_DIR}/tests)
863 endif()
865 include(CMakePackageConfigHelpers)
867 configure_package_config_file(
868   ${CMAKE_CURRENT_SOURCE_DIR}/ode-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/ode-config.cmake
869   INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ode
871 install(
872         FILES ${CMAKE_CURRENT_BINARY_DIR}/ode-config.cmake
873         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ode-${VERSION}
874         COMPONENT development
876 write_basic_package_version_file(
877         ${CMAKE_CURRENT_BINARY_DIR}/ode-config-version.cmake
878         VERSION ${VERSION}
879         COMPATIBILITY ExactVersion
881 install(
882         FILES ${CMAKE_CURRENT_BINARY_DIR}/ode-config-version.cmake
883         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ode-${VERSION}
884         COMPONENT development
886 install(
887         EXPORT ODE
888         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ode-${VERSION}
889         NAMESPACE ODE::
890         FILE ode-export.cmake
891         COMPONENT development
894 configure_file(cmake/cmake_uninstall.cmake.in cmake_uninstall.cmake @ONLY)
895 add_custom_target(uninstall ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
897 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ODE is a free, industrial quality library for simulating articulated rigid body dynamics - for example ground vehicles, legged creatures, and moving objects in VR environments. It is fast, flexible, robust and platform independent, with advanced joints, contact with friction, and built-in collision detection.")
899 set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime)
900 set(CPACK_COMPONENT_DEVELOPMENT_DESCRIPTION "Open Dynamics Engine - development files\n${CPACK_DEBIAN_PACKAGE_DESCRIPTION}")
901 set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "Open Dynamics Engine - runtime library\n${CPACK_DEBIAN_PACKAGE_DESCRIPTION}")
902 set(CPACK_DEB_COMPONENT_INSTALL ON)
903 set(CPACK_DEBIAN_DEVELOPMENT_FILE_NAME "DEB-DEFAULT")
904 set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_SECTION "libdevel")
905 set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.ode.org/")
906 set(CPACK_DEBIAN_PACKAGE_NAME "libode")
907 set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
908 set(CPACK_DEBIAN_RUNTIME_FILE_NAME "DEB-DEFAULT")
909 set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs")
910 set(CPACK_DEBIAN_RUNTIME_PACKAGE_SHLIBDEPS ON)
911 set(CPACK_NSIS_PACKAGE_NAME "ODE ${VERSION}")
912 set(CPACK_NSIS_URL_INFO_ABOUT "http://www.ode.org/")
913 set(CPACK_PACKAGE_CONTACT "ode@ode.org")
914 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "High performance library for simulating rigid body dynamics")
915 set(CPACK_PACKAGE_DISPLAY_NAME "ODE ${VERSION}")
916 set(CPACK_PACKAGE_INSTALL_DIRECTORY "ode-${VERSION}")
917 set(CPACK_PACKAGE_NAME "ode")
918 set(CPACK_PACKAGE_VENDOR "")
919 set(CPACK_PACKAGE_VERSION ${VERSION})
920 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
921 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
922 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
923 set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
924 set(CPACK_RPM_COMPONENT_INSTALL ON)
925 set(CPACK_RPM_DEVELOPMENT_FILE_NAME "RPM-DEFAULT")
926 set(CPACK_RPM_development_PACKAGE_DESCRIPTION "The ode-devel package contains libraries and header files for developing applications that use ode or ode-double.")
927 set(CPACK_RPM_development_PACKAGE_NAME "ode-devel")
928 set(CPACK_RPM_development_PACKAGE_SUMMARY "Development files for ODE")
929 set(CPACK_RPM_PACKAGE_DESCRIPTION "ODE is an open source, high performance library for simulating rigid body dynamics. It is fully featured, stable, mature and platform independent with an easy to use C/C++ API. It has advanced joint types and integrated collision detection with friction. ODE is useful for simulating vehicles, objects in virtual reality environments and virtual creatures. It is currently used in many computer games, 3D authoring tools and simulation tools.")
930 set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
931 set(CPACK_RPM_PACKAGE_LICENSE "BSD or LGPLv2+")
932 set(CPACK_RPM_PACKAGE_NAME "ode")
933 set(CPACK_RPM_PACKAGE_SUMMARY "High performance library for simulating rigid body dynamics")
934 set(CPACK_RPM_PACKAGE_URL "http://www.ode.org/")
935 set(CPACK_RPM_RUNTIME_FILE_NAME "RPM-DEFAULT")
937 if(ODE_DOUBLE_PRECISION)
938         set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_CONFLICTS "libode-sp-dev")
939         set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "libode6")
940         set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "libode-dev")
941         set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONFLICTS "libode6sp")
942         set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "libode6")
943         set(CPACK_RPM_development_PACKAGE_REQUIRES "ode-double")
944         set(CPACK_RPM_runtime_PACKAGE_CONFLICTS "ode")
945         set(CPACK_RPM_runtime_PACKAGE_DESCRIPTION "The ode-double package contains a version of the ODE library for simulating rigid body dynamics compiled with double precision.")
946         set(CPACK_RPM_runtime_PACKAGE_NAME "ode-double")
947         set(CPACK_RPM_runtime_PACKAGE_SUMMARY "ODE physics library compiled with double precision")
948 else()
949         set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_CONFLICTS "libode-dev")
950         set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "libode6sp")
951         set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "libode-sp-dev")
952         set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONFLICTS "libode6")
953         set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "libode6sp")
954         set(CPACK_RPM_development_PACKAGE_REQUIRES "ode")
955         set(CPACK_RPM_runtime_PACKAGE_CONFLICTS "ode-double")
956         set(CPACK_RPM_runtime_PACKAGE_NAME "ode")
957 endif()
959 include(CPack)