[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/games/cmake/modules
From:       Rivo Laks <rivolaks () hot ! ee>
Date:       2009-06-24 21:05:09
Message-ID: 1245877509.664265.13405.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 986665 by rivol:

Update to the FindODE.cmake from astrododge which adds ODE_DEFINITIONS variable and \
slightly improved detection.

 M  +68 -27    FindODE.cmake  


--- trunk/playground/games/cmake/modules/FindODE.cmake #986664:986665
@@ -4,36 +4,77 @@
 #  ODE_FOUND - system has the ODE library
 #  ODE_INCLUDE_DIRS - the ODE include directory (include ODE headers with \
<ode/headername.h>)  #  ODE_LIBRARIES - the ODE library
+#  ODE_DEFINITIONS - additional definitions necessary to use ODE (usually the \
precision flag)  
-if(ODE_LIBRARIES)
-	SET(ODE_FIND_QUIETLY TRUE)
-endif(ODE_LIBRARIES)
+if (ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
+    # ODE has already been found and the necessary variables are cached
+    set(ODE_FOUND TRUE)
+else (ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
+    # Find ODE
 
-FIND_PATH(ODE_INCLUDE_DIRS
-	NAMES ode/ode.h
-	PATHS $ENV{OGRE_HOME}/include # ODE is shipped with the OGRE SDK
-)
-FIND_LIBRARY(ODE_LIBRARIES
-	NAMES ode
-	PATHS $ENV{OGRE_HOME}/lib
-)
+    # Use PkgConfig if possible
+    if (NOT WIN32)
+        find_package(PkgConfig)
+        pkg_check_modules(PC_ODE ode)
+    endif (NOT WIN32)
 
-if(ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
-	SET(ODE_FOUND TRUE)
-else(ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
-	SET(ODE_FOUND FALSE)
-endif(ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
+    # Find include dir
+    find_path(ODE_INCLUDE_DIRS ode/ode.h
+        HINTS ${PC_ODE_INCLUDEDIR}
+        PATHS $ENV{OGRE_HOME}/include # ODE is shipped with the OGRE SDK
+    )
+    find_library(ODE_LIBRARIES ode
+        NAMES ode ${PC_ODE_LIBRARIES}
+        HINTS ${PC_ODE_LIBDIR}
+        PATHS $ENV{OGRE_HOME}/lib
+    )
 
-# TODO: version check (necessary?)
+    # Decide if ODE was found
+    set(ODE_FOUND FALSE)
+    if (ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
+        set(ODE_FOUND TRUE)
+    endif (ODE_INCLUDE_DIRS AND ODE_LIBRARIES)
 
-if(ODE_FOUND)
-   if(NOT ODE_FIND_QUIETLY)
-      message(STATUS "Found ODE: ${ODE_LIBRARIES}")
-   endif(NOT ODE_FIND_QUIETLY)
-else(ODE_FOUND)
-   if(ODE_FIND_REQUIRED)
-      message(FATAL_ERROR "Could NOT find ODE")
-   endif(ODE_FIND_REQUIRED)
-endif(ODE_FOUND)
+    # Find out extra definitions needed for ODE.
+    # This is mostly needed for the ODE's precision selector:
+    #  ODE can be built either in single-precision (default) or double-precision \
mode. The app has +    #  to be built in the same mode, otherwise things will crash.
+    if (ODE_FOUND)
+        # If PkgConfig found anything, then use its results, otherwise use \
ode-config script +        if (PC_ODE_FOUND)
+            # Take the definitions from PkgConfig results
+            set(ODE_DEFINITIONS ${PC_ODE_CFLAGS_OTHER}   CACHE STRING "")
+            set(ODE_DEFINITIONS_FOUND TRUE)
+        else (PC_ODE_FOUND)
+            # Try to use ode-config
+            find_program(ODECONFIG_EXECUTABLE ode-config)
+            if (ODECONFIG_EXECUTABLE)
+                execute_process(COMMAND ${ODECONFIG_EXECUTABLE} --cflags   \
OUTPUT_VARIABLE ODECONFIG_CFLAGS) +                set(ODE_DEFINITIONS \
${ODECONFIG_CFLAGS}   CACHE STRING "") +                set(ODE_DEFINITIONS_FOUND \
TRUE) +            endif (ODECONFIG_EXECUTABLE)
+        endif (PC_ODE_FOUND)
+    endif (ODE_FOUND)
 
-mark_as_advanced(ODE_INCLUDE_DIRS ODE_LIBRARIES)
+    # Show messages
+    if (ODE_FOUND)
+        if (NOT ODE_FIND_QUIETLY)
+            message(STATUS "Found ODE: ${ODE_LIBRARIES}")
+            # Show the ODE precision if the definitions were detected
+            if (ODE_DEFINITIONS_FOUND)
+                if (ODE_DEFINITIONS MATCHES -DdDOUBLE)
+                    message(STATUS "ODE uses double precision")
+                else (ODE_DEFINITIONS MATCHES -DdDOUBLE)
+                    message(STATUS "ODE uses single precision")
+                endif (ODE_DEFINITIONS MATCHES -DdDOUBLE)
+            else (ODE_DEFINITIONS_FOUND)
+                message(STATUS "Warning: couldn't determine ODE's precision")
+            endif (ODE_DEFINITIONS_FOUND)
+        endif (NOT ODE_FIND_QUIETLY)
+    else (ODE_FOUND)
+        if (ODE_FIND_REQUIRED)
+            message(FATAL_ERROR "Could NOT find ODE")
+        endif (ODE_FIND_REQUIRED)
+    endif (ODE_FOUND)
+
+endif(ODE_INCLUDE_DIRS AND ODE_LIBRARIES)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic