mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
CMake: Redo ODE find module
This defines an ODE::ODE target; it also automatically selects the correct `dIDESINGLE`/`dIDEDOUBLE` compile-time definition.
This commit is contained in:
parent
dd5c411e88
commit
8dd46eb736
@ -7,74 +7,144 @@
|
||||
# Once done this will define:
|
||||
# ODE_FOUND - system has ode
|
||||
# ODE_INCLUDE_DIR - the ode include directory
|
||||
# ODE_LIBRARY_DIR - the ode library directory
|
||||
# ODE_LIBRARY - the path to the library binary
|
||||
#
|
||||
# ODE_RELEASE_LIBRARY - the filepath of the ode release library
|
||||
# ODE_DEBUG_LIBRARY - the filepath of the ode debug library
|
||||
#
|
||||
# ODE_SINGLE_DEBUG_LIBRARY - the filepath of the single-precision ode debug library
|
||||
# ODE_SINGLE_RELEASE_LIBRARY - the filepath of the single-precision ode release library
|
||||
# ODE_DOUBLE_DEBUG_LIBRARY - the filepath of the double-precision ode debug library
|
||||
# ODE_DOUBLE_RELEASE_LIBRARY - the filepath of the double-precision ode release library
|
||||
#
|
||||
# ODE::ODE - The recommended ODE library to link against
|
||||
# ODE::ODE_single - If available, this links against single-precision ODE
|
||||
# ODE::ODE_double - If available, this links against double-precision ODE
|
||||
#
|
||||
|
||||
if(NOT ODE_INCLUDE_DIR OR NOT ODE_LIBRARY_DIR)
|
||||
# Find the libode include files
|
||||
find_path(ODE_INCLUDE_DIR
|
||||
NAMES "ode.h"
|
||||
PATHS "/usr/include"
|
||||
"/usr/local/include"
|
||||
"/sw/include"
|
||||
"/opt/include"
|
||||
"/opt/local/include"
|
||||
"/opt/csw/include"
|
||||
PATH_SUFFIXES "" "ode"
|
||||
)
|
||||
PATH_SUFFIXES "ode")
|
||||
|
||||
# Find the libode library built for release
|
||||
find_library(ODE_RELEASE_LIBRARY
|
||||
NAMES "ode" "libode"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
NAMES "ode" "libode")
|
||||
|
||||
# Find the libode library built for debug
|
||||
find_library(ODE_DEBUG_LIBRARY
|
||||
NAMES "oded" "liboded"
|
||||
PATHS "/usr"
|
||||
"/usr/local"
|
||||
"/usr/freeware"
|
||||
"/sw"
|
||||
"/opt"
|
||||
"/opt/csw"
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64"
|
||||
)
|
||||
NAMES "oded" "liboded")
|
||||
|
||||
# Find the single-precision library built for release
|
||||
find_library(ODE_SINGLE_RELEASE_LIBRARY
|
||||
NAMES "ode_single" "libode_single")
|
||||
|
||||
# Find the single-precision library built for debug
|
||||
find_library(ODE_SINGLE_DEBUG_LIBRARY
|
||||
NAMES "ode_singled" "libode_singled")
|
||||
|
||||
# Find the double-precision library built for release
|
||||
find_library(ODE_DOUBLE_RELEASE_LIBRARY
|
||||
NAMES "ode_double" "libode_double" )
|
||||
|
||||
# Find the double-precision library built for debug
|
||||
find_library(ODE_DOUBLE_DEBUG_LIBRARY
|
||||
NAMES "ode_doubled" "libode_doubled")
|
||||
|
||||
unset(_ODE_LIB_PATHS)
|
||||
|
||||
mark_as_advanced(ODE_INCLUDE_DIR)
|
||||
mark_as_advanced(ODE_RELEASE_LIBRARY)
|
||||
mark_as_advanced(ODE_DEBUG_LIBRARY)
|
||||
mark_as_advanced(ODE_SINGLE_RELEASE_LIBRARY)
|
||||
mark_as_advanced(ODE_SINGLE_DEBUG_LIBRARY)
|
||||
mark_as_advanced(ODE_DOUBLE_RELEASE_LIBRARY)
|
||||
mark_as_advanced(ODE_DOUBLE_DEBUG_LIBRARY)
|
||||
endif()
|
||||
|
||||
# Choose library
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug" AND ODE_DEBUG_LIBRARY)
|
||||
set(ODE_LIBRARY ${ODE_DEBUG_LIBRARY} CACHE FILEPATH "The filepath to libode's library binary.")
|
||||
elseif(ODE_RELEASE_LIBRARY)
|
||||
set(ODE_LIBRARY ${ODE_RELEASE_LIBRARY} CACHE FILEPATH "The filepath to libode's library binary.")
|
||||
elseif(ODE_DEBUG_LIBRARY)
|
||||
set(ODE_LIBRARY ${ODE_DEBUG_LIBRARY} CACHE FILEPATH "The filepath to libode's library binary.")
|
||||
# Define targets for both precisions (and unspecified)
|
||||
foreach(_precision _single _double "")
|
||||
string(TOUPPER "${_precision}" _PRECISION)
|
||||
|
||||
if(EXISTS "${ODE${_PRECISION}_RELEASE_LIBRARY}" OR
|
||||
EXISTS "${ODE${_PRECISION}_DEBUG_LIBRARY}")
|
||||
if(NOT TARGET ODE::ODE${_precision})
|
||||
add_library(ODE::ODE${_precision} UNKNOWN IMPORTED GLOBAL)
|
||||
|
||||
set_target_properties(ODE::ODE${_precision} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ODE_INCLUDE_DIR}")
|
||||
|
||||
if(EXISTS "${ODE${_PRECISION}_RELEASE_LIBRARY}")
|
||||
set_property(TARGET ODE::ODE${_precision} APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(ODE::ODE${_precision} PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${ODE${_PRECISION}_RELEASE_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${ODE${_PRECISION}_DEBUG_LIBRARY}")
|
||||
set_property(TARGET ODE::ODE${_precision} APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(ODE::ODE${_precision} PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||
IMPORTED_LOCATION_DEBUG "${ODE${_PRECISION}_DEBUG_LIBRARY}")
|
||||
endif()
|
||||
|
||||
# If this has a precision, we should be sure to define
|
||||
# dIDESINGLE/dIDEDOUBLE to keep it consistent
|
||||
if(_precision)
|
||||
string(REPLACE "_" "dIDE" _precision_symbol "${_PRECISION}")
|
||||
|
||||
set_target_properties(ODE::ODE${_precision} PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "${_precision_symbol}")
|
||||
|
||||
unset(_precision_symbol)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endforeach(_precision)
|
||||
unset(_precision)
|
||||
unset(_PRECISION)
|
||||
|
||||
# OKAY. If everything went well, we have ODE::ODE_single and/or
|
||||
# ODE::ODE_double. We might even have an ODE::ODE, but if not, we need to
|
||||
# alias one of the other two to it.
|
||||
if(NOT TARGET ODE::ODE)
|
||||
if(TARGET ODE::ODE_single)
|
||||
set(_copy_from "ODE::ODE_single")
|
||||
elseif(TARGET ODE::ODE_double)
|
||||
set(_copy_from "ODE::ODE_double")
|
||||
endif()
|
||||
|
||||
if(DEFINED _copy_from)
|
||||
add_library(ODE::ODE UNKNOWN IMPORTED GLOBAL)
|
||||
|
||||
foreach(_prop
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
INTERFACE_COMPILE_DEFINITIONS
|
||||
IMPORTED_CONFIGURATIONS
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE
|
||||
IMPORTED_LOCATION_RELEASE
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG
|
||||
IMPORTED_LOCATION_DEBUG)
|
||||
|
||||
get_target_property(_value "${_copy_from}" "${_prop}")
|
||||
if(DEFINED _value)
|
||||
set_target_properties(ODE::ODE PROPERTIES "${_prop}" "${_value}")
|
||||
endif()
|
||||
unset(_value)
|
||||
endforeach(_prop)
|
||||
endif()
|
||||
|
||||
unset(_copy_from)
|
||||
endif()
|
||||
|
||||
# Translate library into library directory
|
||||
if(ODE_LIBRARY)
|
||||
unset(ODE_LIBRARY_DIR CACHE)
|
||||
get_filename_component(ODE_LIBRARY_DIR "${ODE_LIBRARY}" PATH)
|
||||
set(ODE_LIBRARY_DIR "${ODE_LIBRARY_DIR}" CACHE PATH "The path to libode's library directory.") # Library path
|
||||
if(TARGET ODE::ODE)
|
||||
set(_HAS_ODE_LIBRARY ON)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(ODE_LIBRARY)
|
||||
mark_as_advanced(ODE_LIBRARY_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ODE DEFAULT_MSG ODE_LIBRARY ODE_INCLUDE_DIR ODE_LIBRARY_DIR)
|
||||
find_package_handle_standard_args(ODE DEFAULT_MSG ODE_INCLUDE_DIR _HAS_ODE_LIBRARY)
|
||||
|
||||
unset(_HAS_ODE_LIBRARY)
|
||||
|
@ -336,7 +336,8 @@ find_package(ODE QUIET)
|
||||
|
||||
package_option(ODE
|
||||
"Enable this option to support game dynamics with the Open Dynamics Engine (ODE)."
|
||||
LICENSE "BSD-3")
|
||||
LICENSE "BSD-3"
|
||||
IMPORTED_AS ODE::ODE)
|
||||
|
||||
config_package(ODE "Open Dynamics Engine")
|
||||
|
||||
|
@ -3,80 +3,80 @@ if(NOT HAVE_ODE)
|
||||
endif()
|
||||
|
||||
set(P3ODE_HEADERS
|
||||
ode_includes.h config_ode.h
|
||||
odeWorld.I odeWorld.h
|
||||
odeMass.I odeMass.h
|
||||
odeBody.I odeBody.h
|
||||
odeJointGroup.I odeJointGroup.h
|
||||
odeJoint.I odeJoint.h
|
||||
odeUtil.h
|
||||
odeSpace.I odeSpace.h
|
||||
odeGeom.I odeGeom.h
|
||||
odeSurfaceParameters.I odeSurfaceParameters.h
|
||||
odeContactGeom.I odeContactGeom.h
|
||||
odeContact.I odeContact.h
|
||||
odeAMotorJoint.I odeAMotorJoint.h
|
||||
odeBallJoint.I odeBallJoint.h
|
||||
odeContactJoint.I odeContactJoint.h
|
||||
odeFixedJoint.I odeFixedJoint.h
|
||||
odeHingeJoint.I odeHingeJoint.h
|
||||
odeHinge2Joint.I odeHinge2Joint.h
|
||||
odeLMotorJoint.I odeLMotorJoint.h
|
||||
odeNullJoint.I odeNullJoint.h
|
||||
odePlane2dJoint.I odePlane2dJoint.h
|
||||
odeSliderJoint.I odeSliderJoint.h
|
||||
odeUniversalJoint.I odeUniversalJoint.h
|
||||
odeJointCollection.I odeJointCollection.h
|
||||
odeSimpleSpace.I odeSimpleSpace.h
|
||||
odeHashSpace.I odeHashSpace.h
|
||||
odeQuadTreeSpace.I odeQuadTreeSpace.h
|
||||
odeSphereGeom.I odeSphereGeom.h
|
||||
odeBoxGeom.I odeBoxGeom.h
|
||||
odePlaneGeom.I odePlaneGeom.h
|
||||
odeCappedCylinderGeom.I odeCappedCylinderGeom.h
|
||||
odeCylinderGeom.I odeCylinderGeom.h
|
||||
odeRayGeom.I odeRayGeom.h
|
||||
odeTriMeshData.I odeTriMeshData.h
|
||||
odeTriMeshGeom.I odeTriMeshGeom.h
|
||||
odeCollisionEntry.I odeCollisionEntry.h
|
||||
odeHelperStructs.h)
|
||||
ode_includes.h config_ode.h
|
||||
odeWorld.I odeWorld.h
|
||||
odeMass.I odeMass.h
|
||||
odeBody.I odeBody.h
|
||||
odeJointGroup.I odeJointGroup.h
|
||||
odeJoint.I odeJoint.h
|
||||
odeUtil.h
|
||||
odeSpace.I odeSpace.h
|
||||
odeGeom.I odeGeom.h
|
||||
odeSurfaceParameters.I odeSurfaceParameters.h
|
||||
odeContactGeom.I odeContactGeom.h
|
||||
odeContact.I odeContact.h
|
||||
odeAMotorJoint.I odeAMotorJoint.h
|
||||
odeBallJoint.I odeBallJoint.h
|
||||
odeContactJoint.I odeContactJoint.h
|
||||
odeFixedJoint.I odeFixedJoint.h
|
||||
odeHingeJoint.I odeHingeJoint.h
|
||||
odeHinge2Joint.I odeHinge2Joint.h
|
||||
odeLMotorJoint.I odeLMotorJoint.h
|
||||
odeNullJoint.I odeNullJoint.h
|
||||
odePlane2dJoint.I odePlane2dJoint.h
|
||||
odeSliderJoint.I odeSliderJoint.h
|
||||
odeUniversalJoint.I odeUniversalJoint.h
|
||||
odeJointCollection.I odeJointCollection.h
|
||||
odeSimpleSpace.I odeSimpleSpace.h
|
||||
odeHashSpace.I odeHashSpace.h
|
||||
odeQuadTreeSpace.I odeQuadTreeSpace.h
|
||||
odeSphereGeom.I odeSphereGeom.h
|
||||
odeBoxGeom.I odeBoxGeom.h
|
||||
odePlaneGeom.I odePlaneGeom.h
|
||||
odeCappedCylinderGeom.I odeCappedCylinderGeom.h
|
||||
odeCylinderGeom.I odeCylinderGeom.h
|
||||
odeRayGeom.I odeRayGeom.h
|
||||
odeTriMeshData.I odeTriMeshData.h
|
||||
odeTriMeshGeom.I odeTriMeshGeom.h
|
||||
odeCollisionEntry.I odeCollisionEntry.h
|
||||
odeHelperStructs.h)
|
||||
|
||||
set(P3ODE_SOURCES
|
||||
config_ode.cxx
|
||||
odeWorld.cxx odeMass.cxx odeBody.cxx
|
||||
odeJointGroup.cxx odeJoint.cxx
|
||||
odeUtil.cxx
|
||||
odeSpace.cxx
|
||||
odeGeom.cxx
|
||||
odeSurfaceParameters.cxx
|
||||
odeContactGeom.cxx odeContact.cxx
|
||||
odeAMotorJoint.cxx odeBallJoint.cxx
|
||||
odeContactJoint.cxx odeFixedJoint.cxx
|
||||
odeHingeJoint.cxx odeHinge2Joint.cxx
|
||||
odeLMotorJoint.cxx odeNullJoint.cxx
|
||||
odePlane2dJoint.cxx odeSliderJoint.cxx
|
||||
odeUniversalJoint.cxx odeJointCollection.cxx
|
||||
odeSimpleSpace.cxx
|
||||
odeHashSpace.cxx odeQuadTreeSpace.cxx
|
||||
odeSphereGeom.cxx odeBoxGeom.cxx
|
||||
odePlaneGeom.cxx odeCappedCylinderGeom.cxx
|
||||
odeCylinderGeom.cxx odeRayGeom.cxx
|
||||
odeTriMeshData.cxx odeTriMeshGeom.cxx
|
||||
odeCollisionEntry.cxx)
|
||||
config_ode.cxx
|
||||
odeWorld.cxx odeMass.cxx odeBody.cxx
|
||||
odeJointGroup.cxx odeJoint.cxx
|
||||
odeUtil.cxx
|
||||
odeSpace.cxx
|
||||
odeGeom.cxx
|
||||
odeSurfaceParameters.cxx
|
||||
odeContactGeom.cxx odeContact.cxx
|
||||
odeAMotorJoint.cxx odeBallJoint.cxx
|
||||
odeContactJoint.cxx odeFixedJoint.cxx
|
||||
odeHingeJoint.cxx odeHinge2Joint.cxx
|
||||
odeLMotorJoint.cxx odeNullJoint.cxx
|
||||
odePlane2dJoint.cxx odeSliderJoint.cxx
|
||||
odeUniversalJoint.cxx odeJointCollection.cxx
|
||||
odeSimpleSpace.cxx
|
||||
odeHashSpace.cxx odeQuadTreeSpace.cxx
|
||||
odeSphereGeom.cxx odeBoxGeom.cxx
|
||||
odePlaneGeom.cxx odeCappedCylinderGeom.cxx
|
||||
odeCylinderGeom.cxx odeRayGeom.cxx
|
||||
odeTriMeshData.cxx odeTriMeshGeom.cxx
|
||||
odeCollisionEntry.cxx)
|
||||
|
||||
set(P3ODE_IGATEEXT
|
||||
odeBody_ext.h
|
||||
odeBody_ext.I
|
||||
odeGeom_ext.cxx
|
||||
odeGeom_ext.h
|
||||
odeGeom_ext.I
|
||||
odeJoint_ext.cxx
|
||||
odeJoint_ext.h
|
||||
odeSpace_ext.cxx
|
||||
odeSpace_ext.h
|
||||
odeSpace_ext.I
|
||||
odeUtil_ext.cxx
|
||||
odeUtil_ext.h)
|
||||
odeBody_ext.h
|
||||
odeBody_ext.I
|
||||
odeGeom_ext.cxx
|
||||
odeGeom_ext.h
|
||||
odeGeom_ext.I
|
||||
odeJoint_ext.cxx
|
||||
odeJoint_ext.h
|
||||
odeSpace_ext.cxx
|
||||
odeSpace_ext.h
|
||||
odeSpace_ext.I
|
||||
odeUtil_ext.cxx
|
||||
odeUtil_ext.h)
|
||||
|
||||
set(P3ODE_IGATE_SOURCES "${P3ODE_HEADERS};${P3ODE_SOURCES}")
|
||||
list(REMOVE_ITEM P3ODE_IGATE_SOURCES "odeConvexGeom.h")
|
||||
@ -86,7 +86,6 @@ list(REMOVE_ITEM P3ODE_IGATE_SOURCES "odeHelperStructs.h")
|
||||
composite_sources(p3ode P3ODE_SOURCES)
|
||||
add_library(p3ode ${P3ODE_SOURCES} ${P3ODE_HEADERS})
|
||||
set_target_properties(p3ode PROPERTIES DEFINE_SYMBOL BUILDING_PANDAODE)
|
||||
target_compile_definitions(p3ode PUBLIC dSINGLE)
|
||||
target_link_libraries(p3ode p3igateruntime panda PKG::ODE)
|
||||
target_interrogate(p3ode ${P3ODE_IGATE_SOURCES} EXTENSIONS ${P3ODE_IGATEEXT})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user