From f97222135747cbfc2e553842964668b50bc94b7d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 8 Feb 2014 16:20:57 -0700 Subject: [PATCH] CMake: Detect ODE. --- cmake/modules/FindODE.cmake | 80 +++++++++++++++++++++++++++++++++++++ dtool/Config.cmake | 5 +++ 2 files changed, 85 insertions(+) create mode 100644 cmake/modules/FindODE.cmake diff --git a/cmake/modules/FindODE.cmake b/cmake/modules/FindODE.cmake new file mode 100644 index 0000000000..6c70f69de7 --- /dev/null +++ b/cmake/modules/FindODE.cmake @@ -0,0 +1,80 @@ +# Filename: FindODE.cmake +# Author: CFSworks (7 Feb, 2014) +# +# Usage: +# find_package(ODE [REQUIRED] [QUIET]) +# +# 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 +# + +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" + ) + + # 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" + ) + + # 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" + ) + + + mark_as_advanced(ODE_INCLUDE_DIR) + mark_as_advanced(ODE_RELEASE_LIBRARY) + mark_as_advanced(ODE_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.") +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 +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) diff --git a/dtool/Config.cmake b/dtool/Config.cmake index a5595f22fc..5851928cfc 100644 --- a/dtool/Config.cmake +++ b/dtool/Config.cmake @@ -589,6 +589,11 @@ find_package(ZLIB) package_option(ZLIB DEFAULT ON "Enables support for compression of Panda assets.") +# Is ODE installed, and where? +find_package(ODE) + +package_option(ODE DEFAULT ON + "Enables support for ridid-body physics using the Open Dynamics Engine.") # Is OpenGL installed, and where? find_package(OpenGL QUIET)