mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 13:50:04 +00:00
69e5454d18
Use statically linked freeglut, instead of dynamic glut for the obsolete Bullet 2.x demos Add the 'reset' method to b3GpuDynamicsWorld, and use it in the BasicGpuDemo (pretty slow in debug mode, use release mode) Don't crash in btCollisionWorld, if there is no collision dispatcher
284 lines
9.7 KiB
CMake
284 lines
9.7 KiB
CMake
cmake_minimum_required(VERSION 2.4.3)
|
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
|
|
|
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
|
|
SET(MSVC_INCREMENTAL_DEFAULT ON)
|
|
|
|
PROJECT(BULLET_PHYSICS)
|
|
SET(BULLET_VERSION 2.82)
|
|
|
|
IF(COMMAND cmake_policy)
|
|
cmake_policy(SET CMP0003 NEW)
|
|
ENDIF(COMMAND cmake_policy)
|
|
|
|
|
|
IF (NOT CMAKE_BUILD_TYPE)
|
|
# SET(CMAKE_BUILD_TYPE "Debug")
|
|
SET(CMAKE_BUILD_TYPE "Release")
|
|
ENDIF (NOT CMAKE_BUILD_TYPE)
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
|
|
#MESSAGE("CMAKE_CXX_FLAGS_DEBUG="+${CMAKE_CXX_FLAGS_DEBUG})
|
|
|
|
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
|
|
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
|
|
|
|
|
|
OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" OFF)
|
|
OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
|
|
OPTION(USE_CUSTOM_VECTOR_MATH "Use custom vectormath library" OFF)
|
|
|
|
|
|
#SET(CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:NO")
|
|
#SET(CMAKE_EXE_LINKER_FLAGS "/STACK:10000000 /INCREMENTAL:NO")
|
|
|
|
#MESSAGE("MSVC_INCREMENTAL_YES_FLAG"+${MSVC_INCREMENTAL_YES_FLAG})
|
|
|
|
|
|
IF(MSVC)
|
|
IF (NOT USE_MSVC_INCREMENTAL_LINKING)
|
|
#MESSAGE("MSVC_INCREMENTAL_DEFAULT"+${MSVC_INCREMENTAL_DEFAULT})
|
|
SET( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:NO")
|
|
|
|
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
|
|
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
|
|
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
|
|
|
# STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
|
|
# SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
|
|
# STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS})
|
|
# SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
|
|
|
|
|
|
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
|
|
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacementFlags3})
|
|
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO ${replacementFlags3}" )
|
|
|
|
ENDIF (NOT USE_MSVC_INCREMENTAL_LINKING)
|
|
|
|
IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
|
#We statically link to reduce dependancies
|
|
FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
IF(${flag_var} MATCHES "/MD")
|
|
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
ENDIF(${flag_var} MATCHES "/MD")
|
|
IF(${flag_var} MATCHES "/MDd")
|
|
STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
|
|
ENDIF(${flag_var} MATCHES "/MDd")
|
|
ENDFOREACH(flag_var)
|
|
ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
|
|
|
IF (CMAKE_CL_64)
|
|
ADD_DEFINITIONS(-D_WIN64)
|
|
ELSE()
|
|
OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option" ON)
|
|
IF (USE_MSVC_SSE)
|
|
ADD_DEFINITIONS(/arch:SSE)
|
|
ENDIF()
|
|
ENDIF()
|
|
OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
|
|
IF (USE_MSVC_FAST_FLOATINGPOINT)
|
|
ADD_DEFINITIONS(/fp:fast)
|
|
ENDIF()
|
|
ENDIF(MSVC)
|
|
|
|
|
|
|
|
IF (WIN32)
|
|
OPTION(INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES "Create MSVC projectfiles that can be distributed" OFF)
|
|
|
|
IF (INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
|
SET (LIBRARY_OUTPUT_PATH ${BULLET_PHYSICS_SOURCE_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
|
|
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR})
|
|
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BULLET_PHYSICS_SOURCE_DIR})
|
|
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BULLET_PHYSICS_SOURCE_DIR})
|
|
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BULLET_PHYSICS_SOURCE_DIR})
|
|
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BULLET_PHYSICS_SOURCE_DIR})
|
|
ELSE()
|
|
SET (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
|
|
ENDIF()
|
|
|
|
|
|
|
|
OPTION(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES "Create MSVC projectfiles with relative paths" OFF)
|
|
OPTION(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES "Add MSVC postfix for executable names (_Debug)" OFF)
|
|
|
|
SET(CMAKE_DEBUG_POSTFIX "_Debug" CACHE STRING "Adds a postfix for debug-built libraries.")
|
|
SET(CMAKE_MINSIZEREL_POSTFIX "_MinsizeRel" CACHE STRING "Adds a postfix for MinsizeRelease-built libraries.")
|
|
SET(CMAKE_RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo" CACHE STRING "Adds a postfix for ReleaseWithDebug-built libraries.")
|
|
|
|
|
|
|
|
|
|
|
|
IF (INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
|
|
SET(CMAKE_SUPPRESS_REGENERATION 1)
|
|
SET(CMAKE_USE_RELATIVE_PATHS 1)
|
|
ENDIF(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
|
|
|
|
ENDIF (WIN32)
|
|
|
|
|
|
OPTION(BUILD_CPU_DEMOS "Build original Bullet CPU demos" ON)
|
|
|
|
|
|
|
|
OPTION(INTERNAL_UPDATE_SERIALIZATION_STRUCTURES "Internal update serialization structures" OFF)
|
|
IF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
|
ADD_DEFINITIONS( -DBT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
|
ENDIF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
|
|
|
IF (USE_DOUBLE_PRECISION)
|
|
ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
|
|
SET( BULLET_DOUBLE_DEF "-DBT_USE_DOUBLE_PRECISION")
|
|
ENDIF (USE_DOUBLE_PRECISION)
|
|
|
|
IF(USE_GRAPHICAL_BENCHMARK)
|
|
ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK)
|
|
ENDIF (USE_GRAPHICAL_BENCHMARK)
|
|
|
|
IF (WIN32)
|
|
OPTION(USE_GLUT "Use Glut" ON)
|
|
ADD_DEFINITIONS( -D_IRR_STATIC_LIB_ )
|
|
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
|
ADD_DEFINITIONS( -D_CRT_SECURE_NO_DEPRECATE )
|
|
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
|
|
|
|
IF (USE_GLUT AND MSVC)
|
|
string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
remove_definitions(-D_WINDOWS )
|
|
ENDIF()
|
|
|
|
|
|
|
|
ELSE(WIN32)
|
|
OPTION(USE_GLUT "Use Glut" ON)
|
|
ENDIF(WIN32)
|
|
|
|
|
|
IF(COMMAND cmake_policy)
|
|
cmake_policy(SET CMP0003 NEW)
|
|
ENDIF(COMMAND cmake_policy)
|
|
|
|
|
|
# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system
|
|
# This should be the case.
|
|
|
|
FIND_PACKAGE(OpenGL)
|
|
IF (OPENGL_FOUND)
|
|
MESSAGE("OPENGL FOUND")
|
|
MESSAGE(${OPENGL_LIBRARIES})
|
|
ELSE (OPENGL_FOUND)
|
|
MESSAGE("OPENGL NOT FOUND")
|
|
SET(OPENGL_gl_LIBRARY opengl32)
|
|
SET(OPENGL_glu_LIBRARY glu32)
|
|
ENDIF (OPENGL_FOUND)
|
|
|
|
# ADD_DEFINITIONS(-DBT_USE_FREEGLUT)
|
|
|
|
#FIND_PACKAGE(GLU)
|
|
|
|
IF (USE_GLUT)
|
|
IF (MSVC)
|
|
SET(GLUT_FOUND TRUE)
|
|
ADD_DEFINITIONS(-DBT_USE_FREEGLUT)
|
|
|
|
IF (CMAKE_CL_64)
|
|
message("Win64 using static freeglut in ObsoleteDemos/Glut/glut64.lib")
|
|
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut/glut64.lib glu32.lib gdi32.lib winmm.lib user32.lib)
|
|
ELSE(CMAKE_CL_64)
|
|
message("Win32 using static freeglut in ObsoleteDemos/Glut/glut32.lib")
|
|
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut/glut32.lib glu32.lib gdi32.lib winmm.lib user32.lib)
|
|
ENDIF (CMAKE_CL_64)
|
|
INCLUDE_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos/Glut)
|
|
ELSE()
|
|
FIND_PACKAGE(GLUT)
|
|
IF (GLUT_FOUND)
|
|
MESSAGE("GLUT FOUND")
|
|
MESSAGE(${GLUT_glut_LIBRARY})
|
|
ELSE (GLUT_FOUND)
|
|
# IF (MINGW)
|
|
# MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32")
|
|
# SET(GLUT_glut_LIBRARY glut32)
|
|
# #TODO add better GLUT detection for MinGW
|
|
# SET(GLUT_FOUND TRUE)
|
|
# ELSE (MINGW)
|
|
MESSAGE("GLUT NOT FOUND")
|
|
# ENDIF (MINGW)
|
|
ENDIF (GLUT_FOUND)
|
|
ENDIF (MSVC)
|
|
|
|
IF(NOT WIN32)
|
|
# This is added for linux. This should always work if everything is installed and working fine.
|
|
INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
|
|
ENDIF()
|
|
ENDIF(USE_GLUT)
|
|
|
|
|
|
OPTION(BUILD_DEMOS "Set when you want to build the demos" ON)
|
|
IF(BUILD_DEMOS)
|
|
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/ObsoleteDemos)
|
|
SUBDIRS(ObsoleteDemos)
|
|
ENDIF()
|
|
ENDIF(BUILD_DEMOS)
|
|
|
|
|
|
|
|
|
|
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
|
|
|
|
SUBDIRS(src)
|
|
|
|
IF("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
|
|
OPTION(INSTALL_LIBS "Set when you want to install libraries" ON)
|
|
ELSE()
|
|
IF(APPLE AND FRAMEWORK)
|
|
OPTION(INSTALL_LIBS "Set when you want to install libraries" ON)
|
|
ELSE()
|
|
#by default, don't enable the 'INSTALL' option for Xcode and MSVC projectfiles
|
|
OPTION(INSTALL_LIBS "Set when you want to install libraries" OFF)
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
IF(INSTALL_LIBS)
|
|
SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
|
|
SET (LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name")
|
|
## the following are directories where stuff will be installed to
|
|
SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/bullet/" CACHE PATH "The subdirectory to the header prefix")
|
|
SET(PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
|
|
IF(NOT WIN32)
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc @ONLY)
|
|
INSTALL(
|
|
FILES
|
|
${CMAKE_CURRENT_BINARY_DIR}/bullet.pc
|
|
DESTINATION
|
|
${PKGCONFIG_INSTALL_PREFIX})
|
|
ENDIF(NOT WIN32)
|
|
ENDIF(INSTALL_LIBS)
|
|
|
|
#INSTALL of other files requires CMake 2.6
|
|
#IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
|
# OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF)
|
|
#ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
|
|
|
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" OFF)
|
|
|
|
IF (BUILD_UNIT_TESTS)
|
|
SUBDIRS(UnitTests)
|
|
ENDIF()
|
|
|
|
set (BULLET_CONFIG_CMAKE_PATH lib${LIB_SUFFIX}/cmake/bullet )
|
|
list (APPEND BULLET_LIBRARIES LinearMath)
|
|
list (APPEND BULLET_LIBRARIES BulletCollisions)
|
|
list (APPEND BULLET_LIBRARIES BulletDynamics)
|
|
list (APPEND BULLET_LIBRARIES BulletSoftBody)
|
|
set (BULLET_USE_FILE ${CMAKE_INSTALL_PREFIX}/${BULLET_CONFIG_CMAKE_PATH}/UseBullet.cmake)
|
|
configure_file ( ${CMAKE_SOURCE_DIR}/BulletConfig.cmake.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
|
|
@ONLY ESCAPE_QUOTES
|
|
)
|
|
install ( FILES ${CMAKE_SOURCE_DIR}/UseBullet.cmake
|
|
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
|
|
DESTINATION ${BULLET_CONFIG_CMAKE_PATH}
|
|
)
|