From bdf9acb54fa6415a1d186d9bc8564a8f33fdc7ea Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Tue, 31 Jul 2012 23:48:35 +0200 Subject: [PATCH] Add the makefiles to the repository --- CMakeLists.txt | 21 ++++++++++--- examples/fallingbox/CMakeLists.txt | 50 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 5 deletions(-) mode change 100644 => 100755 CMakeLists.txt create mode 100755 examples/fallingbox/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index e32f3704..6a3bc7aa --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,17 @@ # Minimum cmake version required -cmake_minimum_required(VERSION 2.6) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) # Project configuration -project(ReactPhysics3D) -set(LIBRARY_OUTPUT_PATH lib/) +PROJECT(REACTPHYSICS3D) + +# Where to build the library +SET(LIBRARY_OUTPUT_PATH lib/) + +# Options +OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" OFF) # Headers -include_directories(src) +INCLUDE_DIRECTORIES(src) # Library configuration file ( @@ -15,8 +20,14 @@ file ( src/* ) -add_library ( +# Require the reactphysics3d code to be compiled in a static library +ADD_LIBRARY ( reactphysics3d STATIC ${source_files} ) + +# If we need to compile the examples +IF (COMPILE_EXAMPLES) + add_subdirectory(examples/fallingcubes) +ENDIF (COMPILE_EXAMPLES) diff --git a/examples/fallingbox/CMakeLists.txt b/examples/fallingbox/CMakeLists.txt new file mode 100755 index 00000000..8efa2d44 --- /dev/null +++ b/examples/fallingbox/CMakeLists.txt @@ -0,0 +1,50 @@ +# Minimum cmake version required +cmake_minimum_required(VERSION 2.6) + +# Project configuration +PROJECT(FallingCubes) + +# Headers +INCLUDE_DIRECTORIES(${REACTPHYSICS3D_SOURCE_DIR}/src) + +# Find Glut or Freeglut +if(WIN32 OR APPLE) + # Find the necessary libraries + FIND_PACKAGE(GLUT) +else() + # Find the Freeglut library + FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h + /usr/include/GL + ) + FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut glut) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREEGLUT DEFAULT_MSG FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR) + IF(FREEGLUT_FOUND) + MESSAGE("Freeglut found") + SET(FREEGLUT_LIBRARIES ${FREEGLUT_LIBRARY}) + SET(FREEGLUT_INCLUDE_DIRS ${FREEGLUT_INCLUDE_DIR}) + else() + MESSAGE("Freeglut not found (required to build the examples)") + SET(FREEGLUT_LIBRARIES) + SET(FREEGLUT_INCLUDE_DIRS) + endif() +endif() + +# Find OpenGL +FIND_PACKAGE(OpenGL) +if(OPENGL_FOUND) + MESSAGE("OpenGL found") +else() + MESSAGE("OpenGL not found") +endif() + + +# Create the example executable using the +# compiled reactphysics3d static library +ADD_EXECUTABLE(fallingcubes main.cpp Box.cpp Box.h) + +if(WIN32 OR APPLE) + TARGET_LINK_LIBRARIES(fallingcubes reactphysics3d ${GLUT_LIBRARY} ${OPENGL_LIBRARY}) +elseif(FREEGLUT_FOUND) + TARGET_LINK_LIBRARIES(fallingcubes reactphysics3d ${FREEGLUT_LIBRARY} ${OPENGL_LIBRARY}) +endif()